summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 23:55:37 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 23:55:37 +0000
commit610ae5f3c2e8ee2bd7ecf4cbef5aaeb2ac0b1a68 (patch)
treee275e905152f02a814386ba779eb1c15e9e8dd99
parentc1e45f4712de9f686e39f947c8e49eb28f352bf7 (diff)
downloadchromium_src-610ae5f3c2e8ee2bd7ecf4cbef5aaeb2ac0b1a68.zip
chromium_src-610ae5f3c2e8ee2bd7ecf4cbef5aaeb2ac0b1a68.tar.gz
chromium_src-610ae5f3c2e8ee2bd7ecf4cbef5aaeb2ac0b1a68.tar.bz2
Change string16 to std::string in the gfx::Font() interface.
Most consumers on all platforms (including windows!) were converting the font family/GetFontName() result to UTF8. (Windows was still having to convert for the SkTypeface calls.) On Linux, we're performing a UTF16ToUTF8 on each string print (and this is showing up in pprof output.) BUG=100803 TEST=none Review URL: http://codereview.chromium.org/8392017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107659 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc4
-rw-r--r--chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.mm2
-rw-r--r--chrome/browser/ui/cocoa/download/download_item_cell.mm4
-rw-r--r--chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm4
-rw-r--r--chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm2
-rw-r--r--chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac_unittest.mm2
-rw-r--r--chrome/browser/ui/cocoa/status_bubble_mac.mm4
-rw-r--r--chrome/common/badge_util.cc2
-rw-r--r--printing/print_settings_initializer.cc2
-rw-r--r--ui/gfx/font.cc6
-rw-r--r--ui/gfx/font.h8
-rw-r--r--ui/gfx/font_unittest.cc20
-rw-r--r--ui/gfx/platform_font.h10
-rw-r--r--ui/gfx/platform_font_mac.h10
-rw-r--r--ui/gfx/platform_font_mac.mm14
-rw-r--r--ui/gfx/platform_font_pango.cc30
-rw-r--r--ui/gfx/platform_font_pango.h16
-rw-r--r--ui/gfx/platform_font_win.cc12
-rw-r--r--ui/gfx/platform_font_win.h10
-rw-r--r--ui/gfx/render_text_win.cc2
-rw-r--r--views/controls/label_unittest.cc4
21 files changed, 84 insertions, 84 deletions
diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc
index bb6a36a..7594723 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc
+++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc
@@ -133,7 +133,7 @@ void CloudPrintSetupFlow::GetWebUIMessageHandlers(
void CloudPrintSetupFlow::GetDialogSize(gfx::Size* size) const {
PrefService* prefs = profile_->GetPrefs();
gfx::Font approximate_web_font(
- UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
+ prefs->GetString(prefs::kWebKitSansSerifFontFamily),
prefs->GetInteger(prefs::kWebKitDefaultFontSize));
if (setup_done_) {
@@ -312,7 +312,7 @@ void CloudPrintSetupFlow::ShowSetupDone() {
if (web_ui_) {
PrefService* prefs = profile_->GetPrefs();
gfx::Font approximate_web_font(
- UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
+ prefs->GetString(prefs::kWebKitSansSerifFontFamily),
prefs->GetInteger(prefs::kWebKitDefaultFontSize));
gfx::Size done_size = ui::GetLocalizedContentsSizeForFont(
IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS,
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.mm
index dcfd18c..a854689 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.mm
@@ -28,7 +28,7 @@ const NSUInteger kMaximumMenuPixelsWide = 300;
+ (NSString*)menuTitleForNode:(const BookmarkNode*)node {
NSFont* nsfont = [NSFont menuBarFontOfSize:0]; // 0 means "default"
- gfx::Font font(base::SysNSStringToUTF16([nsfont fontName]),
+ gfx::Font font(base::SysNSStringToUTF8([nsfont fontName]),
static_cast<int>([nsfont pointSize]));
string16 title = ui::ElideText(node->GetTitle(),
font,
diff --git a/chrome/browser/ui/cocoa/download/download_item_cell.mm b/chrome/browser/ui/cocoa/download/download_item_cell.mm
index a7ffa34..793d805 100644
--- a/chrome/browser/ui/cocoa/download/download_item_cell.mm
+++ b/chrome/browser/ui/cocoa/download/download_item_cell.mm
@@ -336,7 +336,7 @@ const int kInterruptedAnimationDuration = 2.5;
- (NSString*)elideTitle:(int)availableWidth {
NSFont* font = [self font];
- gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]),
+ gfx::Font font_chr(base::SysNSStringToUTF8([font fontName]),
[font pointSize]);
return base::SysUTF16ToNSString(
@@ -345,7 +345,7 @@ const int kInterruptedAnimationDuration = 2.5;
- (NSString*)elideStatus:(int)availableWidth {
NSFont* font = [self secondaryFont];
- gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]),
+ gfx::Font font_chr(base::SysNSStringToUTF8([font fontName]),
[font pointSize]);
return base::SysUTF16ToNSString(ui::ElideText(
diff --git a/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm b/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm
index 661dd49..23e733f 100644
--- a/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -91,7 +91,7 @@ CGFloat EVBubbleDecoration::GetWidthForSpace(CGFloat width) {
// Middle-elide the label to fit |width_left|. This leaves the
// prefix and the trailing country code in place.
- gfx::Font font(base::SysNSStringToUTF16([font_ fontName]),
+ gfx::Font font(base::SysNSStringToUTF8([font_ fontName]),
[font_ pointSize]);
NSString* elided_label = base::SysUTF16ToNSString(
ui::ElideText(base::SysNSStringToUTF16(full_label_), font, width_left,
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
index 5335a34..a6da319 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
@@ -453,7 +453,7 @@ void OmniboxPopupViewMac::UpdatePopupAppearance() {
// The popup's font is a slightly smaller version of the field's.
NSFont* fieldFont = OmniboxViewMac::GetFieldFont();
const CGFloat resultFontSize = [fieldFont pointSize] + kEditFontAdjust;
- gfx::Font resultFont(base::SysNSStringToUTF16([fieldFont fontName]),
+ gfx::Font resultFont(base::SysNSStringToUTF8([fieldFont fontName]),
static_cast<int>(resultFontSize));
AutocompleteMatrix* matrix = GetAutocompleteMatrix();
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac_unittest.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac_unittest.mm
index 178acec..40c0cc6 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac_unittest.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac_unittest.mm
@@ -27,7 +27,7 @@ class OmniboxPopupViewMacTest : public PlatformTest {
color_ = [NSColor blackColor];
dimColor_ = [NSColor darkGrayColor];
font_ = gfx::Font(
- base::SysNSStringToUTF16([[NSFont userFontOfSize:12] fontName]), 12);
+ base::SysNSStringToUTF8([[NSFont userFontOfSize:12] fontName]), 12);
}
// Returns the length of the run starting at |location| for which
diff --git a/chrome/browser/ui/cocoa/status_bubble_mac.mm b/chrome/browser/ui/cocoa/status_bubble_mac.mm
index 73f2332..5bf6500 100644
--- a/chrome/browser/ui/cocoa/status_bubble_mac.mm
+++ b/chrome/browser/ui/cocoa/status_bubble_mac.mm
@@ -148,7 +148,7 @@ void StatusBubbleMac::SetURL(const GURL& url, const std::string& languages) {
scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil];
text_width = static_cast<int>(scaled_width.width);
NSFont* font = [[window_ contentView] font];
- gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]),
+ gfx::Font font_chr(base::SysNSStringToUTF8([font fontName]),
[font pointSize]);
string16 original_url_text = net::FormatUrl(url, languages);
@@ -609,7 +609,7 @@ void StatusBubbleMac::ExpandBubble() {
// Generate the URL string that fits in the expanded bubble.
NSFont* font = [[window_ contentView] font];
- gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]),
+ gfx::Font font_chr(base::SysNSStringToUTF8([font fontName]),
[font pointSize]);
string16 expanded_url = ui::ElideUrl(
url_, font_chr, max_bubble_width, languages_);
diff --git a/chrome/common/badge_util.cc b/chrome/common/badge_util.cc
index 3175de8..4531ff5 100644
--- a/chrome/common/badge_util.cc
+++ b/chrome/common/badge_util.cc
@@ -41,7 +41,7 @@ SkPaint* GetBadgeTextPaintSingleton() {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
typeface = SkTypeface::CreateFromName(
- UTF16ToUTF8(base_font.GetFontName()).c_str(), SkTypeface::kNormal);
+ base_font.GetFontName().c_str(), SkTypeface::kNormal);
DCHECK(typeface);
}
diff --git a/printing/print_settings_initializer.cc b/printing/print_settings_initializer.cc
index 7a0f0e3c..8d9065d 100644
--- a/printing/print_settings_initializer.cc
+++ b/printing/print_settings_initializer.cc
@@ -42,7 +42,7 @@ void PrintSettingsInitializer::InitHeaderFooterStrings(
}
gfx::Font font(
- UTF8ToUTF16(kSettingHeaderFooterFontName),
+ kSettingHeaderFooterFontName,
ceil(ConvertPointsToPixelDouble(kSettingHeaderFooterFontSize)));
double segment_width = GetHeaderFooterSegmentWidth(ConvertUnitDouble(
print_settings->page_setup_device_units().physical_size().width(),
diff --git a/ui/gfx/font.cc b/ui/gfx/font.cc
index 08b7b34..51e2ff4 100644
--- a/ui/gfx/font.cc
+++ b/ui/gfx/font.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -30,7 +30,7 @@ Font::Font(NativeFont native_font)
Font::Font(PlatformFont* platform_font) : platform_font_(platform_font) {
}
-Font::Font(const string16& font_name, int font_size)
+Font::Font(const std::string& 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();
}
-string16 Font::GetFontName() const {
+std::string Font::GetFontName() const {
return platform_font_->GetFontName();
}
diff --git a/ui/gfx/font.h b/ui/gfx/font.h
index cdb9542..8ded147 100644
--- a/ui/gfx/font.h
+++ b/ui/gfx/font.h
@@ -43,8 +43,8 @@ class UI_EXPORT Font {
// object takes ownership of the PlatformFont object.
explicit Font(PlatformFont* platform_font);
- // Creates a font with the specified name and size in pixels.
- Font(const string16& font_name, int font_size);
+ // Creates a font with the specified name in UTF-8 and size in pixels.
+ Font(const std::string& font_name, int font_size);
~Font();
@@ -85,8 +85,8 @@ class UI_EXPORT Font {
// Returns the style of the font.
int GetStyle() const;
- // Returns the font name.
- string16 GetFontName() const;
+ // Returns the font name in UTF-8.
+ std::string GetFontName() const;
// Returns the font size in pixels.
int GetFontSize() const;
diff --git a/ui/gfx/font_unittest.cc b/ui/gfx/font_unittest.cc
index 06e260e..d495213 100644
--- a/ui/gfx/font_unittest.cc
+++ b/ui/gfx/font_unittest.cc
@@ -57,17 +57,17 @@ int ScopedMinimumFontSizeCallback::minimum_size_ = 0;
TEST_F(FontTest, LoadArial) {
- Font cf(ASCIIToUTF16("Arial"), 16);
+ Font cf("Arial", 16);
gfx::NativeFont native = cf.GetNativeFont();
ASSERT_TRUE(native);
ASSERT_EQ(cf.GetStyle(), Font::NORMAL);
ASSERT_EQ(cf.GetFontSize(), 16);
- ASSERT_EQ(cf.GetFontName(), ASCIIToUTF16("Arial"));
+ ASSERT_EQ(cf.GetFontName(), "Arial");
FreeIfNecessary(native);
}
TEST_F(FontTest, LoadArialBold) {
- Font cf(ASCIIToUTF16("Arial"), 16);
+ Font cf("Arial", 16);
Font bold(cf.DeriveFont(0, Font::BOLD));
gfx::NativeFont native = bold.GetNativeFont();
ASSERT_TRUE(native);
@@ -76,20 +76,20 @@ TEST_F(FontTest, LoadArialBold) {
}
TEST_F(FontTest, Ascent) {
- Font cf(ASCIIToUTF16("Arial"), 16);
+ Font cf("Arial", 16);
ASSERT_GT(cf.GetBaseline(), 2);
ASSERT_LE(cf.GetBaseline(), 22);
}
TEST_F(FontTest, Height) {
- Font cf(ASCIIToUTF16("Arial"), 16);
+ Font cf("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(ASCIIToUTF16("Arial"), 16);
+ Font cf("Arial", 16);
ASSERT_EQ(cf.GetExpectedTextWidth(0), 0);
ASSERT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0));
ASSERT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1));
@@ -97,12 +97,12 @@ TEST_F(FontTest, AvgWidths) {
}
TEST_F(FontTest, AvgCharWidth) {
- Font cf(ASCIIToUTF16("Arial"), 16);
+ Font cf("Arial", 16);
ASSERT_GT(cf.GetAverageCharacterWidth(), 0);
}
TEST_F(FontTest, Widths) {
- Font cf(ASCIIToUTF16("Arial"), 16);
+ Font cf("Arial", 16);
ASSERT_EQ(cf.GetStringWidth(ASCIIToUTF16("")), 0);
ASSERT_GT(cf.GetStringWidth(ASCIIToUTF16("a")),
cf.GetStringWidth(ASCIIToUTF16("")));
@@ -114,7 +114,7 @@ TEST_F(FontTest, Widths) {
#if defined(OS_WIN)
TEST_F(FontTest, DeriveFontResizesIfSizeTooSmall) {
- Font cf(L"Arial", 8);
+ Font cf("Arial", 8);
// The minimum font size is set to 5 in browser_main.cc.
ScopedMinimumFontSizeCallback minimum_size(5);
@@ -123,7 +123,7 @@ TEST_F(FontTest, DeriveFontResizesIfSizeTooSmall) {
}
TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) {
- Font cf(L"Arial", 8);
+ Font cf("Arial", 8);
// The minimum font size is set to 5 in browser_main.cc.
ScopedMinimumFontSizeCallback minimum_size(5);
diff --git a/ui/gfx/platform_font.h b/ui/gfx/platform_font.h
index 7e316fe..bd4e0ae 100644
--- a/ui/gfx/platform_font.h
+++ b/ui/gfx/platform_font.h
@@ -23,9 +23,9 @@ class UI_EXPORT PlatformFont : public base::RefCounted<PlatformFont> {
static PlatformFont* CreateDefault();
static PlatformFont* CreateFromFont(const Font& other);
static PlatformFont* CreateFromNativeFont(NativeFont native_font);
- // Creates a PlatformFont implementation with the specified |font_name| and
- // |font_size| in pixels.
- static PlatformFont* CreateFromNameAndSize(const string16& font_name,
+ // Creates a PlatformFont implementation with the specified |font_name|
+ // (encoded in UTF-8) and |font_size| in pixels.
+ static PlatformFont* CreateFromNameAndSize(const std::string& font_name,
int font_size);
// Returns a new Font derived from the existing font.
@@ -59,8 +59,8 @@ class UI_EXPORT PlatformFont : public base::RefCounted<PlatformFont> {
// Returns the style of the font.
virtual int GetStyle() const = 0;
- // Returns the font name.
- virtual string16 GetFontName() const = 0;
+ // Returns the font name in UTF-8.
+ virtual std::string GetFontName() const = 0;
// Returns the font size in pixels.
virtual int GetFontSize() const = 0;
diff --git a/ui/gfx/platform_font_mac.h b/ui/gfx/platform_font_mac.h
index 6196137..64ae669 100644
--- a/ui/gfx/platform_font_mac.h
+++ b/ui/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 string16& font_name,
+ PlatformFontMac(const std::string& 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 string16 GetFontName() const;
+ virtual std::string GetFontName() const;
virtual int GetFontSize() const;
virtual NativeFont GetNativeFont() const;
private:
- PlatformFontMac(const string16& font_name, int font_size, int style);
+ PlatformFontMac(const std::string& font_name, int font_size, int style);
virtual ~PlatformFontMac() {}
// Initialize the object with the specified parameters.
- void InitWithNameSizeAndStyle(const string16& font_name,
+ void InitWithNameSizeAndStyle(const std::string& font_name,
int font_size,
int style);
// Calculate and cache the font metrics.
void CalculateMetrics();
- string16 font_name_;
+ std::string font_name_;
int font_size_;
int style_;
diff --git a/ui/gfx/platform_font_mac.mm b/ui/gfx/platform_font_mac.mm
index 48bb4c8..ee12a33 100644
--- a/ui/gfx/platform_font_mac.mm
+++ b/ui/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::SysNSStringToUTF16([system_font fontName]);
+ font_name_ = base::SysNSStringToUTF8([system_font fontName]);
CalculateMetrics();
}
@@ -32,7 +32,7 @@ PlatformFontMac::PlatformFontMac(const Font& other) {
PlatformFontMac::PlatformFontMac(NativeFont native_font) {
}
-PlatformFontMac::PlatformFontMac(const string16& font_name,
+PlatformFontMac::PlatformFontMac(const std::string& font_name,
int font_size) {
InitWithNameSizeAndStyle(font_name, font_size, gfx::Font::NORMAL);
}
@@ -71,7 +71,7 @@ int PlatformFontMac::GetStyle() const {
return style_;
}
-string16 PlatformFontMac::GetFontName() const {
+std::string 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::SysUTF16ToNSString(font_name_)
+ return [NSFont fontWithName:base::SysUTF8ToNSString(font_name_)
size:font_size_];
}
////////////////////////////////////////////////////////////////////////////////
// PlatformFontMac, private:
-PlatformFontMac::PlatformFontMac(const string16& font_name,
+PlatformFontMac::PlatformFontMac(const std::string& font_name,
int font_size,
int style) {
InitWithNameSizeAndStyle(font_name, font_size, style);
}
-void PlatformFontMac::InitWithNameSizeAndStyle(const string16& font_name,
+void PlatformFontMac::InitWithNameSizeAndStyle(const std::string& 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 string16& font_name,
+PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
int font_size) {
return new PlatformFontMac(font_name, font_size);
}
diff --git a/ui/gfx/platform_font_pango.cc b/ui/gfx/platform_font_pango.cc
index f2a2d63..999fd77 100644
--- a/ui/gfx/platform_font_pango.cc
+++ b/ui/gfx/platform_font_pango.cc
@@ -91,7 +91,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.
-string16 FindBestMatchFontFamilyName(const char* family_name) {
+std::string FindBestMatchFontFamilyName(const char* family_name) {
FcPattern* pattern = FcPatternCreate();
FcValue fcvalue;
fcvalue.type = FcTypeString;
@@ -106,7 +106,7 @@ string16 FindBestMatchFontFamilyName(const char* family_name) {
FcChar8* match_family;
FcPatternGetString(match, FC_FAMILY, 0, &match_family);
- string16 font_family = UTF8ToUTF16(reinterpret_cast<char*>(match_family));
+ std::string font_family(reinterpret_cast<char*>(match_family));
FcPatternDestroy(match);
FcPatternDestroy(pattern);
free(family_name_copy);
@@ -180,7 +180,7 @@ PlatformFontPango::PlatformFontPango(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.
- string16 font_family = FindBestMatchFontFamilyName(family_name);
+ std::string font_family = FindBestMatchFontFamilyName(family_name);
InitWithNameAndSize(font_family, size_in_pixels);
int style = 0;
@@ -197,7 +197,7 @@ PlatformFontPango::PlatformFontPango(NativeFont native_font) {
style_ = style;
}
-PlatformFontPango::PlatformFontPango(const string16& font_name,
+PlatformFontPango::PlatformFontPango(const std::string& font_name,
int font_size) {
InitWithNameAndSize(font_name, font_size);
}
@@ -242,7 +242,7 @@ Font PlatformFontPango::DeriveFont(int size_delta, int style) const {
skstyle |= SkTypeface::kItalic;
SkTypeface* typeface = SkTypeface::CreateFromName(
- UTF16ToUTF8(font_family_).c_str(),
+ font_family_.c_str(),
static_cast<SkTypeface::Style>(skstyle));
SkAutoUnref tf_helper(typeface);
@@ -281,7 +281,7 @@ int PlatformFontPango::GetStyle() const {
return style_;
}
-string16 PlatformFontPango::GetFontName() const {
+std::string PlatformFontPango::GetFontName() const {
return font_family_;
}
@@ -291,7 +291,7 @@ int PlatformFontPango::GetFontSize() const {
NativeFont PlatformFontPango::GetNativeFont() const {
PangoFontDescription* pfd = pango_font_description_new();
- pango_font_description_set_family(pfd, UTF16ToUTF8(GetFontName()).c_str());
+ pango_font_description_set_family(pfd, GetFontName().c_str());
// Set the absolute size to avoid overflowing UI elements.
// pango_font_description_set_absolute_size() takes a size in Pango units.
// There are PANGO_SCALE Pango units in one device unit. Screen output
@@ -322,7 +322,7 @@ NativeFont PlatformFontPango::GetNativeFont() const {
// PlatformFontPango, private:
PlatformFontPango::PlatformFontPango(SkTypeface* typeface,
- const string16& name,
+ const std::string& name,
int size,
int style) {
InitWithTypefaceNameSizeAndStyle(typeface, name, size, style);
@@ -330,22 +330,22 @@ PlatformFontPango::PlatformFontPango(SkTypeface* typeface,
PlatformFontPango::~PlatformFontPango() {}
-void PlatformFontPango::InitWithNameAndSize(const string16& font_name,
+void PlatformFontPango::InitWithNameAndSize(const std::string& font_name,
int font_size) {
DCHECK_GT(font_size, 0);
- string16 fallback;
+ std::string fallback;
SkTypeface* typeface = SkTypeface::CreateFromName(
- UTF16ToUTF8(font_name).c_str(), SkTypeface::kNormal);
+ 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: "
- << UTF16ToUTF8(font_name)
+ << font_name
<< ", " << kFallbackFontFamilyName;
- fallback = UTF8ToUTF16(kFallbackFontFamilyName);
+ fallback = kFallbackFontFamilyName;
}
SkAutoUnref typeface_helper(typeface);
@@ -357,7 +357,7 @@ void PlatformFontPango::InitWithNameAndSize(const string16& font_name,
void PlatformFontPango::InitWithTypefaceNameSizeAndStyle(
SkTypeface* typeface,
- const string16& font_family,
+ const std::string& font_family,
int font_size,
int style) {
typeface_helper_.reset(new SkAutoUnref(typeface));
@@ -464,7 +464,7 @@ PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) {
}
// static
-PlatformFont* PlatformFont::CreateFromNameAndSize(const string16& font_name,
+PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
int font_size) {
return new PlatformFontPango(font_name, font_size);
}
diff --git a/ui/gfx/platform_font_pango.h b/ui/gfx/platform_font_pango.h
index eedfad0..2e4ccdd 100644
--- a/ui/gfx/platform_font_pango.h
+++ b/ui/gfx/platform_font_pango.h
@@ -20,7 +20,7 @@ class UI_EXPORT PlatformFontPango : public PlatformFont {
PlatformFontPango();
explicit PlatformFontPango(const Font& other);
explicit PlatformFontPango(NativeFont native_font);
- PlatformFontPango(const string16& font_name, int font_size);
+ PlatformFontPango(const std::string& font_name, int font_size);
// Converts |gfx_font| to a new pango font. Free the returned font with
// pango_font_description_free().
@@ -46,7 +46,7 @@ class UI_EXPORT PlatformFontPango : public PlatformFont {
virtual int GetStringWidth(const string16& text) const;
virtual int GetExpectedTextWidth(int length) const;
virtual int GetStyle() const;
- virtual string16 GetFontName() const;
+ virtual std::string GetFontName() const;
virtual int GetFontSize() const;
virtual NativeFont GetNativeFont() const;
@@ -54,15 +54,15 @@ class UI_EXPORT PlatformFontPango : public PlatformFont {
// Create a new instance of this object with the specified properties. Called
// from DeriveFont.
PlatformFontPango(SkTypeface* typeface,
- const string16& name,
- int size,
- int style);
+ const std::string& name,
+ int size,
+ int style);
virtual ~PlatformFontPango();
// Initialize this object.
- void InitWithNameAndSize(const string16& font_name, int font_size);
+ void InitWithNameAndSize(const std::string& font_name, int font_size);
void InitWithTypefaceNameSizeAndStyle(SkTypeface* typeface,
- const string16& name,
+ const std::string& name,
int size,
int style);
void InitFromPlatformFont(const PlatformFontPango* other);
@@ -87,7 +87,7 @@ class UI_EXPORT PlatformFontPango : public PlatformFont {
// Additional information about the face
// Skia actually expects a family name and not a font name.
- string16 font_family_;
+ std::string font_family_;
int font_size_pixels_;
int style_;
diff --git a/ui/gfx/platform_font_win.cc b/ui/gfx/platform_font_win.cc
index e8fb93d..04375aa 100644
--- a/ui/gfx/platform_font_win.cc
+++ b/ui/gfx/platform_font_win.cc
@@ -69,7 +69,7 @@ PlatformFontWin::PlatformFontWin(NativeFont native_font) {
InitWithCopyOfHFONT(native_font);
}
-PlatformFontWin::PlatformFontWin(const string16& font_name,
+PlatformFontWin::PlatformFontWin(const std::string& font_name,
int font_size) {
InitWithFontNameAndSize(font_name, font_size);
}
@@ -117,7 +117,7 @@ int PlatformFontWin::GetStyle() const {
return font_ref_->style();
}
-string16 PlatformFontWin::GetFontName() const {
+std::string PlatformFontWin::GetFontName() const {
return font_ref_->font_name();
}
@@ -142,10 +142,10 @@ void PlatformFontWin::InitWithCopyOfHFONT(HFONT hfont) {
font_ref_ = CreateHFontRef(CreateFontIndirect(&font_info));
}
-void PlatformFontWin::InitWithFontNameAndSize(const string16& font_name,
+void PlatformFontWin::InitWithFontNameAndSize(const std::string& font_name,
int font_size) {
HFONT hf = ::CreateFont(-font_size, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- font_name.c_str());
+ UTF8ToUTF16(font_name).c_str());
font_ref_ = CreateHFontRef(hf);
}
@@ -224,7 +224,7 @@ PlatformFontWin::HFontRef::HFontRef(HFONT hfont,
LOGFONT font_info;
GetObject(hfont_, sizeof(LOGFONT), &font_info);
- font_name_ = string16(font_info.lfFaceName);
+ font_name_ = UTF16ToUTF8(string16(font_info.lfFaceName));
}
PlatformFontWin::HFontRef::~HFontRef() {
@@ -250,7 +250,7 @@ PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) {
}
// static
-PlatformFont* PlatformFont::CreateFromNameAndSize(const string16& font_name,
+PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
int font_size) {
return new PlatformFontWin(font_name, font_size);
}
diff --git a/ui/gfx/platform_font_win.h b/ui/gfx/platform_font_win.h
index 56f3340..c56ff93 100644
--- a/ui/gfx/platform_font_win.h
+++ b/ui/gfx/platform_font_win.h
@@ -17,7 +17,7 @@ class UI_EXPORT PlatformFontWin : public PlatformFont {
PlatformFontWin();
explicit PlatformFontWin(const Font& other);
explicit PlatformFontWin(NativeFont native_font);
- PlatformFontWin(const string16& font_name, int font_size);
+ PlatformFontWin(const std::string& font_name, int font_size);
// Dialog units to pixels conversion.
// See http://support.microsoft.com/kb/145994 for details.
@@ -48,7 +48,7 @@ class UI_EXPORT PlatformFontWin : public PlatformFont {
virtual int GetStringWidth(const string16& text) const;
virtual int GetExpectedTextWidth(int length) const;
virtual int GetStyle() const;
- virtual string16 GetFontName() const;
+ virtual std::string GetFontName() const;
virtual int GetFontSize() const;
virtual NativeFont GetNativeFont() const;
@@ -81,7 +81,7 @@ class UI_EXPORT 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 string16& font_name() const { return font_name_; }
+ const std::string& font_name() const { return font_name_; }
private:
friend class base::RefCounted<HFontRef>;
@@ -95,7 +95,7 @@ class UI_EXPORT PlatformFontWin : public PlatformFont {
const int style_;
// Constants used in converting dialog units to pixels.
const int dlu_base_x_;
- string16 font_name_;
+ std::string font_name_;
DISALLOW_COPY_AND_ASSIGN(HFontRef);
};
@@ -104,7 +104,7 @@ class UI_EXPORT PlatformFontWin : public PlatformFont {
void InitWithCopyOfHFONT(HFONT hfont);
// Initializes this object with the specified font name and size.
- void InitWithFontNameAndSize(const string16& font_name,
+ void InitWithFontNameAndSize(const std::string& font_name,
int font_size);
// Returns the base font ref. This should ONLY be invoked on the
diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc
index 6ae45d9..561bb6d 100644
--- a/ui/gfx/render_text_win.cc
+++ b/ui/gfx/render_text_win.cc
@@ -610,7 +610,7 @@ void RenderTextWin::DrawVisualText(Canvas* canvas) {
internal::TextRun* run = runs_[visual_to_logical_[i]];
// TODO(msw): Font default/fallback and style integration.
- std::string font(UTF16ToASCII(run->font.GetFontName()));
+ std::string font(run->font.GetFontName());
SkTypeface::Style style = SkTypeface::kNormal;
SkTypeface* typeface = SkTypeface::CreateFromName(font.c_str(), style);
if (typeface) {
diff --git a/views/controls/label_unittest.cc b/views/controls/label_unittest.cc
index 9a86fc8..cbb769a 100644
--- a/views/controls/label_unittest.cc
+++ b/views/controls/label_unittest.cc
@@ -20,7 +20,7 @@ const int kMinTextDimension = 4;
// Courier is failing on linux because it's non scalable.
TEST(LabelTest, FontPropertyCourier) {
Label label;
- string16 font_name(ASCIIToUTF16("courier"));
+ std::string font_name("courier");
gfx::Font font(font_name, 30);
label.SetFont(font);
gfx::Font font_used = label.font();
@@ -31,7 +31,7 @@ TEST(LabelTest, FontPropertyCourier) {
TEST(LabelTest, FontPropertyArial) {
Label label;
- string16 font_name(ASCIIToUTF16("arial"));
+ std::string font_name("arial");
gfx::Font font(font_name, 30);
label.SetFont(font);
gfx::Font font_used = label.font();