| 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" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 CalculateMetrics(); | 100 CalculateMetrics(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void PlatformFontMac::CalculateMetrics() { | 103 void PlatformFontMac::CalculateMetrics() { |
| 104 NSFont* font = GetNativeFont(); | 104 NSFont* font = GetNativeFont(); |
| 105 scoped_nsobject<NSLayoutManager> layout_manager( | 105 scoped_nsobject<NSLayoutManager> layout_manager( |
| 106 [[NSLayoutManager alloc] init]); | 106 [[NSLayoutManager alloc] init]); |
| 107 height_ = [layout_manager defaultLineHeightForFont:font]; | 107 height_ = [layout_manager defaultLineHeightForFont:font]; |
| 108 ascent_ = [font ascender]; | 108 ascent_ = [font ascender]; |
| 109 average_width_ = | 109 average_width_ = |
| 110 [font boundingRectForGlyph:[font glyphWithName:@"x"]].size.width; | 110 NSWidth([font boundingRectForGlyph:[font glyphWithName:@"x"]]); |
| 111 } | 111 } |
| 112 | 112 |
| 113 //////////////////////////////////////////////////////////////////////////////// | 113 //////////////////////////////////////////////////////////////////////////////// |
| 114 // PlatformFont, public: | 114 // PlatformFont, public: |
| 115 | 115 |
| 116 // static | 116 // static |
| 117 PlatformFont* PlatformFont::CreateDefault() { | 117 PlatformFont* PlatformFont::CreateDefault() { |
| 118 return new PlatformFontMac; | 118 return new PlatformFontMac; |
| 119 } | 119 } |
| 120 | 120 |
| 121 // static | 121 // static |
| 122 PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) { | 122 PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) { |
| 123 return new PlatformFontMac(native_font); | 123 return new PlatformFontMac(native_font); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // static | 126 // static |
| 127 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 127 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
| 128 int font_size) { | 128 int font_size) { |
| 129 return new PlatformFontMac(font_name, font_size); | 129 return new PlatformFontMac(font_name, font_size); |
| 130 } | 130 } |
| 131 | 131 |
| 132 } // namespace gfx | 132 } // namespace gfx |
| 133 | 133 |
| OLD | NEW |