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

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

Issue 445363006: MacViews: Fix vertical alignment of text rendering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // an actual font. Don't waste time working out metrics. 159 // an actual font. Don't waste time working out metrics.
160 height_ = 0; 160 height_ = 0;
161 ascent_ = 0; 161 ascent_ = 0;
162 cap_height_ = 0; 162 cap_height_ = 0;
163 average_width_ = 0; 163 average_width_ = 0;
164 return; 164 return;
165 } 165 }
166 166
167 base::scoped_nsobject<NSLayoutManager> layout_manager( 167 base::scoped_nsobject<NSLayoutManager> layout_manager(
168 [[NSLayoutManager alloc] init]); 168 [[NSLayoutManager alloc] init]);
169 height_ = [layout_manager defaultLineHeightForFont:font]; 169 height_ = SkScalarCeilToInt([layout_manager defaultLineHeightForFont:font]);
170 ascent_ = [font ascender]; 170 ascent_ = SkScalarCeilToInt([font ascender]);
171 cap_height_ = [font capHeight]; 171 cap_height_ = SkScalarCeilToInt([font capHeight]);
172 average_width_ = 172 average_width_ =
173 NSWidth([font boundingRectForGlyph:[font glyphWithName:@"x"]]); 173 NSWidth([font boundingRectForGlyph:[font glyphWithName:@"x"]]);
174 } 174 }
175 175
176 //////////////////////////////////////////////////////////////////////////////// 176 ////////////////////////////////////////////////////////////////////////////////
177 // PlatformFont, public: 177 // PlatformFont, public:
178 178
179 // static 179 // static
180 PlatformFont* PlatformFont::CreateDefault() { 180 PlatformFont* PlatformFont::CreateDefault() {
181 return new PlatformFontMac; 181 return new PlatformFontMac;
182 } 182 }
183 183
184 // static 184 // static
185 PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) { 185 PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) {
186 return new PlatformFontMac(native_font); 186 return new PlatformFontMac(native_font);
187 } 187 }
188 188
189 // static 189 // static
190 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 190 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
191 int font_size) { 191 int font_size) {
192 return new PlatformFontMac(font_name, font_size); 192 return new PlatformFontMac(font_name, font_size);
193 } 193 }
194 194
195 } // namespace gfx 195 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698