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

Unified Diff: ui/gfx/platform_font_pango.cc

Issue 9117009: Move |PlatformFont::GetStringWidth()| implementation up into font.cc directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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 | « ui/gfx/platform_font_pango.h ('k') | ui/gfx/platform_font_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/platform_font_pango.cc
===================================================================
--- ui/gfx/platform_font_pango.cc (revision 118837)
+++ ui/gfx/platform_font_pango.cc (working copy)
@@ -239,13 +239,6 @@
return SkScalarRound(average_width_pixels_);
}
-int PlatformFontPango::GetStringWidth(const string16& text) const {
- int width = 0, height = 0;
- CanvasSkia::SizeStringInt(text, Font(const_cast<PlatformFontPango*>(this)),
- &width, &height, gfx::Canvas::NO_ELLIPSIS);
- return width;
-}
-
int PlatformFontPango::GetExpectedTextWidth(int length) const {
double char_width = const_cast<PlatformFontPango*>(this)->GetAverageWidth();
return round(static_cast<float>(length) * char_width);
@@ -399,15 +392,16 @@
PANGO_SCALE;
// First get the Pango-based width (converting from Pango units to pixels).
- double pango_width_pixels =
+ const double pango_width_pixels =
pango_font_metrics_get_approximate_char_width(pango_metrics) /
PANGO_SCALE;
// Yes, this is how Microsoft recommends calculating the dialog unit
// conversions.
- int text_width_pixels = GetStringWidth(
- ASCIIToUTF16("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
- double dialog_units_pixels = (text_width_pixels / 26 + 1) / 2;
+ const int text_width_pixels = CanvasSkia::GetStringWidth(
+ ASCIIToUTF16("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"),
+ Font(this));
+ const double dialog_units_pixels = (text_width_pixels / 26 + 1) / 2;
average_width_pixels_ = std::min(pango_width_pixels, dialog_units_pixels);
pango_font_description_free(pango_desc);
}
« no previous file with comments | « ui/gfx/platform_font_pango.h ('k') | ui/gfx/platform_font_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698