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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 void PlatformFontWin::InitWithCopyOfHFONT(HFONT hfont) { | 187 void PlatformFontWin::InitWithCopyOfHFONT(HFONT hfont) { |
188 DCHECK(hfont); | 188 DCHECK(hfont); |
189 LOGFONT font_info; | 189 LOGFONT font_info; |
190 GetObject(hfont, sizeof(LOGFONT), &font_info); | 190 GetObject(hfont, sizeof(LOGFONT), &font_info); |
191 font_ref_ = CreateHFontRef(CreateFontIndirect(&font_info)); | 191 font_ref_ = CreateHFontRef(CreateFontIndirect(&font_info)); |
192 } | 192 } |
193 | 193 |
194 void PlatformFontWin::InitWithFontNameAndSize(const std::string& font_name, | 194 void PlatformFontWin::InitWithFontNameAndSize(const std::string& font_name, |
195 int font_size) { | 195 int font_size) { |
196 HFONT hf = ::CreateFont(-font_size, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 196 HFONT hf = ::CreateFont(-font_size, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, |
197 UTF8ToUTF16(font_name).c_str()); | 197 0, 0, 0, UTF8ToUTF16(font_name).c_str()); |
198 font_ref_ = CreateHFontRef(hf); | 198 font_ref_ = hf ? CreateHFontRef(hf) : GetBaseFontRef(); |
199 } | 199 } |
200 | 200 |
201 // static | 201 // static |
202 PlatformFontWin::HFontRef* PlatformFontWin::GetBaseFontRef() { | 202 PlatformFontWin::HFontRef* PlatformFontWin::GetBaseFontRef() { |
203 if (base_font_ref_ == NULL) { | 203 if (base_font_ref_ == NULL) { |
204 NONCLIENTMETRICS metrics; | 204 NONCLIENTMETRICS metrics; |
205 base::win::GetNonClientMetrics(&metrics); | 205 base::win::GetNonClientMetrics(&metrics); |
206 | 206 |
207 if (adjust_font_callback) | 207 if (adjust_font_callback) |
208 adjust_font_callback(&metrics.lfMessageFont); | 208 adjust_font_callback(&metrics.lfMessageFont); |
(...skipping 100 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 |