OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/platform_font_mac.h" | 5 #include "ui/gfx/platform_font_mac.h" |
6 | 6 |
7 #include <Cocoa/Cocoa.h> | 7 #include <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
14 #include "ui/gfx/font.h" | 14 #include "ui/gfx/font.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 | 17 |
18 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
19 // PlatformFontMac, public: | 19 // PlatformFontMac, public: |
20 | 20 |
21 PlatformFontMac::PlatformFontMac() { | 21 PlatformFontMac::PlatformFontMac() { |
22 font_size_ = [NSFont systemFontSize]; | 22 font_size_ = [NSFont systemFontSize]; |
23 style_ = gfx::Font::NORMAL; | 23 style_ = gfx::Font::NORMAL; |
24 NSFont* system_font = [NSFont systemFontOfSize:font_size_]; | 24 NSFont* system_font = [NSFont systemFontOfSize:font_size_]; |
25 font_name_ = base::SysNSStringToUTF8([system_font fontName]); | 25 font_name_ = base::SysNSStringToUTF8([system_font fontName]); |
26 CalculateMetrics(); | 26 CalculateMetrics(); |
27 } | 27 } |
28 | 28 |
29 PlatformFontMac::PlatformFontMac(const Font& other) { | |
30 } | |
31 | |
32 PlatformFontMac::PlatformFontMac(NativeFont native_font) { | 29 PlatformFontMac::PlatformFontMac(NativeFont native_font) { |
33 } | 30 } |
34 | 31 |
35 PlatformFontMac::PlatformFontMac(const std::string& font_name, | 32 PlatformFontMac::PlatformFontMac(const std::string& font_name, |
36 int font_size) { | 33 int font_size) { |
37 InitWithNameSizeAndStyle(font_name, font_size, gfx::Font::NORMAL); | 34 InitWithNameSizeAndStyle(font_name, font_size, gfx::Font::NORMAL); |
38 } | 35 } |
39 | 36 |
40 //////////////////////////////////////////////////////////////////////////////// | 37 //////////////////////////////////////////////////////////////////////////////// |
41 // PlatformFontMac, PlatformFont implementation: | 38 // PlatformFontMac, PlatformFont implementation: |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 112 |
116 //////////////////////////////////////////////////////////////////////////////// | 113 //////////////////////////////////////////////////////////////////////////////// |
117 // PlatformFont, public: | 114 // PlatformFont, public: |
118 | 115 |
119 // static | 116 // static |
120 PlatformFont* PlatformFont::CreateDefault() { | 117 PlatformFont* PlatformFont::CreateDefault() { |
121 return new PlatformFontMac; | 118 return new PlatformFontMac; |
122 } | 119 } |
123 | 120 |
124 // static | 121 // static |
125 PlatformFont* PlatformFont::CreateFromFont(const Font& other) { | |
126 return new PlatformFontMac(other); | |
127 } | |
128 | |
129 // static | |
130 PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) { | 122 PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) { |
131 return new PlatformFontMac(native_font); | 123 return new PlatformFontMac(native_font); |
132 } | 124 } |
133 | 125 |
134 // static | 126 // static |
135 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 127 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
136 int font_size) { | 128 int font_size) { |
137 return new PlatformFontMac(font_name, font_size); | 129 return new PlatformFontMac(font_name, font_size); |
138 } | 130 } |
139 | 131 |
140 } // namespace gfx | 132 } // namespace gfx |
141 | 133 |
OLD | NEW |