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

Side by Side Diff: ui/gfx/platform_font_mac.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 trybots 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_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/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "ui/gfx/canvas.h" 13 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/font.h" 14 #include "ui/gfx/font.h"
15 #include "ui/gfx/font_list.h"
15 16
16 namespace gfx { 17 namespace gfx {
17 18
18 //////////////////////////////////////////////////////////////////////////////// 19 ////////////////////////////////////////////////////////////////////////////////
19 // PlatformFontMac, public: 20 // PlatformFontMac, public:
20 21
21 PlatformFontMac::PlatformFontMac() { 22 PlatformFontMac::PlatformFontMac() {
22 font_size_ = [NSFont systemFontSize]; 23 font_size_ = [NSFont systemFontSize];
23 style_ = gfx::Font::NORMAL; 24 style_ = gfx::Font::NORMAL;
24 NSFont* system_font = [NSFont systemFontOfSize:font_size_]; 25 NSFont* system_font = [NSFont systemFontOfSize:font_size_];
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 66
66 int PlatformFontMac::GetAverageCharacterWidth() const { 67 int PlatformFontMac::GetAverageCharacterWidth() const {
67 return average_width_; 68 return average_width_;
68 } 69 }
69 70
70 int PlatformFontMac::GetStringWidth(const base::string16& text) const { 71 int PlatformFontMac::GetStringWidth(const base::string16& text) const {
71 return Canvas::GetStringWidth(text, 72 return Canvas::GetStringWidth(text,
72 Font(const_cast<PlatformFontMac*>(this))); 73 Font(const_cast<PlatformFontMac*>(this)));
73 } 74 }
74 75
76 float PlatformFontMac::GetStringWidthF(const base::string16& text) const {
77 return Canvas::GetStringWidthF(
78 text, FontList(Font(const_cast<PlatformFontMac*>(this))));
79 }
80
75 int PlatformFontMac::GetExpectedTextWidth(int length) const { 81 int PlatformFontMac::GetExpectedTextWidth(int length) const {
76 return length * average_width_; 82 return length * average_width_;
77 } 83 }
78 84
79 int PlatformFontMac::GetStyle() const { 85 int PlatformFontMac::GetStyle() const {
80 return style_; 86 return style_;
81 } 87 }
82 88
83 std::string PlatformFontMac::GetFontName() const { 89 std::string PlatformFontMac::GetFontName() const {
84 return font_name_; 90 return font_name_;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return new PlatformFontMac(native_font); 156 return new PlatformFontMac(native_font);
151 } 157 }
152 158
153 // static 159 // static
154 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 160 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
155 int font_size) { 161 int font_size) {
156 return new PlatformFontMac(font_name, font_size); 162 return new PlatformFontMac(font_name, font_size);
157 } 163 }
158 164
159 } // namespace gfx 165 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698