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

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

Issue 10545050: mac: Use NSWidth() and friends in a few more places. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 8 years, 6 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/memory/scoped_nsobject.h" 10 #include "base/memory/scoped_nsobject.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 CalculateMetrics(); 100 CalculateMetrics();
101 } 101 }
102 102
103 void PlatformFontMac::CalculateMetrics() { 103 void PlatformFontMac::CalculateMetrics() {
104 NSFont* font = GetNativeFont(); 104 NSFont* font = GetNativeFont();
105 scoped_nsobject<NSLayoutManager> layout_manager( 105 scoped_nsobject<NSLayoutManager> layout_manager(
106 [[NSLayoutManager alloc] init]); 106 [[NSLayoutManager alloc] init]);
107 height_ = [layout_manager defaultLineHeightForFont:font]; 107 height_ = [layout_manager defaultLineHeightForFont:font];
108 ascent_ = [font ascender]; 108 ascent_ = [font ascender];
109 average_width_ = 109 average_width_ =
110 [font boundingRectForGlyph:[font glyphWithName:@"x"]].size.width; 110 NSWidth([font boundingRectForGlyph:[font glyphWithName:@"x"]]);
111 } 111 }
112 112
113 //////////////////////////////////////////////////////////////////////////////// 113 ////////////////////////////////////////////////////////////////////////////////
114 // PlatformFont, public: 114 // PlatformFont, public:
115 115
116 // static 116 // static
117 PlatformFont* PlatformFont::CreateDefault() { 117 PlatformFont* PlatformFont::CreateDefault() {
118 return new PlatformFontMac; 118 return new PlatformFontMac;
119 } 119 }
120 120
121 // static 121 // static
122 PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) { 122 PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) {
123 return new PlatformFontMac(native_font); 123 return new PlatformFontMac(native_font);
124 } 124 }
125 125
126 // static 126 // static
127 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 127 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
128 int font_size) { 128 int font_size) {
129 return new PlatformFontMac(font_name, font_size); 129 return new PlatformFontMac(font_name, font_size);
130 } 130 }
131 131
132 } // namespace gfx 132 } // namespace gfx
133 133
OLDNEW
« no previous file with comments | « ui/base/cocoa/underlay_opengl_hosting_window.mm ('k') | webkit/tools/test_shell/webview_host_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698