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

Side by Side Diff: ui/gfx/platform_font_win.cc

Issue 230793003: Fix creating platform font on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « no previous file | no next file » | 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) 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 void PlatformFontWin::InitWithCopyOfHFONT(HFONT hfont) { 195 void PlatformFontWin::InitWithCopyOfHFONT(HFONT hfont) {
196 DCHECK(hfont); 196 DCHECK(hfont);
197 LOGFONT font_info; 197 LOGFONT font_info;
198 GetObject(hfont, sizeof(LOGFONT), &font_info); 198 GetObject(hfont, sizeof(LOGFONT), &font_info);
199 font_ref_ = CreateHFontRef(CreateFontIndirect(&font_info)); 199 font_ref_ = CreateHFontRef(CreateFontIndirect(&font_info));
200 } 200 }
201 201
202 void PlatformFontWin::InitWithFontNameAndSize(const std::string& font_name, 202 void PlatformFontWin::InitWithFontNameAndSize(const std::string& font_name,
203 int font_size) { 203 int font_size) {
204 HFONT hf = ::CreateFont(-font_size, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 204 HFONT hf = ::CreateFont(-font_size, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
205 DEFAULT_CHARSET,
206 OUT_DEFAULT_PRECIS,
207 CLIP_DEFAULT_PRECIS,
208 DEFAULT_QUALITY,
209 DEFAULT_PITCH | FF_DONTCARE,
205 base::UTF8ToUTF16(font_name).c_str()); 210 base::UTF8ToUTF16(font_name).c_str());
206 font_ref_ = CreateHFontRef(hf); 211 font_ref_ = CreateHFontRef(hf);
207 } 212 }
208 213
209 // static 214 // static
210 PlatformFontWin::HFontRef* PlatformFontWin::GetBaseFontRef() { 215 PlatformFontWin::HFontRef* PlatformFontWin::GetBaseFontRef() {
211 if (base_font_ref_ == NULL) { 216 if (base_font_ref_ == NULL) {
212 NONCLIENTMETRICS metrics; 217 NONCLIENTMETRICS metrics;
213 base::win::GetNonClientMetrics(&metrics); 218 base::win::GetNonClientMetrics(&metrics);
214 219
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 return new PlatformFontWin(native_font); 327 return new PlatformFontWin(native_font);
323 } 328 }
324 329
325 // static 330 // static
326 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 331 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
327 int font_size) { 332 int font_size) {
328 return new PlatformFontWin(font_name, font_size); 333 return new PlatformFontWin(font_name, font_size);
329 } 334 }
330 335
331 } // namespace gfx 336 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698