diff options
-rw-r--r-- | gfx/font.cc | 3 | ||||
-rw-r--r-- | gfx/platform_font.h | 3 | ||||
-rw-r--r-- | gfx/platform_font_gtk.cc | 7 | ||||
-rw-r--r-- | gfx/platform_font_gtk.h | 2 | ||||
-rw-r--r-- | gfx/platform_font_mac.h | 2 | ||||
-rw-r--r-- | gfx/platform_font_mac.mm | 5 | ||||
-rw-r--r-- | gfx/platform_font_win.cc | 5 | ||||
-rw-r--r-- | gfx/platform_font_win.h | 2 |
8 files changed, 14 insertions, 15 deletions
diff --git a/gfx/font.cc b/gfx/font.cc index 625968a..1c3400b 100644 --- a/gfx/font.cc +++ b/gfx/font.cc @@ -4,6 +4,7 @@ #include "gfx/font.h" +#include "base/utf_string_conversions.h" #include "gfx/platform_font.h" namespace gfx { @@ -58,7 +59,7 @@ int Font::GetAverageCharacterWidth() const { } int Font::GetStringWidth(const std::wstring& text) const { - return platform_font_->GetStringWidth(text); + return platform_font_->GetStringWidth(WideToUTF16Hack(text)); } int Font::GetExpectedTextWidth(int length) const { diff --git a/gfx/platform_font.h b/gfx/platform_font.h index df3c7f2..87900f3 100644 --- a/gfx/platform_font.h +++ b/gfx/platform_font.h @@ -9,6 +9,7 @@ #include <string> #include "base/ref_counted.h" +#include "base/string16.h" #include "gfx/native_widget_types.h" namespace gfx { @@ -46,7 +47,7 @@ class PlatformFont : public base::RefCounted<PlatformFont> { // Returns the number of horizontal pixels needed to display the specified // string. - virtual int GetStringWidth(const std::wstring& text) const = 0; + virtual int GetStringWidth(const string16& text) const = 0; // Returns the expected number of horizontal pixels needed to display the // specified length of characters. Call GetStringWidth() to retrieve the diff --git a/gfx/platform_font_gtk.cc b/gfx/platform_font_gtk.cc index bc4d05b..3e038d7 100644 --- a/gfx/platform_font_gtk.cc +++ b/gfx/platform_font_gtk.cc @@ -219,10 +219,9 @@ int PlatformFontGtk::GetAverageCharacterWidth() const { return SkScalarRound(average_width_); } -int PlatformFontGtk::GetStringWidth(const std::wstring& text) const { +int PlatformFontGtk::GetStringWidth(const string16& text) const { int width = 0, height = 0; - CanvasSkia::SizeStringInt(WideToUTF16Hack(text), - Font(const_cast<PlatformFontGtk*>(this)), + CanvasSkia::SizeStringInt(text, Font(const_cast<PlatformFontGtk*>(this)), &width, &height, gfx::Canvas::NO_ELLIPSIS); return width; } @@ -385,7 +384,7 @@ void PlatformFontGtk::InitPangoMetrics() { // Yes, this is how Microsoft recommends calculating the dialog unit // conversions. int text_width = GetStringWidth( - L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); + ASCIIToUTF16("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); double dialog_units = (text_width / 26 + 1) / 2; average_width_ = std::min(pango_width, dialog_units); pango_font_description_free(pango_desc); diff --git a/gfx/platform_font_gtk.h b/gfx/platform_font_gtk.h index bc7be66..d36142d 100644 --- a/gfx/platform_font_gtk.h +++ b/gfx/platform_font_gtk.h @@ -39,7 +39,7 @@ class PlatformFontGtk : public PlatformFont { virtual int GetHeight() const; virtual int GetBaseline() const; virtual int GetAverageCharacterWidth() const; - virtual int GetStringWidth(const std::wstring& text) const; + virtual int GetStringWidth(const string16& text) const; virtual int GetExpectedTextWidth(int length) const; virtual int GetStyle() const; virtual const std::wstring& GetFontName() const; diff --git a/gfx/platform_font_mac.h b/gfx/platform_font_mac.h index 71a8262..11440ebb 100644 --- a/gfx/platform_font_mac.h +++ b/gfx/platform_font_mac.h @@ -23,7 +23,7 @@ class PlatformFontMac : public PlatformFont { virtual int GetHeight() const; virtual int GetBaseline() const; virtual int GetAverageCharacterWidth() const; - virtual int GetStringWidth(const std::wstring& text) const; + virtual int GetStringWidth(const string16& text) const; virtual int GetExpectedTextWidth(int length) const; virtual int GetStyle() const; virtual const std::wstring& GetFontName() const; diff --git a/gfx/platform_font_mac.mm b/gfx/platform_font_mac.mm index 80b9be4..15d08f8 100644 --- a/gfx/platform_font_mac.mm +++ b/gfx/platform_font_mac.mm @@ -56,10 +56,9 @@ int PlatformFontMac::GetAverageCharacterWidth() const { return average_width_; } -int PlatformFontMac::GetStringWidth(const std::wstring& text) const { +int PlatformFontMac::GetStringWidth(const string16& text) const { int width = 0, height = 0; - CanvasSkia::SizeStringInt(WideToUTF16Hack(text), - Font(const_cast<PlatformFontMac*>(this)), + CanvasSkia::SizeStringInt(text, Font(const_cast<PlatformFontMac*>(this)), &width, &height, gfx::Canvas::NO_ELLIPSIS); return width; } diff --git a/gfx/platform_font_win.cc b/gfx/platform_font_win.cc index 05db587..8191c44 100644 --- a/gfx/platform_font_win.cc +++ b/gfx/platform_font_win.cc @@ -102,10 +102,9 @@ int PlatformFontWin::GetAverageCharacterWidth() const { return font_ref_->ave_char_width(); } -int PlatformFontWin::GetStringWidth(const std::wstring& text) const { +int PlatformFontWin::GetStringWidth(const string16& text) const { int width = 0, height = 0; - CanvasSkia::SizeStringInt(WideToUTF16Hack(text), - Font(const_cast<PlatformFontWin*>(this)), + CanvasSkia::SizeStringInt(text, Font(const_cast<PlatformFontWin*>(this)), &width, &height, gfx::Canvas::NO_ELLIPSIS); return width; } diff --git a/gfx/platform_font_win.h b/gfx/platform_font_win.h index 1fd89166..0c310db 100644 --- a/gfx/platform_font_win.h +++ b/gfx/platform_font_win.h @@ -45,7 +45,7 @@ class PlatformFontWin : public PlatformFont { virtual int GetHeight() const; virtual int GetBaseline() const; virtual int GetAverageCharacterWidth() const; - virtual int GetStringWidth(const std::wstring& text) const; + virtual int GetStringWidth(const string16& text) const; virtual int GetExpectedTextWidth(int length) const; virtual int GetStyle() const; virtual const std::wstring& GetFontName() const; |