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

Side by Side Diff: app/gfx/font_mac.mm

Issue 344008: Implemented most of HtmlDialogWindowController, which is a Cocoa port (Closed)
Patch Set: Added TODOs. Created 11 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/cocoa/browser_command_executor.h » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/gfx/font.h" 5 #include "app/gfx/font.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 15 matching lines...) Expand all
26 Font::Font() 26 Font::Font()
27 : font_size_([NSFont systemFontSize]), 27 : font_size_([NSFont systemFontSize]),
28 style_(NORMAL) { 28 style_(NORMAL) {
29 NSFont* system_font = [NSFont systemFontOfSize:font_size_]; 29 NSFont* system_font = [NSFont systemFontOfSize:font_size_];
30 font_name_ = base::SysNSStringToWide([system_font fontName]); 30 font_name_ = base::SysNSStringToWide([system_font fontName]);
31 calculateMetrics(); 31 calculateMetrics();
32 } 32 }
33 33
34 void Font::calculateMetrics() { 34 void Font::calculateMetrics() {
35 NSFont* font = nativeFont(); 35 NSFont* font = nativeFont();
36 // TODO(akalin): This is the wrong height to use! Use either the height
37 // of the bounding rect for the font or ascender - descender; this needs
38 // further investigation. Width may be wrong, too.
36 height_ = [font xHeight]; 39 height_ = [font xHeight];
37 ascent_ = [font ascender]; 40 ascent_ = [font ascender];
38 avg_width_ = [font boundingRectForGlyph:[font glyphWithName:@"x"]].size.width; 41 avg_width_ = [font boundingRectForGlyph:[font glyphWithName:@"x"]].size.width;
39 } 42 }
40 43
41 Font Font::DeriveFont(int size_delta, int style) const { 44 Font Font::DeriveFont(int size_delta, int style) const {
42 return Font(font_name_, font_size_ + size_delta, style); 45 return Font(font_name_, font_size_ + size_delta, style);
43 } 46 }
44 47
45 int Font::height() const { 48 int Font::height() const {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 84
82 NativeFont Font::nativeFont() const { 85 NativeFont Font::nativeFont() const {
83 // TODO(pinkerton): apply |style_| to font. 86 // TODO(pinkerton): apply |style_| to font.
84 // We could cache this, but then we'd have to conditionally change the 87 // We could cache this, but then we'd have to conditionally change the
85 // dtor just for MacOS. Not sure if we want to/need to do that. 88 // dtor just for MacOS. Not sure if we want to/need to do that.
86 return [NSFont fontWithName:base::SysWideToNSString(font_name_) 89 return [NSFont fontWithName:base::SysWideToNSString(font_name_)
87 size:font_size_]; 90 size:font_size_];
88 } 91 }
89 92
90 } // namespace gfx 93 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/browser_command_executor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698