| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "gfx/platform_font_mac.h" | 5 #include "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/scoped_nsobject.h" | 10 #include "base/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 "gfx/canvas_skia.h" | 13 #include "gfx/canvas_skia.h" |
| 13 #include "gfx/font.h" | 14 #include "gfx/font.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 | 17 |
| 17 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
| 18 // PlatformFontMac, public: | 19 // PlatformFontMac, public: |
| 19 | 20 |
| 20 PlatformFontMac::PlatformFontMac() { | 21 PlatformFontMac::PlatformFontMac() { |
| 21 font_size_ = [NSFont systemFontSize]; | 22 font_size_ = [NSFont systemFontSize]; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 50 int PlatformFontMac::GetBaseline() const { | 51 int PlatformFontMac::GetBaseline() const { |
| 51 return ascent_; | 52 return ascent_; |
| 52 } | 53 } |
| 53 | 54 |
| 54 int PlatformFontMac::GetAverageCharacterWidth() const { | 55 int PlatformFontMac::GetAverageCharacterWidth() const { |
| 55 return average_width_; | 56 return average_width_; |
| 56 } | 57 } |
| 57 | 58 |
| 58 int PlatformFontMac::GetStringWidth(const std::wstring& text) const { | 59 int PlatformFontMac::GetStringWidth(const std::wstring& text) const { |
| 59 int width = 0, height = 0; | 60 int width = 0, height = 0; |
| 60 CanvasSkia::SizeStringInt(text, Font(const_cast<PlatformFontMac*>(this)), | 61 CanvasSkia::SizeStringInt(WideToUTF16Hack(text), |
| 62 Font(const_cast<PlatformFontMac*>(this)), |
| 61 &width, &height, gfx::Canvas::NO_ELLIPSIS); | 63 &width, &height, gfx::Canvas::NO_ELLIPSIS); |
| 62 return width; | 64 return width; |
| 63 } | 65 } |
| 64 | 66 |
| 65 int PlatformFontMac::GetExpectedTextWidth(int length) const { | 67 int PlatformFontMac::GetExpectedTextWidth(int length) const { |
| 66 return length * average_width_; | 68 return length * average_width_; |
| 67 } | 69 } |
| 68 | 70 |
| 69 int PlatformFontMac::GetStyle() const { | 71 int PlatformFontMac::GetStyle() const { |
| 70 return style_; | 72 return style_; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 135 } |
| 134 | 136 |
| 135 // static | 137 // static |
| 136 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::wstring& font_name, | 138 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::wstring& font_name, |
| 137 int font_size) { | 139 int font_size) { |
| 138 return new PlatformFontMac(font_name, font_size); | 140 return new PlatformFontMac(font_name, font_size); |
| 139 } | 141 } |
| 140 | 142 |
| 141 } // namespace gfx | 143 } // namespace gfx |
| 142 | 144 |
| OLD | NEW |