Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: gfx/font_win.cc

Issue 2895017: Revert Win specific elements of 46492 to look for perf impact... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gfx/font_win.cc
===================================================================
--- gfx/font_win.cc (revision 51805)
+++ gfx/font_win.cc (working copy)
@@ -170,9 +170,18 @@
}
int Font::GetStringWidth(const std::wstring& text) const {
- int width = 0, height = 0;
- CanvasSkia::SizeStringInt(text, *this, &width, &height,
- gfx::Canvas::NO_ELLIPSIS);
+ int width = 0;
+ HDC dc = GetDC(NULL);
+ HFONT previous_font = static_cast<HFONT>(SelectObject(dc, hfont()));
+ SIZE size;
+ if (GetTextExtentPoint32(dc, text.c_str(), static_cast<int>(text.size()),
+ &size)) {
+ width = size.cx;
+ } else {
+ width = 0;
+ }
+ SelectObject(dc, previous_font);
+ ReleaseDC(NULL, dc);
return width;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698