Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2097)

Unified Diff: app/gfx/chrome_font_mac.mm

Issue 113441: ChromeFont->gfx::Font... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/gfx/chrome_font_gtk.cc ('k') | app/gfx/chrome_font_skia.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/gfx/chrome_font_mac.mm
===================================================================
--- app/gfx/chrome_font_mac.mm (revision 16106)
+++ app/gfx/chrome_font_mac.mm (working copy)
@@ -9,20 +9,21 @@
#include "base/logging.h"
#include "base/sys_string_conversions.h"
+namespace gfx {
+
// static
-ChromeFont ChromeFont::CreateFont(const std::wstring& font_name,
- int font_size) {
- return ChromeFont(font_name, font_size, NORMAL);
+Font Font::CreateFont(const std::wstring& font_name, int font_size) {
+ return Font(font_name, font_size, NORMAL);
}
-ChromeFont::ChromeFont(const std::wstring& font_name, int font_size, int style)
+Font::Font(const std::wstring& font_name, int font_size, int style)
: font_name_(font_name),
font_size_(font_size),
style_(style) {
calculateMetrics();
}
-ChromeFont::ChromeFont()
+Font::Font()
: font_size_([NSFont systemFontSize]),
style_(NORMAL) {
NSFont* system_font = [NSFont systemFontOfSize:font_size_];
@@ -30,30 +31,30 @@
calculateMetrics();
}
-void ChromeFont::calculateMetrics() {
+void Font::calculateMetrics() {
NSFont* font = nativeFont();
height_ = [font xHeight];
ascent_ = [font ascender];
avg_width_ = [font boundingRectForGlyph:[font glyphWithName:@"x"]].size.width;
}
-ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
- return ChromeFont(font_name_, font_size_ + size_delta, style);
+Font Font::DeriveFont(int size_delta, int style) const {
+ return Font(font_name_, font_size_ + size_delta, style);
}
-int ChromeFont::height() const {
+int Font::height() const {
return height_;
}
-int ChromeFont::baseline() const {
+int Font::baseline() const {
return ascent_;
}
-int ChromeFont::ave_char_width() const {
+int Font::ave_char_width() const {
return avg_width_;
}
-int ChromeFont::GetStringWidth(const std::wstring& text) const {
+int Font::GetStringWidth(const std::wstring& text) const {
NSFont* font = nativeFont();
NSString* ns_string = base::SysWideToNSString(text);
NSDictionary* attributes =
@@ -62,26 +63,28 @@
return string_size.width;
}
-int ChromeFont::GetExpectedTextWidth(int length) const {
+int Font::GetExpectedTextWidth(int length) const {
return length * avg_width_;
}
-int ChromeFont::style() const {
+int Font::style() const {
return style_;
}
-std::wstring ChromeFont::FontName() {
+std::wstring Font::FontName() {
return font_name_;
}
-int ChromeFont::FontSize() {
+int Font::FontSize() {
return font_size_;
}
-NativeFont ChromeFont::nativeFont() const {
+NativeFont Font::nativeFont() const {
// TODO(pinkerton): apply |style_| to font.
// 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_)
size:font_size_];
}
+
+} // namespace gfx
« no previous file with comments | « app/gfx/chrome_font_gtk.cc ('k') | app/gfx/chrome_font_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698