summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-30 20:55:55 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-30 20:55:55 +0000
commit0d3c28e8983a614e5858d4b84a6cfe479adb1312 (patch)
treedefa6adae65173bd27bee5503425274dd4d7809d /app
parentdb32931f6800e91b0d6fa5ddf7c21d4b39d98c3f (diff)
downloadchromium_src-0d3c28e8983a614e5858d4b84a6cfe479adb1312.zip
chromium_src-0d3c28e8983a614e5858d4b84a6cfe479adb1312.tar.gz
chromium_src-0d3c28e8983a614e5858d4b84a6cfe479adb1312.tar.bz2
Fix up extension badge text drawing.
Fall abck to the system default font if the preferred font isn't available. Also, only create the SkPaint struct once, not on every paint. Also, make some more things const. BUG=25693 TEST=badge still looks good, that crash goes away Review URL: http://codereview.chromium.org/341045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r--app/gfx/font.h4
-rw-r--r--app/gfx/font_mac.mm2
-rwxr-xr-xapp/gfx/font_skia.cc2
-rw-r--r--app/gfx/font_win.cc10
-rw-r--r--app/resource_bundle.cc2
-rw-r--r--app/resource_bundle.h2
6 files changed, 13 insertions, 9 deletions
diff --git a/app/gfx/font.h b/app/gfx/font.h
index 4bea194..ccc1a64 100644
--- a/app/gfx/font.h
+++ b/app/gfx/font.h
@@ -97,7 +97,7 @@ class Font {
// Font Name.
// It is actually a font family name, because Skia expects a family name
// and not a font name.
- std::wstring FontName();
+ const std::wstring& FontName() const;
// Font Size.
int FontSize();
@@ -175,6 +175,7 @@ class Font {
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_; }
private:
const HFONT hfont_;
@@ -184,6 +185,7 @@ class Font {
const int style_;
// Constants used in converting dialog units to pixels.
const int dlu_base_x_;
+ std::wstring font_name_;
DISALLOW_COPY_AND_ASSIGN(HFontRef);
};
diff --git a/app/gfx/font_mac.mm b/app/gfx/font_mac.mm
index 4d0a48e..56cc6bc 100644
--- a/app/gfx/font_mac.mm
+++ b/app/gfx/font_mac.mm
@@ -74,7 +74,7 @@ int Font::style() const {
return style_;
}
-std::wstring Font::FontName() {
+const std::wstring& Font::FontName() const {
return font_name_;
}
diff --git a/app/gfx/font_skia.cc b/app/gfx/font_skia.cc
index a283306..8cf0280 100755
--- a/app/gfx/font_skia.cc
+++ b/app/gfx/font_skia.cc
@@ -261,7 +261,7 @@ int Font::style() const {
return style_;
}
-std::wstring Font::FontName() {
+const std::wstring& Font::FontName() const {
return font_family_;
}
diff --git a/app/gfx/font_win.cc b/app/gfx/font_win.cc
index 5e22efe..1f69afa 100644
--- a/app/gfx/font_win.cc
+++ b/app/gfx/font_win.cc
@@ -111,10 +111,8 @@ Font::HFontRef* Font::GetBaseFontRef() {
return base_font_ref_;
}
-std::wstring Font::FontName() {
- LOGFONT font_info;
- GetObject(hfont(), sizeof(LOGFONT), &font_info);
- return (std::wstring(font_info.lfFaceName));
+const std::wstring& Font::FontName() const {
+ return font_ref_->font_name();
}
int Font::FontSize() {
@@ -145,6 +143,10 @@ Font::HFontRef::HFontRef(HFONT hfont,
style_(style),
dlu_base_x_(dlu_base_x) {
DLOG_ASSERT(hfont);
+
+ LOGFONT font_info;
+ GetObject(hfont_, sizeof(LOGFONT), &font_info);
+ font_name_ = std::wstring(font_info.lfFaceName);
}
Font::HFontRef::~HFontRef() {
diff --git a/app/resource_bundle.cc b/app/resource_bundle.cc
index 28674a8..a2ebdf0 100644
--- a/app/resource_bundle.cc
+++ b/app/resource_bundle.cc
@@ -176,7 +176,7 @@ void ResourceBundle::LoadFontsIfNecessary() {
}
}
-gfx::Font ResourceBundle::GetFont(FontStyle style) {
+const gfx::Font& ResourceBundle::GetFont(FontStyle style) {
LoadFontsIfNecessary();
switch (style) {
case SmallFont:
diff --git a/app/resource_bundle.h b/app/resource_bundle.h
index f2fdb58..a59cbfd 100644
--- a/app/resource_bundle.h
+++ b/app/resource_bundle.h
@@ -113,7 +113,7 @@ class ResourceBundle {
string16 GetLocalizedString(int message_id);
// Returns the font for the specified style.
- gfx::Font GetFont(FontStyle style);
+ const gfx::Font& GetFont(FontStyle style);
#if defined(OS_WIN)
// Loads and returns an icon from the theme dll.