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

Side by Side Diff: gfx/font_mac.mm

Issue 2811032: Revert 50784 - Canvas refactoring part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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
« no previous file with comments | « gfx/canvas_skia_win.cc ('k') | gfx/font_skia.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "gfx/font.h" 5 #include "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/scoped_nsobject.h" 10 #include "base/scoped_nsobject.h"
11 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
12 #include "gfx/canvas_skia.h" 12 #include "gfx/canvas.h"
13 13
14 namespace gfx { 14 namespace gfx {
15 15
16 // static 16 // static
17 Font Font::CreateFont(const std::wstring& font_name, int font_size) { 17 Font Font::CreateFont(const std::wstring& font_name, int font_size) {
18 return Font(font_name, font_size, NORMAL); 18 return Font(font_name, font_size, NORMAL);
19 } 19 }
20 20
21 Font::Font(const std::wstring& font_name, int font_size, int style) 21 Font::Font(const std::wstring& font_name, int font_size, int style)
22 : font_name_(font_name), 22 : font_name_(font_name),
(...skipping 30 matching lines...) Expand all
53 int Font::baseline() const { 53 int Font::baseline() const {
54 return ascent_; 54 return ascent_;
55 } 55 }
56 56
57 int Font::ave_char_width() const { 57 int Font::ave_char_width() const {
58 return avg_width_; 58 return avg_width_;
59 } 59 }
60 60
61 int Font::GetStringWidth(const std::wstring& text) const { 61 int Font::GetStringWidth(const std::wstring& text) const {
62 int width = 0, height = 0; 62 int width = 0, height = 0;
63 CanvasSkia::SizeStringInt(text, *this, &width, &height, 63 Canvas::SizeStringInt(text, *this, &width, &height, gfx::Canvas::NO_ELLIPSIS);
64 gfx::Canvas::NO_ELLIPSIS);
65 return width; 64 return width;
66 } 65 }
67 66
68 int Font::GetExpectedTextWidth(int length) const { 67 int Font::GetExpectedTextWidth(int length) const {
69 return length * avg_width_; 68 return length * avg_width_;
70 } 69 }
71 70
72 int Font::style() const { 71 int Font::style() const {
73 return style_; 72 return style_;
74 } 73 }
75 74
76 const std::wstring& Font::FontName() const { 75 const std::wstring& Font::FontName() const {
77 return font_name_; 76 return font_name_;
78 } 77 }
79 78
80 int Font::FontSize() { 79 int Font::FontSize() {
81 return font_size_; 80 return font_size_;
82 } 81 }
83 82
84 NativeFont Font::nativeFont() const { 83 NativeFont Font::nativeFont() const {
85 // TODO(pinkerton): apply |style_| to font. http://crbug.com/34667 84 // TODO(pinkerton): apply |style_| to font. http://crbug.com/34667
86 // We could cache this, but then we'd have to conditionally change the 85 // We could cache this, but then we'd have to conditionally change the
87 // dtor just for MacOS. Not sure if we want to/need to do that. 86 // dtor just for MacOS. Not sure if we want to/need to do that.
88 return [NSFont fontWithName:base::SysWideToNSString(font_name_) 87 return [NSFont fontWithName:base::SysWideToNSString(font_name_)
89 size:font_size_]; 88 size:font_size_];
90 } 89 }
91 90
92 } // namespace gfx 91 } // namespace gfx
OLDNEW
« no previous file with comments | « gfx/canvas_skia_win.cc ('k') | gfx/font_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698