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

Side by Side Diff: ui/gfx/platform_font_ios.mm

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix round-down problems Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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::GetCapHeight() const { 54 int PlatformFontIOS::GetCapHeight() const {
55 return cap_height_; 55 return cap_height_;
56 } 56 }
57 57
58 int PlatformFontIOS::GetAverageCharacterWidth() const { 58 float PlatformFontIOS::GetAverageCharacterWidth() const {
59 return average_width_; 59 return average_width_;
60 } 60 }
61 61
62 int PlatformFontIOS::GetStringWidth(const base::string16& text) const { 62 float PlatformFontIOS::GetStringWidth(const base::string16& text) const {
63 NSString* ns_text = base::SysUTF16ToNSString(text); 63 NSString* ns_text = base::SysUTF16ToNSString(text);
64 return [ns_text sizeWithFont:GetNativeFont()].width; 64 return [ns_text sizeWithFont:GetNativeFont()].width;
65 } 65 }
66 66
67 int PlatformFontIOS::GetExpectedTextWidth(int length) const { 67 float PlatformFontIOS::GetExpectedTextWidth(int length) const {
68 return length * average_width_; 68 return length * average_width_;
69 } 69 }
70 70
71 int PlatformFontIOS::GetStyle() const { 71 int PlatformFontIOS::GetStyle() const {
72 return style_; 72 return style_;
73 } 73 }
74 74
75 std::string PlatformFontIOS::GetFontName() const { 75 std::string PlatformFontIOS::GetFontName() const {
76 return font_name_; 76 return font_name_;
77 } 77 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return new PlatformFontIOS(native_font); 124 return new PlatformFontIOS(native_font);
125 } 125 }
126 126
127 // static 127 // static
128 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 128 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
129 int font_size) { 129 int font_size) {
130 return new PlatformFontIOS(font_name, font_size); 130 return new PlatformFontIOS(font_name, font_size);
131 } 131 }
132 132
133 } // namespace gfx 133 } // namespace gfx
OLDNEW
« ui/gfx/canvas.h ('K') | « ui/gfx/platform_font_ios.h ('k') | ui/gfx/platform_font_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698