summaryrefslogtreecommitdiffstats
path: root/app/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'app/gfx')
-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
4 files changed, 11 insertions, 7 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() {