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_ios.h" | 5 #include "ui/gfx/platform_font_ios.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 | 49 |
50 int PlatformFontIOS::GetBaseline() const { | 50 int PlatformFontIOS::GetBaseline() const { |
51 return ascent_; | 51 return ascent_; |
52 } | 52 } |
53 | 53 |
54 int PlatformFontIOS::GetAverageCharacterWidth() const { | 54 int PlatformFontIOS::GetAverageCharacterWidth() const { |
55 return average_width_; | 55 return average_width_; |
56 } | 56 } |
57 | 57 |
58 int PlatformFontIOS::GetStringWidth(const string16& text) const { | 58 int PlatformFontIOS::GetStringWidth(const base::string16& text) const { |
59 NSString* ns_text = base::SysUTF16ToNSString(text); | 59 NSString* ns_text = base::SysUTF16ToNSString(text); |
60 return [ns_text sizeWithFont:GetNativeFont()].width; | 60 return [ns_text sizeWithFont:GetNativeFont()].width; |
61 } | 61 } |
62 | 62 |
63 int PlatformFontIOS::GetExpectedTextWidth(int length) const { | 63 int PlatformFontIOS::GetExpectedTextWidth(int length) const { |
64 return length * average_width_; | 64 return length * average_width_; |
65 } | 65 } |
66 | 66 |
67 int PlatformFontIOS::GetStyle() const { | 67 int PlatformFontIOS::GetStyle() const { |
68 return style_; | 68 return style_; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 return new PlatformFontIOS(native_font); | 119 return new PlatformFontIOS(native_font); |
120 } | 120 } |
121 | 121 |
122 // static | 122 // static |
123 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 123 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
124 int font_size) { | 124 int font_size) { |
125 return new PlatformFontIOS(font_name, font_size); | 125 return new PlatformFontIOS(font_name, font_size); |
126 } | 126 } |
127 | 127 |
128 } // namespace gfx | 128 } // namespace gfx |
OLD | NEW |