0

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
This commit is contained in:
erg@chromium.org
2011-10-27 23:55:37 +00:00
parent c1e45f4712
commit 610ae5f3c2
21 changed files with 84 additions and 84 deletions

@ -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,

@ -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,

@ -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(

@ -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,

@ -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();

@ -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

@ -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_);

@ -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);
}

@ -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(),

@ -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();
}

@ -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;

@ -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);

@ -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;

@ -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_;

@ -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);
}

@ -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);
}

@ -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_;

@ -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);
}

@ -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

@ -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) {

@ -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();