Chromium Code Reviews| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 base_font_ref_->AddRef(); | 215 base_font_ref_->AddRef(); |
| 216 } | 216 } |
| 217 return base_font_ref_; | 217 return base_font_ref_; |
| 218 } | 218 } |
| 219 | 219 |
| 220 PlatformFontWin::HFontRef* PlatformFontWin::CreateHFontRef(HFONT font) { | 220 PlatformFontWin::HFontRef* PlatformFontWin::CreateHFontRef(HFONT font) { |
| 221 TEXTMETRIC font_metrics; | 221 TEXTMETRIC font_metrics; |
| 222 | 222 |
| 223 { | 223 { |
| 224 base::win::ScopedGetDC screen_dc(NULL); | 224 base::win::ScopedGetDC screen_dc(NULL); |
| 225 base::win::ScopedSelectObject font(screen_dc, font); | 225 base::win::ScopedSelectObject scoped_font(screen_dc, font); |
|
Nico
2012/05/02 17:34:35
This one might actually fix a bug.
| |
| 226 ui::ScopedSetMapMode mode(screen_dc, MM_TEXT); | 226 ui::ScopedSetMapMode mode(screen_dc, MM_TEXT); |
| 227 GetTextMetrics(screen_dc, &font_metrics); | 227 GetTextMetrics(screen_dc, &font_metrics); |
| 228 } | 228 } |
| 229 | 229 |
| 230 const int height = std::max<int>(1, font_metrics.tmHeight); | 230 const int height = std::max<int>(1, font_metrics.tmHeight); |
| 231 const int baseline = std::max<int>(1, font_metrics.tmAscent); | 231 const int baseline = std::max<int>(1, font_metrics.tmAscent); |
| 232 const int ave_char_width = std::max<int>(1, font_metrics.tmAveCharWidth); | 232 const int ave_char_width = std::max<int>(1, font_metrics.tmAveCharWidth); |
| 233 const int font_size = | 233 const int font_size = |
| 234 std::max<int>(1, font_metrics.tmHeight - font_metrics.tmInternalLeading); | 234 std::max<int>(1, font_metrics.tmHeight - font_metrics.tmInternalLeading); |
| 235 int style = 0; | 235 int style = 0; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 return new PlatformFontWin(native_font); | 309 return new PlatformFontWin(native_font); |
| 310 } | 310 } |
| 311 | 311 |
| 312 // static | 312 // static |
| 313 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 313 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
| 314 int font_size) { | 314 int font_size) { |
| 315 return new PlatformFontWin(font_name, font_size); | 315 return new PlatformFontWin(font_name, font_size); |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace gfx | 318 } // namespace gfx |
| OLD | NEW |