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

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 win bots 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 int PlatformFontIOS::GetHeight() const { 46 int PlatformFontIOS::GetHeight() const {
47 return height_; 47 return height_;
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 float PlatformFontIOS::GetAverageCharacterWidth() const {
55 return average_width_; 55 return average_width_;
56 } 56 }
57 57
58 int PlatformFontIOS::GetStringWidth(const base::string16& text) const { 58 float 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 float 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_;
69 } 69 }
70 70
71 std::string PlatformFontIOS::GetFontName() const { 71 std::string PlatformFontIOS::GetFontName() const {
72 return font_name_; 72 return font_name_;
73 } 73 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698