OLD | NEW |
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_win.h" | 5 #include "ui/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> |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 | 139 |
140 int PlatformFontWin::GetBaseline() const { | 140 int PlatformFontWin::GetBaseline() const { |
141 return font_ref_->baseline(); | 141 return font_ref_->baseline(); |
142 } | 142 } |
143 | 143 |
144 int PlatformFontWin::GetAverageCharacterWidth() const { | 144 int PlatformFontWin::GetAverageCharacterWidth() const { |
145 return font_ref_->ave_char_width(); | 145 return font_ref_->ave_char_width(); |
146 } | 146 } |
147 | 147 |
148 int PlatformFontWin::GetStringWidth(const string16& text) const { | 148 int PlatformFontWin::GetStringWidth(const base::string16& text) const { |
149 return Canvas::GetStringWidth(text, | 149 return Canvas::GetStringWidth(text, |
150 Font(const_cast<PlatformFontWin*>(this))); | 150 Font(const_cast<PlatformFontWin*>(this))); |
151 } | 151 } |
152 | 152 |
153 int PlatformFontWin::GetExpectedTextWidth(int length) const { | 153 int PlatformFontWin::GetExpectedTextWidth(int length) const { |
154 return length * std::min(font_ref_->GetDluBaseX(), | 154 return length * std::min(font_ref_->GetDluBaseX(), |
155 GetAverageCharacterWidth()); | 155 GetAverageCharacterWidth()); |
156 } | 156 } |
157 | 157 |
158 int PlatformFontWin::GetStyle() const { | 158 int PlatformFontWin::GetStyle() const { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 height_(height), | 266 height_(height), |
267 baseline_(baseline), | 267 baseline_(baseline), |
268 ave_char_width_(ave_char_width), | 268 ave_char_width_(ave_char_width), |
269 style_(style), | 269 style_(style), |
270 dlu_base_x_(-1), | 270 dlu_base_x_(-1), |
271 requested_font_size_(font_size) { | 271 requested_font_size_(font_size) { |
272 DLOG_ASSERT(hfont); | 272 DLOG_ASSERT(hfont); |
273 | 273 |
274 LOGFONT font_info; | 274 LOGFONT font_info; |
275 GetObject(hfont_, sizeof(LOGFONT), &font_info); | 275 GetObject(hfont_, sizeof(LOGFONT), &font_info); |
276 font_name_ = UTF16ToUTF8(string16(font_info.lfFaceName)); | 276 font_name_ = UTF16ToUTF8(base::string16(font_info.lfFaceName)); |
277 if (font_info.lfHeight < 0) | 277 if (font_info.lfHeight < 0) |
278 requested_font_size_ = -font_info.lfHeight; | 278 requested_font_size_ = -font_info.lfHeight; |
279 } | 279 } |
280 | 280 |
281 int PlatformFontWin::HFontRef::GetDluBaseX() { | 281 int PlatformFontWin::HFontRef::GetDluBaseX() { |
282 if (dlu_base_x_ != -1) | 282 if (dlu_base_x_ != -1) |
283 return dlu_base_x_; | 283 return dlu_base_x_; |
284 | 284 |
285 base::win::ScopedGetDC screen_dc(NULL); | 285 base::win::ScopedGetDC screen_dc(NULL); |
286 base::win::ScopedSelectObject font(screen_dc, hfont_); | 286 base::win::ScopedSelectObject font(screen_dc, hfont_); |
(...skipping 28 matching lines...) Expand all Loading... |
315 return new PlatformFontWin(native_font); | 315 return new PlatformFontWin(native_font); |
316 } | 316 } |
317 | 317 |
318 // static | 318 // static |
319 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 319 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
320 int font_size) { | 320 int font_size) { |
321 return new PlatformFontWin(font_name, font_size); | 321 return new PlatformFontWin(font_name, font_size); |
322 } | 322 } |
323 | 323 |
324 } // namespace gfx | 324 } // namespace gfx |
OLD | NEW |