summaryrefslogtreecommitdiffstats
path: root/gfx
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-12 14:37:16 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-12 14:37:16 +0000
commit3f891cf79f72f4768a15bfae051e08b9211ed8c3 (patch)
tree3cf8d59e7186889184f575fcbe3284e6400fb505 /gfx
parente0c7405b8f24e6c0096285446f94f729e63107df (diff)
downloadchromium_src-3f891cf79f72f4768a15bfae051e08b9211ed8c3.zip
chromium_src-3f891cf79f72f4768a15bfae051e08b9211ed8c3.tar.gz
chromium_src-3f891cf79f72f4768a15bfae051e08b9211ed8c3.tar.bz2
Remove wstring from gfx.
BUG=68882 TEST=no visible changes; all tests pass Review URL: http://codereview.chromium.org/6121004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71167 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx')
-rw-r--r--gfx/canvas.h7
-rw-r--r--gfx/canvas_direct2d.cc6
-rw-r--r--gfx/canvas_direct2d.h6
-rw-r--r--gfx/canvas_skia.cc4
-rw-r--r--gfx/canvas_skia.h10
-rw-r--r--gfx/canvas_skia_linux.cc11
-rw-r--r--gfx/canvas_skia_mac.mm6
-rw-r--r--gfx/canvas_skia_win.cc18
-rw-r--r--gfx/font.cc4
-rw-r--r--gfx/font.h4
-rw-r--r--gfx/font_unittest.cc14
-rw-r--r--gfx/platform_font.h4
-rw-r--r--gfx/platform_font_gtk.cc31
-rw-r--r--gfx/platform_font_gtk.h12
-rw-r--r--gfx/platform_font_mac.h10
-rw-r--r--gfx/platform_font_mac.mm14
-rw-r--r--gfx/platform_font_win.cc10
-rw-r--r--gfx/platform_font_win.h10
18 files changed, 90 insertions, 91 deletions
diff --git a/gfx/canvas.h b/gfx/canvas.h
index b64c926..17a9586 100644
--- a/gfx/canvas.h
+++ b/gfx/canvas.h
@@ -8,6 +8,7 @@
#include <string>
+#include "base/string16.h"
#include "gfx/native_widget_types.h"
// TODO(beng): remove this include when we no longer depend on SkTypes.
#include "skia/ext/platform_canvas.h"
@@ -171,11 +172,11 @@ class Canvas {
// Draws text with the specified color, font and location. The text is
// aligned to the left, vertically centered, clipped to the region. If the
// text is too big, it is truncated and '...' is added to the end.
- virtual void DrawStringInt(const std::wstring& text, const
+ virtual void DrawStringInt(const string16& text, const
gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h) = 0;
- virtual void DrawStringInt(const std::wstring& text,
+ virtual void DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
const gfx::Rect& display_rect) = 0;
@@ -183,7 +184,7 @@ class Canvas {
// Draws text with the specified color, font and location. The last argument
// specifies flags for how the text should be rendered. It can be one of
// TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT.
- virtual void DrawStringInt(const std::wstring& text,
+ virtual void DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h,
diff --git a/gfx/canvas_direct2d.cc b/gfx/canvas_direct2d.cc
index 585659d..cba7b64 100644
--- a/gfx/canvas_direct2d.cc
+++ b/gfx/canvas_direct2d.cc
@@ -286,21 +286,21 @@ void CanvasDirect2D::DrawBitmapInt(const SkBitmap& bitmap,
NOTIMPLEMENTED();
}
-void CanvasDirect2D::DrawStringInt(const std::wstring& text,
+void CanvasDirect2D::DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h) {
NOTIMPLEMENTED();
}
-void CanvasDirect2D::DrawStringInt(const std::wstring& text,
+void CanvasDirect2D::DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
const gfx::Rect& display_rect) {
NOTIMPLEMENTED();
}
-void CanvasDirect2D::DrawStringInt(const std::wstring& text,
+void CanvasDirect2D::DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h,
diff --git a/gfx/canvas_direct2d.h b/gfx/canvas_direct2d.h
index 89ea448..740a24d 100644
--- a/gfx/canvas_direct2d.h
+++ b/gfx/canvas_direct2d.h
@@ -57,15 +57,15 @@ class CanvasDirect2D : public Canvas {
int dest_x, int dest_y, int dest_w, int dest_h,
bool filter,
const SkPaint& paint);
- virtual void DrawStringInt(const std::wstring& text,
+ virtual void DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h);
- virtual void DrawStringInt(const std::wstring& text,
+ virtual void DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
const gfx::Rect& display_rect);
- virtual void DrawStringInt(const std::wstring& text,
+ virtual void DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h,
diff --git a/gfx/canvas_skia.cc b/gfx/canvas_skia.cc
index 017fd5f..aa0cb9d 100644
--- a/gfx/canvas_skia.cc
+++ b/gfx/canvas_skia.cc
@@ -277,7 +277,7 @@ void CanvasSkia::DrawBitmapInt(const SkBitmap& bitmap,
drawRect(dest_rect, p);
}
-void CanvasSkia::DrawStringInt(const std::wstring& text,
+void CanvasSkia::DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h) {
@@ -285,7 +285,7 @@ void CanvasSkia::DrawStringInt(const std::wstring& text,
gfx::CanvasSkia::DefaultCanvasTextAlignment());
}
-void CanvasSkia::DrawStringInt(const std::wstring& text,
+void CanvasSkia::DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
const gfx::Rect& display_rect) {
diff --git a/gfx/canvas_skia.h b/gfx/canvas_skia.h
index 7db41a0..b8b0aa9 100644
--- a/gfx/canvas_skia.h
+++ b/gfx/canvas_skia.h
@@ -75,7 +75,7 @@ class CanvasSkia : public skia::PlatformCanvas,
// we don't do any fancy blurring.
// On Linux, text with halo is created by stroking it with 2px |halo_color|
// then filling it with |text_color|.
- void DrawStringWithHalo(const std::wstring& text,
+ void DrawStringWithHalo(const string16& text,
const gfx::Font& font,
const SkColor& text_color,
const SkColor& halo_color,
@@ -119,15 +119,15 @@ class CanvasSkia : public skia::PlatformCanvas,
int dest_x, int dest_y, int dest_w, int dest_h,
bool filter,
const SkPaint& paint);
- virtual void DrawStringInt(const std::wstring& text,
+ virtual void DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h);
- virtual void DrawStringInt(const std::wstring& text,
+ virtual void DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
const gfx::Rect& display_rect);
- virtual void DrawStringInt(const std::wstring& text,
+ virtual void DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h,
@@ -150,7 +150,7 @@ class CanvasSkia : public skia::PlatformCanvas,
// Draws text with the specified color, font and location. The text is
// aligned to the left, vertically centered, clipped to the region. If the
// text is too big, it is truncated and '...' is added to the end.
- void DrawStringInt(const std::wstring& text,
+ void DrawStringInt(const string16& text,
HFONT font,
const SkColor& color,
int x, int y, int w, int h,
diff --git a/gfx/canvas_skia_linux.cc b/gfx/canvas_skia_linux.cc
index 903c99f..ce2ae01 100644
--- a/gfx/canvas_skia_linux.cc
+++ b/gfx/canvas_skia_linux.cc
@@ -162,7 +162,7 @@ static void SetupPangoLayout(PangoLayout* layout,
class DrawStringContext {
public:
DrawStringContext(gfx::CanvasSkia* canvas,
- const std::wstring& text,
+ const string16& text,
const gfx::Font& font,
const gfx::Rect& bounds,
const gfx::Rect& clip,
@@ -191,7 +191,7 @@ class DrawStringContext {
};
DrawStringContext::DrawStringContext(gfx::CanvasSkia* canvas,
- const std::wstring& text,
+ const string16& text,
const gfx::Font& font,
const gfx::Rect& bounds,
const gfx::Rect& clip,
@@ -211,8 +211,7 @@ DrawStringContext::DrawStringContext(gfx::CanvasSkia* canvas,
cr_ = canvas_->beginPlatformPaint();
layout_ = pango_cairo_create_layout(cr_);
- SetupPangoLayout(layout_, WideToUTF16Hack(text), font, bounds_.width(),
- flags_);
+ SetupPangoLayout(layout_, text, font, bounds_.width(), flags_);
pango_layout_set_height(layout_, bounds_.height() * PANGO_SCALE);
@@ -346,7 +345,7 @@ void CanvasSkia::SizeStringInt(const string16& text,
cairo_surface_destroy(surface);
}
-void CanvasSkia::DrawStringWithHalo(const std::wstring& text,
+void CanvasSkia::DrawStringWithHalo(const string16& text,
const gfx::Font& font,
const SkColor& text_color,
const SkColor& halo_color,
@@ -361,7 +360,7 @@ void CanvasSkia::DrawStringWithHalo(const std::wstring& text,
context.DrawWithHalo(text_color, halo_color);
}
-void CanvasSkia::DrawStringInt(const std::wstring& text,
+void CanvasSkia::DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h,
diff --git a/gfx/canvas_skia_mac.mm b/gfx/canvas_skia_mac.mm
index 1c3dcca..fb30055 100644
--- a/gfx/canvas_skia_mac.mm
+++ b/gfx/canvas_skia_mac.mm
@@ -39,7 +39,7 @@ void CanvasSkia::SizeStringInt(const string16& text,
*height = font.GetHeight();
}
-void CanvasSkia::DrawStringInt(const std::wstring& text,
+void CanvasSkia::DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h,
@@ -68,8 +68,8 @@ void CanvasSkia::DrawStringInt(const std::wstring& text,
nil];
NSAttributedString* ns_string =
- [[[NSAttributedString alloc] initWithString:base::SysWideToNSString(text)
- attributes:attributes] autorelease];
+ [[[NSAttributedString alloc] initWithString:base::SysUTF16ToNSString(text)
+ attributes:attributes] autorelease];
base::mac::ScopedCFTypeRef<CTFramesetterRef> framesetter(
CTFramesetterCreateWithAttributedString(
reinterpret_cast<CFAttributedStringRef>(ns_string)));
diff --git a/gfx/canvas_skia_win.cc b/gfx/canvas_skia_win.cc
index dd8c96a..03186fa 100644
--- a/gfx/canvas_skia_win.cc
+++ b/gfx/canvas_skia_win.cc
@@ -16,7 +16,7 @@ namespace {
// We make sure that LTR text we draw in an RTL context is modified
// appropriately to make sure it maintains it LTR orientation.
void DoDrawText(HDC hdc,
- const std::wstring& text,
+ const string16& text,
RECT* text_bounds,
int flags) {
// Only adjust string directionality if both of the following are true:
@@ -25,7 +25,7 @@ void DoDrawText(HDC hdc,
const wchar_t* string_ptr = text.c_str();
int string_size = static_cast<int>(text.length());
- std::wstring localized_text;
+ string16 localized_text;
if (flags & DT_RTLREADING) {
localized_text = text;
base::i18n::AdjustStringForLocaleDirection(&localized_text);
@@ -38,7 +38,7 @@ void DoDrawText(HDC hdc,
// Compute the windows flags necessary to implement the provided text Canvas
// flags.
-int ComputeFormatFlags(int flags, const std::wstring& text) {
+int ComputeFormatFlags(int flags, const string16& text) {
// Setting the text alignment explicitly in case it hasn't already been set.
// This will make sure that we don't align text to the left on RTL locales
// just because no alignment flag was passed to DrawStringInt().
@@ -139,7 +139,7 @@ CanvasSkia::~CanvasSkia() {
}
// static
-void CanvasSkia::SizeStringInt(const std::wstring& text,
+void CanvasSkia::SizeStringInt(const string16& text,
const gfx::Font& font,
int* width, int* height,
int flags) {
@@ -147,7 +147,7 @@ void CanvasSkia::SizeStringInt(const std::wstring& text,
// actually drawn, it will be clipped to whatever size box is provided, and
// the time to do that doesn't depend on the length being clipped off.
const int kMaxStringLength = 2048 - 1; // So the trailing \0 fits in 2K.
- std::wstring clamped_string(text.substr(0, kMaxStringLength));
+ string16 clamped_string(text.substr(0, kMaxStringLength));
if (*width == 0) {
// If multi-line + character break are on, the computed width will be one
@@ -177,7 +177,7 @@ void CanvasSkia::SizeStringInt(const std::wstring& text,
*height = r.bottom;
}
-void CanvasSkia::DrawStringInt(const std::wstring& text,
+void CanvasSkia::DrawStringInt(const string16& text,
HFONT font,
const SkColor& color,
int x, int y, int w, int h,
@@ -190,7 +190,7 @@ void CanvasSkia::DrawStringInt(const std::wstring& text,
// length > 43680 (for which it draws nothing), and since we clamped to 2K in
// SizeStringInt() we're unlikely to be able to display this much anyway.
const int kMaxStringLength = 32768 - 1; // So the trailing \0 fits in 32K.
- std::wstring clamped_string(text.substr(0, kMaxStringLength));
+ string16 clamped_string(text.substr(0, kMaxStringLength));
RECT text_bounds = { x, y, x + w, y + h };
HDC dc = beginPlatformPaint();
@@ -214,7 +214,7 @@ void CanvasSkia::DrawStringInt(const std::wstring& text,
getTopPlatformDevice().makeOpaque(x, y, w, h);
}
-void CanvasSkia::DrawStringInt(const std::wstring& text,
+void CanvasSkia::DrawStringInt(const string16& text,
const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h,
@@ -250,7 +250,7 @@ static bool pixelShouldGetHalo(const SkBitmap& bitmap,
return false;
}
-void CanvasSkia::DrawStringWithHalo(const std::wstring& text,
+void CanvasSkia::DrawStringWithHalo(const string16& text,
const gfx::Font& font,
const SkColor& text_color,
const SkColor& halo_color_in,
diff --git a/gfx/font.cc b/gfx/font.cc
index 6897022..8b8241d 100644
--- a/gfx/font.cc
+++ b/gfx/font.cc
@@ -30,7 +30,7 @@ Font::Font(NativeFont native_font)
Font::Font(PlatformFont* platform_font) : platform_font_(platform_font) {
}
-Font::Font(const std::wstring& font_name, int font_size)
+Font::Font(const string16& font_name, int font_size)
: platform_font_(PlatformFont::CreateFromNameAndSize(font_name,
font_size)) {
}
@@ -70,7 +70,7 @@ int Font::GetStyle() const {
return platform_font_->GetStyle();
}
-const std::wstring& Font::GetFontName() const {
+string16 Font::GetFontName() const {
return platform_font_->GetFontName();
}
diff --git a/gfx/font.h b/gfx/font.h
index d0b16a4..eb6e4d5 100644
--- a/gfx/font.h
+++ b/gfx/font.h
@@ -43,7 +43,7 @@ class Font {
explicit Font(PlatformFont* platform_font);
// Creates a font with the specified name and size.
- Font(const std::wstring& font_name, int font_size);
+ Font(const string16& font_name, int font_size);
~Font();
@@ -85,7 +85,7 @@ class Font {
int GetStyle() const;
// Returns the font name.
- const std::wstring& GetFontName() const;
+ string16 GetFontName() const;
// Returns the font size in pixels.
int GetFontSize() const;
diff --git a/gfx/font_unittest.cc b/gfx/font_unittest.cc
index 3f26507..43eaa7c 100644
--- a/gfx/font_unittest.cc
+++ b/gfx/font_unittest.cc
@@ -46,35 +46,35 @@ int ScopedMinimumFontSizeCallback::minimum_size_ = 0;
TEST_F(FontTest, LoadArial) {
- Font cf(L"Arial", 16);
+ Font cf(ASCIIToUTF16("Arial"), 16);
ASSERT_TRUE(cf.GetNativeFont());
ASSERT_EQ(cf.GetStyle(), Font::NORMAL);
ASSERT_EQ(cf.GetFontSize(), 16);
- ASSERT_EQ(cf.GetFontName(), L"Arial");
+ ASSERT_EQ(cf.GetFontName(), ASCIIToUTF16("Arial"));
}
TEST_F(FontTest, LoadArialBold) {
- Font cf(L"Arial", 16);
+ Font cf(ASCIIToUTF16("Arial"), 16);
Font bold(cf.DeriveFont(0, Font::BOLD));
ASSERT_TRUE(bold.GetNativeFont());
ASSERT_EQ(bold.GetStyle(), Font::BOLD);
}
TEST_F(FontTest, Ascent) {
- Font cf(L"Arial", 16);
+ Font cf(ASCIIToUTF16("Arial"), 16);
ASSERT_GT(cf.GetBaseline(), 2);
ASSERT_LE(cf.GetBaseline(), 22);
}
TEST_F(FontTest, Height) {
- Font cf(L"Arial", 16);
+ Font cf(ASCIIToUTF16("Arial"), 16);
ASSERT_GE(cf.GetHeight(), 16);
// TODO(akalin): Figure out why height is so large on Linux.
ASSERT_LE(cf.GetHeight(), 26);
}
TEST_F(FontTest, AvgWidths) {
- Font cf(L"Arial", 16);
+ Font cf(ASCIIToUTF16("Arial"), 16);
ASSERT_EQ(cf.GetExpectedTextWidth(0), 0);
ASSERT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0));
ASSERT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1));
@@ -82,7 +82,7 @@ TEST_F(FontTest, AvgWidths) {
}
TEST_F(FontTest, Widths) {
- Font cf(L"Arial", 16);
+ Font cf(ASCIIToUTF16("Arial"), 16);
ASSERT_EQ(cf.GetStringWidth(ASCIIToUTF16("")), 0);
ASSERT_GT(cf.GetStringWidth(ASCIIToUTF16("a")),
cf.GetStringWidth(ASCIIToUTF16("")));
diff --git a/gfx/platform_font.h b/gfx/platform_font.h
index 87900f3..412e260 100644
--- a/gfx/platform_font.h
+++ b/gfx/platform_font.h
@@ -22,7 +22,7 @@ class PlatformFont : public base::RefCounted<PlatformFont> {
static PlatformFont* CreateDefault();
static PlatformFont* CreateFromFont(const Font& other);
static PlatformFont* CreateFromNativeFont(NativeFont native_font);
- static PlatformFont* CreateFromNameAndSize(const std::wstring& font_name,
+ static PlatformFont* CreateFromNameAndSize(const string16& font_name,
int font_size);
// Returns a new Font derived from the existing font.
@@ -58,7 +58,7 @@ class PlatformFont : public base::RefCounted<PlatformFont> {
virtual int GetStyle() const = 0;
// Returns the font name.
- virtual const std::wstring& GetFontName() const = 0;
+ virtual string16 GetFontName() const = 0;
// Returns the font size in pixels.
virtual int GetFontSize() const = 0;
diff --git a/gfx/platform_font_gtk.cc b/gfx/platform_font_gtk.cc
index 3e038d7..61a0933 100644
--- a/gfx/platform_font_gtk.cc
+++ b/gfx/platform_font_gtk.cc
@@ -13,7 +13,6 @@
#include "base/logging.h"
#include "base/string_piece.h"
-#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "gfx/canvas_skia.h"
#include "gfx/font.h"
@@ -67,7 +66,7 @@ PangoFontMetrics* GetPangoFontMetrics(PangoFontDescription* desc) {
// PGothic". In this case, SkTypeface for "Sans" returns NULL even if
// the system has a font for "Sans" font family. See FontMatch() in
// skia/ports/SkFontHost_fontconfig.cpp for more detail.
-std::wstring FindBestMatchFontFamilyName(const char* family_name) {
+string16 FindBestMatchFontFamilyName(const char* family_name) {
FcPattern* pattern = FcPatternCreate();
FcValue fcvalue;
fcvalue.type = FcTypeString;
@@ -82,7 +81,7 @@ std::wstring FindBestMatchFontFamilyName(const char* family_name) {
FcChar8* match_family;
FcPatternGetString(match, FC_FAMILY, 0, &match_family);
- std::wstring font_family = UTF8ToWide(reinterpret_cast<char*>(match_family));
+ string16 font_family = UTF8ToUTF16(reinterpret_cast<char*>(match_family));
FcPatternDestroy(match);
FcPatternDestroy(pattern);
free(family_name_copy);
@@ -141,7 +140,7 @@ PlatformFontGtk::PlatformFontGtk(NativeFont native_font) {
// Find best match font for |family_name| to make sure we can get
// a SkTypeface for the default font.
// TODO(agl): remove this.
- std::wstring font_family = FindBestMatchFontFamilyName(family_name);
+ string16 font_family = FindBestMatchFontFamilyName(family_name);
InitWithNameAndSize(font_family, size / PANGO_SCALE);
int style = 0;
@@ -158,7 +157,7 @@ PlatformFontGtk::PlatformFontGtk(NativeFont native_font) {
style_ = style;
}
-PlatformFontGtk::PlatformFontGtk(const std::wstring& font_name,
+PlatformFontGtk::PlatformFontGtk(const string16& font_name,
int font_size) {
InitWithNameAndSize(font_name, font_size);
}
@@ -197,7 +196,7 @@ Font PlatformFontGtk::DeriveFont(int size_delta, int style) const {
skstyle |= SkTypeface::kItalic;
SkTypeface* typeface = SkTypeface::CreateFromName(
- base::SysWideToUTF8(font_family_).c_str(),
+ UTF16ToUTF8(font_family_).c_str(),
static_cast<SkTypeface::Style>(skstyle));
SkAutoUnref tf_helper(typeface);
@@ -235,7 +234,7 @@ int PlatformFontGtk::GetStyle() const {
return style_;
}
-const std::wstring& PlatformFontGtk::GetFontName() const {
+string16 PlatformFontGtk::GetFontName() const {
return font_family_;
}
@@ -245,7 +244,7 @@ int PlatformFontGtk::GetFontSize() const {
NativeFont PlatformFontGtk::GetNativeFont() const {
PangoFontDescription* pfd = pango_font_description_new();
- pango_font_description_set_family(pfd, WideToUTF8(GetFontName()).c_str());
+ pango_font_description_set_family(pfd, UTF16ToUTF8(GetFontName()).c_str());
// Set the absolute size to avoid overflowing UI elements.
pango_font_description_set_absolute_size(pfd,
GetFontSize() * PANGO_SCALE * GetPangoScaleFactor());
@@ -273,7 +272,7 @@ NativeFont PlatformFontGtk::GetNativeFont() const {
// PlatformFontGtk, private:
PlatformFontGtk::PlatformFontGtk(SkTypeface* typeface,
- const std::wstring& name,
+ const string16& name,
int size,
int style) {
InitWithTypefaceNameSizeAndStyle(typeface, name, size, style);
@@ -281,22 +280,22 @@ PlatformFontGtk::PlatformFontGtk(SkTypeface* typeface,
PlatformFontGtk::~PlatformFontGtk() {}
-void PlatformFontGtk::InitWithNameAndSize(const std::wstring& font_name,
+void PlatformFontGtk::InitWithNameAndSize(const string16& font_name,
int font_size) {
DCHECK_GT(font_size, 0);
- std::wstring fallback;
+ string16 fallback;
SkTypeface* typeface = SkTypeface::CreateFromName(
- base::SysWideToUTF8(font_name).c_str(), SkTypeface::kNormal);
+ UTF16ToUTF8(font_name).c_str(), SkTypeface::kNormal);
if (!typeface) {
// A non-scalable font such as .pcf is specified. Falls back to a default
// scalable font.
typeface = SkTypeface::CreateFromName(
kFallbackFontFamilyName, SkTypeface::kNormal);
CHECK(typeface) << "Could not find any font: "
- << base::SysWideToUTF8(font_name)
+ << UTF16ToUTF8(font_name)
<< ", " << kFallbackFontFamilyName;
- fallback = base::SysUTF8ToWide(kFallbackFontFamilyName);
+ fallback = UTF8ToUTF16(kFallbackFontFamilyName);
}
SkAutoUnref typeface_helper(typeface);
@@ -308,7 +307,7 @@ void PlatformFontGtk::InitWithNameAndSize(const std::wstring& font_name,
void PlatformFontGtk::InitWithTypefaceNameSizeAndStyle(
SkTypeface* typeface,
- const std::wstring& font_family,
+ const string16& font_family,
int font_size,
int style) {
typeface_helper_.reset(new SkAutoUnref(typeface));
@@ -435,7 +434,7 @@ PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) {
}
// static
-PlatformFont* PlatformFont::CreateFromNameAndSize(const std::wstring& font_name,
+PlatformFont* PlatformFont::CreateFromNameAndSize(const string16& font_name,
int font_size) {
return new PlatformFontGtk(font_name, font_size);
}
diff --git a/gfx/platform_font_gtk.h b/gfx/platform_font_gtk.h
index a7f3c21..fedbfc1 100644
--- a/gfx/platform_font_gtk.h
+++ b/gfx/platform_font_gtk.h
@@ -20,7 +20,7 @@ class PlatformFontGtk : public PlatformFont {
PlatformFontGtk();
explicit PlatformFontGtk(const Font& other);
explicit PlatformFontGtk(NativeFont native_font);
- PlatformFontGtk(const std::wstring& font_name,
+ PlatformFontGtk(const string16& font_name,
int font_size);
// Converts |gfx_font| to a new pango font. Free the returned font with
@@ -45,7 +45,7 @@ class PlatformFontGtk : public PlatformFont {
virtual int GetStringWidth(const string16& text) const;
virtual int GetExpectedTextWidth(int length) const;
virtual int GetStyle() const;
- virtual const std::wstring& GetFontName() const;
+ virtual string16 GetFontName() const;
virtual int GetFontSize() const;
virtual NativeFont GetNativeFont() const;
@@ -53,15 +53,15 @@ class PlatformFontGtk : public PlatformFont {
// Create a new instance of this object with the specified properties. Called
// from DeriveFont.
PlatformFontGtk(SkTypeface* typeface,
- const std::wstring& name,
+ const string16& name,
int size,
int style);
virtual ~PlatformFontGtk();
// Initialize this object.
- void InitWithNameAndSize(const std::wstring& font_name, int font_size);
+ void InitWithNameAndSize(const string16& font_name, int font_size);
void InitWithTypefaceNameSizeAndStyle(SkTypeface* typeface,
- const std::wstring& name,
+ const string16& name,
int size,
int style);
void InitFromPlatformFont(const PlatformFontGtk* other);
@@ -86,7 +86,7 @@ class PlatformFontGtk : public PlatformFont {
// Additional information about the face
// Skia actually expects a family name and not a font name.
- std::wstring font_family_;
+ string16 font_family_;
int font_size_;
int style_;
diff --git a/gfx/platform_font_mac.h b/gfx/platform_font_mac.h
index 11440ebb..62f44b6 100644
--- a/gfx/platform_font_mac.h
+++ b/gfx/platform_font_mac.h
@@ -15,7 +15,7 @@ class PlatformFontMac : public PlatformFont {
PlatformFontMac();
explicit PlatformFontMac(const Font& other);
explicit PlatformFontMac(NativeFont native_font);
- PlatformFontMac(const std::wstring& font_name,
+ PlatformFontMac(const string16& font_name,
int font_size);
// Overridden from PlatformFont:
@@ -26,23 +26,23 @@ class PlatformFontMac : public PlatformFont {
virtual int GetStringWidth(const string16& text) const;
virtual int GetExpectedTextWidth(int length) const;
virtual int GetStyle() const;
- virtual const std::wstring& GetFontName() const;
+ virtual string16 GetFontName() const;
virtual int GetFontSize() const;
virtual NativeFont GetNativeFont() const;
private:
- PlatformFontMac(const std::wstring& font_name, int font_size, int style);
+ PlatformFontMac(const string16& font_name, int font_size, int style);
virtual ~PlatformFontMac() {}
// Initialize the object with the specified parameters.
- void InitWithNameSizeAndStyle(const std::wstring& font_name,
+ void InitWithNameSizeAndStyle(const string16& font_name,
int font_size,
int style);
// Calculate and cache the font metrics.
void CalculateMetrics();
- std::wstring font_name_;
+ string16 font_name_;
int font_size_;
int style_;
diff --git a/gfx/platform_font_mac.mm b/gfx/platform_font_mac.mm
index 15d08f8..4aa9b88 100644
--- a/gfx/platform_font_mac.mm
+++ b/gfx/platform_font_mac.mm
@@ -22,7 +22,7 @@ PlatformFontMac::PlatformFontMac() {
font_size_ = [NSFont systemFontSize];
style_ = gfx::Font::NORMAL;
NSFont* system_font = [NSFont systemFontOfSize:font_size_];
- font_name_ = base::SysNSStringToWide([system_font fontName]);
+ font_name_ = base::SysNSStringToUTF16([system_font fontName]);
CalculateMetrics();
}
@@ -32,7 +32,7 @@ PlatformFontMac::PlatformFontMac(const Font& other) {
PlatformFontMac::PlatformFontMac(NativeFont native_font) {
}
-PlatformFontMac::PlatformFontMac(const std::wstring& font_name,
+PlatformFontMac::PlatformFontMac(const string16& font_name,
int font_size) {
InitWithNameSizeAndStyle(font_name, font_size, gfx::Font::NORMAL);
}
@@ -71,7 +71,7 @@ int PlatformFontMac::GetStyle() const {
return style_;
}
-const std::wstring& PlatformFontMac::GetFontName() const {
+string16 PlatformFontMac::GetFontName() const {
return font_name_;
}
@@ -83,20 +83,20 @@ NativeFont PlatformFontMac::GetNativeFont() const {
// TODO(pinkerton): apply |style_| to font. http://crbug.com/34667
// We could cache this, but then we'd have to conditionally change the
// dtor just for MacOS. Not sure if we want to/need to do that.
- return [NSFont fontWithName:base::SysWideToNSString(font_name_)
+ return [NSFont fontWithName:base::SysUTF16ToNSString(font_name_)
size:font_size_];
}
////////////////////////////////////////////////////////////////////////////////
// PlatformFontMac, private:
-PlatformFontMac::PlatformFontMac(const std::wstring& font_name,
+PlatformFontMac::PlatformFontMac(const string16& font_name,
int font_size,
int style) {
InitWithNameSizeAndStyle(font_name, font_size, style);
}
-void PlatformFontMac::InitWithNameSizeAndStyle(const std::wstring& font_name,
+void PlatformFontMac::InitWithNameSizeAndStyle(const string16& font_name,
int font_size,
int style) {
font_name_ = font_name;
@@ -134,7 +134,7 @@ PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) {
}
// static
-PlatformFont* PlatformFont::CreateFromNameAndSize(const std::wstring& font_name,
+PlatformFont* PlatformFont::CreateFromNameAndSize(const string16& font_name,
int font_size) {
return new PlatformFontMac(font_name, font_size);
}
diff --git a/gfx/platform_font_win.cc b/gfx/platform_font_win.cc
index 34761c6..8071640 100644
--- a/gfx/platform_font_win.cc
+++ b/gfx/platform_font_win.cc
@@ -69,7 +69,7 @@ PlatformFontWin::PlatformFontWin(NativeFont native_font) {
InitWithCopyOfHFONT(native_font);
}
-PlatformFontWin::PlatformFontWin(const std::wstring& font_name,
+PlatformFontWin::PlatformFontWin(const string16& font_name,
int font_size) {
InitWithFontNameAndSize(font_name, font_size);
}
@@ -117,7 +117,7 @@ int PlatformFontWin::GetStyle() const {
return font_ref_->style();
}
-const std::wstring& PlatformFontWin::GetFontName() const {
+string16 PlatformFontWin::GetFontName() const {
return font_ref_->font_name();
}
@@ -150,7 +150,7 @@ void PlatformFontWin::InitWithCopyOfHFONT(HFONT hfont) {
font_ref_ = CreateHFontRef(CreateFontIndirect(&font_info));
}
-void PlatformFontWin::InitWithFontNameAndSize(const std::wstring& font_name,
+void PlatformFontWin::InitWithFontNameAndSize(const string16& font_name,
int font_size) {
HDC hdc = GetDC(NULL);
long lf_height = -MulDiv(font_size, GetDeviceCaps(hdc, LOGPIXELSY), 72);
@@ -235,7 +235,7 @@ PlatformFontWin::HFontRef::HFontRef(HFONT hfont,
LOGFONT font_info;
GetObject(hfont_, sizeof(LOGFONT), &font_info);
- font_name_ = std::wstring(font_info.lfFaceName);
+ font_name_ = string16(font_info.lfFaceName);
}
PlatformFontWin::HFontRef::~HFontRef() {
@@ -261,7 +261,7 @@ PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) {
}
// static
-PlatformFont* PlatformFont::CreateFromNameAndSize(const std::wstring& font_name,
+PlatformFont* PlatformFont::CreateFromNameAndSize(const string16& font_name,
int font_size) {
return new PlatformFontWin(font_name, font_size);
}
diff --git a/gfx/platform_font_win.h b/gfx/platform_font_win.h
index 0c310db..4adaa38 100644
--- a/gfx/platform_font_win.h
+++ b/gfx/platform_font_win.h
@@ -16,7 +16,7 @@ class PlatformFontWin : public PlatformFont {
PlatformFontWin();
explicit PlatformFontWin(const Font& other);
explicit PlatformFontWin(NativeFont native_font);
- PlatformFontWin(const std::wstring& font_name,
+ PlatformFontWin(const string16& font_name,
int font_size);
// Dialog units to pixels conversion.
@@ -48,7 +48,7 @@ class PlatformFontWin : public PlatformFont {
virtual int GetStringWidth(const string16& text) const;
virtual int GetExpectedTextWidth(int length) const;
virtual int GetStyle() const;
- virtual const std::wstring& GetFontName() const;
+ virtual string16 GetFontName() const;
virtual int GetFontSize() const;
virtual NativeFont GetNativeFont() const;
@@ -81,7 +81,7 @@ class PlatformFontWin : public PlatformFont {
int ave_char_width() const { return ave_char_width_; }
int style() const { return style_; }
int dlu_base_x() const { return dlu_base_x_; }
- const std::wstring& font_name() const { return font_name_; }
+ const string16& font_name() const { return font_name_; }
private:
friend class base::RefCounted<HFontRef>;
@@ -95,7 +95,7 @@ class PlatformFontWin : public PlatformFont {
const int style_;
// Constants used in converting dialog units to pixels.
const int dlu_base_x_;
- std::wstring font_name_;
+ string16 font_name_;
DISALLOW_COPY_AND_ASSIGN(HFontRef);
};
@@ -104,7 +104,7 @@ class PlatformFontWin : public PlatformFont {
void InitWithCopyOfHFONT(HFONT hfont);
// Initializes this object with the specified font name and size.
- void InitWithFontNameAndSize(const std::wstring& font_name,
+ void InitWithFontNameAndSize(const string16& font_name,
int font_size);
// Returns the base font ref. This should ONLY be invoked on the