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

Side by Side Diff: gfx/platform_font_win.cc

Issue 5158006: Convert SizeStringInt from taking a wstring to a string16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac Created 10 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 | Annotate | Revision Log
« no previous file with comments | « gfx/platform_font_mac.mm ('k') | views/controls/button/text_button.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/platform_font_win.h" 5 #include "gfx/platform_font_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <math.h> 8 #include <math.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h"
14 #include "base/win_util.h" 15 #include "base/win_util.h"
15 #include "gfx/canvas_skia.h" 16 #include "gfx/canvas_skia.h"
16 #include "gfx/font.h" 17 #include "gfx/font.h"
17 18
18 namespace { 19 namespace {
19 20
20 // If the tmWeight field of a TEXTMETRIC structure has a value >= this, the 21 // If the tmWeight field of a TEXTMETRIC structure has a value >= this, the
21 // font is bold. 22 // font is bold.
22 const int kTextMetricWeightBold = 700; 23 const int kTextMetricWeightBold = 700;
23 24
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 int PlatformFontWin::GetBaseline() const { 97 int PlatformFontWin::GetBaseline() const {
97 return font_ref_->baseline(); 98 return font_ref_->baseline();
98 } 99 }
99 100
100 int PlatformFontWin::GetAverageCharacterWidth() const { 101 int PlatformFontWin::GetAverageCharacterWidth() const {
101 return font_ref_->ave_char_width(); 102 return font_ref_->ave_char_width();
102 } 103 }
103 104
104 int PlatformFontWin::GetStringWidth(const std::wstring& text) const { 105 int PlatformFontWin::GetStringWidth(const std::wstring& text) const {
105 int width = 0, height = 0; 106 int width = 0, height = 0;
106 CanvasSkia::SizeStringInt(text, Font(const_cast<PlatformFontWin*>(this)), 107 CanvasSkia::SizeStringInt(WideToUTF16Hack(text),
108 Font(const_cast<PlatformFontWin*>(this)),
107 &width, &height, gfx::Canvas::NO_ELLIPSIS); 109 &width, &height, gfx::Canvas::NO_ELLIPSIS);
108 return width; 110 return width;
109 } 111 }
110 112
111 int PlatformFontWin::GetExpectedTextWidth(int length) const { 113 int PlatformFontWin::GetExpectedTextWidth(int length) const {
112 return length * std::min(font_ref_->dlu_base_x(), GetAverageCharacterWidth()); 114 return length * std::min(font_ref_->dlu_base_x(), GetAverageCharacterWidth());
113 } 115 }
114 116
115 int PlatformFontWin::GetStyle() const { 117 int PlatformFontWin::GetStyle() const {
116 return font_ref_->style(); 118 return font_ref_->style();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 return new PlatformFontWin(native_font); 261 return new PlatformFontWin(native_font);
260 } 262 }
261 263
262 // static 264 // static
263 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::wstring& font_name, 265 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::wstring& font_name,
264 int font_size) { 266 int font_size) {
265 return new PlatformFontWin(font_name, font_size); 267 return new PlatformFontWin(font_name, font_size);
266 } 268 }
267 269
268 } // namespace gfx 270 } // namespace gfx
OLDNEW
« no previous file with comments | « gfx/platform_font_mac.mm ('k') | views/controls/button/text_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698