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

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

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 <dwrite.h> 8 #include <dwrite.h>
9 #include <limits.h> 9 #include <limits.h>
10 #include <math.h> 10 #include <math.h>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return lf_height < 0 ? -min_font_size : min_font_size; 60 return lf_height < 0 ? -min_font_size : min_font_size;
61 } else { 61 } else {
62 return lf_height; 62 return lf_height;
63 } 63 }
64 } 64 }
65 65
66 // Sets style properties on |font_info| based on |font_style|. 66 // Sets style properties on |font_info| based on |font_style|.
67 void SetLogFontStyle(int font_style, LOGFONT* font_info) { 67 void SetLogFontStyle(int font_style, LOGFONT* font_info) {
68 font_info->lfUnderline = (font_style & gfx::Font::UNDERLINE) != 0; 68 font_info->lfUnderline = (font_style & gfx::Font::UNDERLINE) != 0;
69 font_info->lfItalic = (font_style & gfx::Font::ITALIC) != 0; 69 font_info->lfItalic = (font_style & gfx::Font::ITALIC) != 0;
70 font_info->lfWeight = (font_style & gfx::Font::BOLD) ? FW_BOLD : FW_NORMAL; 70 }
71
72 gfx::Font::FontWeight ToGfxFontWeight(int weight) {
73 return static_cast<gfx::Font::FontWeight>(weight);
71 } 74 }
72 75
73 // Returns the family name for the |IDWriteFont| interface passed in. 76 // Returns the family name for the |IDWriteFont| interface passed in.
74 // The family name is returned in the |family_name_ret| parameter. 77 // The family name is returned in the |family_name_ret| parameter.
75 // Returns S_OK on success. 78 // Returns S_OK on success.
76 // TODO(ananta) 79 // TODO(ananta)
77 // Remove the CHECKs in this function once this stabilizes on the field. 80 // Remove the CHECKs in this function once this stabilizes on the field.
78 HRESULT GetFamilyNameFromDirectWriteFont(IDWriteFont* dwrite_font, 81 HRESULT GetFamilyNameFromDirectWriteFont(IDWriteFont* dwrite_font,
79 base::string16* family_name_ret) { 82 base::string16* family_name_ret) {
80 base::win::ScopedComPtr<IDWriteFontFamily> font_family; 83 base::win::ScopedComPtr<IDWriteFontFamily> font_family;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return hr; 154 return hr;
152 } 155 }
153 156
154 // Returns a matching IDWriteFont for the |font_info| passed in. If we fail 157 // Returns a matching IDWriteFont for the |font_info| passed in. If we fail
155 // to find a matching font, then we return the IDWriteFont corresponding to 158 // to find a matching font, then we return the IDWriteFont corresponding to
156 // the default font on the system. 159 // the default font on the system.
157 // Returns S_OK on success. 160 // Returns S_OK on success.
158 // The contents of the LOGFONT pointer |font_info| may be modified on 161 // The contents of the LOGFONT pointer |font_info| may be modified on
159 // return. 162 // return.
160 HRESULT GetMatchingDirectWriteFont(LOGFONT* font_info, 163 HRESULT GetMatchingDirectWriteFont(LOGFONT* font_info,
161 int font_style, 164 int font_style,
msw 2016/03/22 01:53:44 This only concerns italic now... change to |bool i
162 IDWriteFactory* factory, 165 IDWriteFactory* factory,
163 IDWriteFont** dwrite_font) { 166 IDWriteFont** dwrite_font) {
164 // First try the GDI compat route to get a matching DirectWrite font. 167 // First try the GDI compat route to get a matching DirectWrite font.
165 // If that succeeds then we are good. If that fails then try and find a 168 // If that succeeds then we are good. If that fails then try and find a
166 // match from the DirectWrite font collection. 169 // match from the DirectWrite font collection.
167 HRESULT hr = FindDirectWriteFontForLOGFONT(factory, font_info, dwrite_font); 170 HRESULT hr = FindDirectWriteFontForLOGFONT(factory, font_info, dwrite_font);
168 if (SUCCEEDED(hr)) 171 if (SUCCEEDED(hr))
169 return hr; 172 return hr;
170 173
171 // Get a matching font from the system font collection exposed by 174 // Get a matching font from the system font collection exposed by
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // If we fail to find a matching font, then fallback to the first font in 233 // If we fail to find a matching font, then fallback to the first font in
231 // the list. This is what skia does as well. 234 // the list. This is what skia does as well.
232 hr = font_collection->GetFontFamily(0, font_family.Receive()); 235 hr = font_collection->GetFontFamily(0, font_family.Receive());
233 } 236 }
234 237
235 if (FAILED(hr)) { 238 if (FAILED(hr)) {
236 CHECK(false); 239 CHECK(false);
237 return hr; 240 return hr;
238 } 241 }
239 242
240 DWRITE_FONT_WEIGHT weight = (font_style & SkTypeface::kBold) 243 DWRITE_FONT_WEIGHT weight =
241 ? DWRITE_FONT_WEIGHT_BOLD 244 static_cast<DWRITE_FONT_WEIGHT>(font_info->lfWeight);
242 : DWRITE_FONT_WEIGHT_NORMAL;
243 DWRITE_FONT_STRETCH stretch = DWRITE_FONT_STRETCH_NORMAL; 245 DWRITE_FONT_STRETCH stretch = DWRITE_FONT_STRETCH_NORMAL;
244 DWRITE_FONT_STYLE italic = (font_style & SkTypeface::kItalic) 246 DWRITE_FONT_STYLE italic = (font_style & SkTypeface::kItalic)
245 ? DWRITE_FONT_STYLE_ITALIC 247 ? DWRITE_FONT_STYLE_ITALIC
246 : DWRITE_FONT_STYLE_NORMAL; 248 : DWRITE_FONT_STYLE_NORMAL;
247 249
248 // The IDWriteFontFamily::GetFirstMatchingFont call fails on certain machines 250 // The IDWriteFontFamily::GetFirstMatchingFont call fails on certain machines
249 // for fonts like MS UI Gothic, Segoe UI, etc. It is not clear why these 251 // for fonts like MS UI Gothic, Segoe UI, etc. It is not clear why these
250 // fonts could be accessible to GDI and not to DirectWrite. 252 // fonts could be accessible to GDI and not to DirectWrite.
251 // The code below adds some debug fields to help track down these failures. 253 // The code below adds some debug fields to help track down these failures.
252 // 1. We get the matching font list for the font attributes passed in. 254 // 1. We get the matching font list for the font attributes passed in.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 304
303 PlatformFontWin::PlatformFontWin(NativeFont native_font) { 305 PlatformFontWin::PlatformFontWin(NativeFont native_font) {
304 InitWithCopyOfHFONT(native_font); 306 InitWithCopyOfHFONT(native_font);
305 } 307 }
306 308
307 PlatformFontWin::PlatformFontWin(const std::string& font_name, 309 PlatformFontWin::PlatformFontWin(const std::string& font_name,
308 int font_size) { 310 int font_size) {
309 InitWithFontNameAndSize(font_name, font_size); 311 InitWithFontNameAndSize(font_name, font_size);
310 } 312 }
311 313
312 Font PlatformFontWin::DeriveFontWithHeight(int height, int style) { 314 Font PlatformFontWin::DeriveFontWithHeight(int height,
315 int style,
316 gfx::Font::FontWeight weight) {
313 DCHECK_GE(height, 0); 317 DCHECK_GE(height, 0);
314 318
315 // Create a font with a height near that of the target height. 319 // Create a font with a height near that of the target height.
316 LOGFONT font_info; 320 LOGFONT font_info;
317 GetObject(GetNativeFont(), sizeof(LOGFONT), &font_info); 321 GetObject(GetNativeFont(), sizeof(LOGFONT), &font_info);
318 font_info.lfHeight = height; 322 font_info.lfHeight = height;
323 font_info.lfWeight = weight;
319 SetLogFontStyle(style, &font_info); 324 SetLogFontStyle(style, &font_info);
320 325
321 HFONT hfont = CreateFontIndirect(&font_info); 326 HFONT hfont = CreateFontIndirect(&font_info);
322 Font font(new PlatformFontWin(CreateHFontRef(hfont))); 327 Font font(new PlatformFontWin(CreateHFontRef(hfont)));
323 328
324 // Respect the minimum font size constraint. 329 // Respect the minimum font size constraint.
325 const int min_font_size = GetMinimumFontSize(); 330 const int min_font_size = GetMinimumFontSize();
326 331
327 // Used to avoid shrinking the font and expanding it. 332 // Used to avoid shrinking the font and expanding it.
328 bool ran_shrink_loop = false; 333 bool ran_shrink_loop = false;
329 334
330 // Iterate to find the largest font with a height <= |height|. 335 // Iterate to find the largest font with a height <= |height|.
331 while ((font.GetHeight() > height) && 336 while ((font.GetHeight() > height) &&
332 (font.GetFontSize() >= min_font_size)) { 337 (font.GetFontSize() >= min_font_size)) {
333 ran_shrink_loop = true; 338 ran_shrink_loop = true;
334 Font derived_font = font.Derive(-1, style); 339 Font derived_font = font.Derive(-1, style, font.GetWeight());
335 // Break the loop if the derived font is too small or hasn't shrunk at all. 340 // Break the loop if the derived font is too small or hasn't shrunk at all.
336 if ((derived_font.GetFontSize() < min_font_size) || 341 if ((derived_font.GetFontSize() < min_font_size) ||
337 ((derived_font.GetFontSize() == font.GetFontSize()) && 342 ((derived_font.GetFontSize() == font.GetFontSize()) &&
338 (derived_font.GetHeight() == font.GetHeight()))) 343 (derived_font.GetHeight() == font.GetHeight())))
339 break; 344 break;
340 font = derived_font; 345 font = derived_font;
341 } 346 }
342 347
343 while ((!ran_shrink_loop && font.GetHeight() <= height) || 348 while ((!ran_shrink_loop && font.GetHeight() <= height) ||
344 (font.GetFontSize() < min_font_size)) { 349 (font.GetFontSize() < min_font_size)) {
345 Font derived_font = font.Derive(1, style); 350 Font derived_font = font.Derive(1, style, font.GetWeight());
346 // Break the loop if the derived font is too large or hasn't grown at all. 351 // Break the loop if the derived font is too large or hasn't grown at all.
347 if (((derived_font.GetHeight() > height) && 352 if (((derived_font.GetHeight() > height) &&
348 (font.GetFontSize() >= min_font_size)) || 353 (font.GetFontSize() >= min_font_size)) ||
349 ((derived_font.GetFontSize() == font.GetFontSize()) && 354 ((derived_font.GetFontSize() == font.GetFontSize()) &&
350 (derived_font.GetHeight() == font.GetHeight()))) 355 (derived_font.GetHeight() == font.GetHeight())))
351 break; 356 break;
352 font = derived_font; 357 font = derived_font;
353 } 358 }
354 return font; 359 return font;
355 } 360 }
356 361
357 //////////////////////////////////////////////////////////////////////////////// 362 ////////////////////////////////////////////////////////////////////////////////
358 // PlatformFontWin, PlatformFont implementation: 363 // PlatformFontWin, PlatformFont implementation:
359 364
360 Font PlatformFontWin::DeriveFont(int size_delta, int style) const { 365 Font PlatformFontWin::DeriveFont(int size_delta,
366 int style,
367 gfx::Font::FontWeight weight) const {
361 LOGFONT font_info; 368 LOGFONT font_info;
362 GetObject(GetNativeFont(), sizeof(LOGFONT), &font_info); 369 GetObject(GetNativeFont(), sizeof(LOGFONT), &font_info);
363 const int requested_font_size = font_ref_->requested_font_size(); 370 const int requested_font_size = font_ref_->requested_font_size();
364 font_info.lfHeight = AdjustFontSize(-requested_font_size, size_delta); 371 font_info.lfHeight = AdjustFontSize(-requested_font_size, size_delta);
372 font_info.lfWeight = weight;
365 SetLogFontStyle(style, &font_info); 373 SetLogFontStyle(style, &font_info);
366 374
367 HFONT hfont = CreateFontIndirect(&font_info); 375 HFONT hfont = CreateFontIndirect(&font_info);
368 return Font(new PlatformFontWin(CreateHFontRef(hfont))); 376 return Font(new PlatformFontWin(CreateHFontRef(hfont)));
369 } 377 }
370 378
371 int PlatformFontWin::GetHeight() { 379 int PlatformFontWin::GetHeight() {
372 return font_ref_->height(); 380 return font_ref_->height();
373 } 381 }
374 382
383 gfx::Font::FontWeight PlatformFontWin::GetWeight() {
384 return font_ref_->weight();
385 }
386
375 int PlatformFontWin::GetBaseline() { 387 int PlatformFontWin::GetBaseline() {
376 return font_ref_->baseline(); 388 return font_ref_->baseline();
377 } 389 }
378 390
379 int PlatformFontWin::GetCapHeight() { 391 int PlatformFontWin::GetCapHeight() {
380 return font_ref_->cap_height(); 392 return font_ref_->cap_height();
381 } 393 }
382 394
383 int PlatformFontWin::GetExpectedTextWidth(int length) { 395 int PlatformFontWin::GetExpectedTextWidth(int length) {
384 return length * std::min(font_ref_->GetDluBaseX(), 396 return length * std::min(font_ref_->GetDluBaseX(),
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 const int cap_height = 535 const int cap_height =
524 std::max<int>(1, font_metrics.tmAscent - font_metrics.tmInternalLeading); 536 std::max<int>(1, font_metrics.tmAscent - font_metrics.tmInternalLeading);
525 const int ave_char_width = std::max<int>(1, font_metrics.tmAveCharWidth); 537 const int ave_char_width = std::max<int>(1, font_metrics.tmAveCharWidth);
526 const int font_size = 538 const int font_size =
527 std::max<int>(1, font_metrics.tmHeight - font_metrics.tmInternalLeading); 539 std::max<int>(1, font_metrics.tmHeight - font_metrics.tmInternalLeading);
528 int style = 0; 540 int style = 0;
529 if (font_metrics.tmItalic) 541 if (font_metrics.tmItalic)
530 style |= Font::ITALIC; 542 style |= Font::ITALIC;
531 if (font_metrics.tmUnderlined) 543 if (font_metrics.tmUnderlined)
532 style |= Font::UNDERLINE; 544 style |= Font::UNDERLINE;
533 if (font_metrics.tmWeight >= kTextMetricWeightBold)
534 style |= Font::BOLD;
535 545
536 return new HFontRef(font, font_size, height, baseline, cap_height, 546 return new HFontRef(font, font_size, height, baseline, cap_height,
537 ave_char_width, style); 547 ave_char_width, ToGfxFontWeight(font_metrics.tmWeight),
548 style);
538 } 549 }
539 550
540 // static 551 // static
541 PlatformFontWin::HFontRef* PlatformFontWin::CreateHFontRefFromSkia( 552 PlatformFontWin::HFontRef* PlatformFontWin::CreateHFontRefFromSkia(
542 HFONT gdi_font, 553 HFONT gdi_font,
543 const TEXTMETRIC& font_metrics) { 554 const TEXTMETRIC& font_metrics) {
544 LOGFONT font_info = {0}; 555 LOGFONT font_info = {0};
545 GetObject(gdi_font, sizeof(LOGFONT), &font_info); 556 GetObject(gdi_font, sizeof(LOGFONT), &font_info);
546 557
547 // If the font height is passed in as 0, assume the height to be -1 to ensure 558 // If the font height is passed in as 0, assume the height to be -1 to ensure
548 // that we return the metrics for a 1 point font. 559 // that we return the metrics for a 1 point font.
549 // If the font height is positive it represents the rasterized font's cell 560 // If the font height is positive it represents the rasterized font's cell
550 // height. Calculate the actual height accordingly. 561 // height. Calculate the actual height accordingly.
551 if (font_info.lfHeight > 0) { 562 if (font_info.lfHeight > 0) {
552 font_info.lfHeight = 563 font_info.lfHeight =
553 font_metrics.tmInternalLeading - font_metrics.tmHeight; 564 font_metrics.tmInternalLeading - font_metrics.tmHeight;
554 } else if (font_info.lfHeight == 0) { 565 } else if (font_info.lfHeight == 0) {
555 font_info.lfHeight = -1; 566 font_info.lfHeight = -1;
556 } 567 }
557 568
558 int skia_style = SkTypeface::kNormal; 569 int skia_style = SkTypeface::kNormal;
559 if (font_info.lfWeight >= FW_SEMIBOLD && 570 if (font_info.lfWeight >= FW_SEMIBOLD && font_info.lfWeight <= FW_ULTRABOLD)
560 font_info.lfWeight <= FW_ULTRABOLD) {
561 skia_style |= SkTypeface::kBold; 571 skia_style |= SkTypeface::kBold;
msw 2016/03/22 01:53:44 This is ignored by GetMatchingDirectWriteFont now;
Mikus 2016/03/22 14:19:51 Done.
562 }
563 if (font_info.lfItalic) 572 if (font_info.lfItalic)
564 skia_style |= SkTypeface::kItalic; 573 skia_style |= SkTypeface::kItalic;
565 574
566 // Skia does not return all values we need for font metrics. For e.g. 575 // Skia does not return all values we need for font metrics. For e.g.
567 // the cap height which indicates the height of capital letters is not 576 // the cap height which indicates the height of capital letters is not
568 // returned even though it is returned by DirectWrite. 577 // returned even though it is returned by DirectWrite.
569 // TODO(ananta) 578 // TODO(ananta)
570 // Fix SkScalerContext_win_dw.cpp to return all metrics we need from 579 // Fix SkScalerContext_win_dw.cpp to return all metrics we need from
571 // DirectWrite and remove the code here which retrieves metrics from 580 // DirectWrite and remove the code here which retrieves metrics from
572 // DirectWrite to calculate the cap height. 581 // DirectWrite to calculate the cap height.
573 base::win::ScopedComPtr<IDWriteFont> dwrite_font; 582 base::win::ScopedComPtr<IDWriteFont> dwrite_font;
574 HRESULT hr = GetMatchingDirectWriteFont(&font_info, 583 HRESULT hr = GetMatchingDirectWriteFont(&font_info,
575 skia_style, 584 skia_style,
576 direct_write_factory_, 585 direct_write_factory_,
577 dwrite_font.Receive()); 586 dwrite_font.Receive());
578 if (FAILED(hr)) { 587 if (FAILED(hr)) {
579 CHECK(false); 588 CHECK(false);
580 return nullptr; 589 return nullptr;
581 } 590 }
582 591
583 DWRITE_FONT_METRICS dwrite_font_metrics = {0}; 592 DWRITE_FONT_METRICS dwrite_font_metrics = {0};
584 dwrite_font->GetMetrics(&dwrite_font_metrics); 593 dwrite_font->GetMetrics(&dwrite_font_metrics);
585 594
586 skia::RefPtr<SkTypeface> skia_face = skia::AdoptRef( 595 SkFontStyle skia_font_style(font_info.lfWeight, SkFontStyle::kNormal_Width,
587 SkTypeface::CreateFromName( 596 font_info.lfItalic ? SkFontStyle::kItalic_Slant
588 base::SysWideToUTF8(font_info.lfFaceName).c_str(), 597 : SkFontStyle::kUpright_Slant);
589 static_cast<SkTypeface::Style>(skia_style))); 598
599 skia::RefPtr<SkTypeface> skia_face =
600 skia::AdoptRef(SkTypeface::CreateFromNameAndStyle(
601 base::SysWideToUTF8(font_info.lfFaceName).c_str(), skia_font_style));
590 602
591 gfx::FontRenderParams font_params = 603 gfx::FontRenderParams font_params =
592 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr); 604 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr);
593 SkFontHost::SetSubpixelOrder( 605 SkFontHost::SetSubpixelOrder(
594 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrder( 606 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrder(
595 font_params.subpixel_rendering)); 607 font_params.subpixel_rendering));
596 SkFontHost::SetSubpixelOrientation( 608 SkFontHost::SetSubpixelOrientation(
597 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrientation( 609 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrientation(
598 font_params.subpixel_rendering)); 610 font_params.subpixel_rendering));
599 611
(...skipping 20 matching lines...) Expand all
620 // from DirectWrite. 632 // from DirectWrite.
621 const int ave_char_width = 633 const int ave_char_width =
622 skia_metrics.fAvgCharWidth == 0 ? font_metrics.tmAveCharWidth 634 skia_metrics.fAvgCharWidth == 0 ? font_metrics.tmAveCharWidth
623 : skia_metrics.fAvgCharWidth; 635 : skia_metrics.fAvgCharWidth;
624 636
625 int style = 0; 637 int style = 0;
626 if (skia_style & SkTypeface::kItalic) 638 if (skia_style & SkTypeface::kItalic)
627 style |= Font::ITALIC; 639 style |= Font::ITALIC;
628 if (font_info.lfUnderline) 640 if (font_info.lfUnderline)
629 style |= Font::UNDERLINE; 641 style |= Font::UNDERLINE;
630 if (font_info.lfWeight >= kTextMetricWeightBold)
631 style |= Font::BOLD;
632 642
633 // DirectWrite may have substituted the GDI font name with a fallback 643 // DirectWrite may have substituted the GDI font name with a fallback
634 // font. Ensure that it is updated here. 644 // font. Ensure that it is updated here.
635 DeleteObject(gdi_font); 645 DeleteObject(gdi_font);
636 gdi_font = ::CreateFontIndirect(&font_info); 646 gdi_font = ::CreateFontIndirect(&font_info);
637 return new HFontRef(gdi_font, -font_info.lfHeight, height, baseline, 647 return new HFontRef(gdi_font, -font_info.lfHeight, height, baseline,
638 cap_height, ave_char_width, style); 648 cap_height, ave_char_width,
649 ToGfxFontWeight(font_metrics.tmWeight), style);
639 } 650 }
640 651
641 PlatformFontWin::PlatformFontWin(HFontRef* hfont_ref) : font_ref_(hfont_ref) { 652 PlatformFontWin::PlatformFontWin(HFontRef* hfont_ref) : font_ref_(hfont_ref) {
642 } 653 }
643 654
644 PlatformFontWin::~PlatformFontWin() { 655 PlatformFontWin::~PlatformFontWin() {
645 } 656 }
646 657
647 //////////////////////////////////////////////////////////////////////////////// 658 ////////////////////////////////////////////////////////////////////////////////
648 // PlatformFontWin::HFontRef: 659 // PlatformFontWin::HFontRef:
649 660
650 PlatformFontWin::HFontRef::HFontRef(HFONT hfont, 661 PlatformFontWin::HFontRef::HFontRef(HFONT hfont,
651 int font_size, 662 int font_size,
652 int height, 663 int height,
653 int baseline, 664 int baseline,
654 int cap_height, 665 int cap_height,
655 int ave_char_width, 666 int ave_char_width,
667 gfx::Font::FontWeight weight,
656 int style) 668 int style)
657 : hfont_(hfont), 669 : hfont_(hfont),
658 font_size_(font_size), 670 font_size_(font_size),
659 height_(height), 671 height_(height),
660 baseline_(baseline), 672 baseline_(baseline),
661 cap_height_(cap_height), 673 cap_height_(cap_height),
662 ave_char_width_(ave_char_width), 674 ave_char_width_(ave_char_width),
675 weight_(weight),
663 style_(style), 676 style_(style),
664 dlu_base_x_(-1), 677 dlu_base_x_(-1),
665 requested_font_size_(font_size) { 678 requested_font_size_(font_size) {
666 DLOG_ASSERT(hfont); 679 DLOG_ASSERT(hfont);
667 680
668 LOGFONT font_info; 681 LOGFONT font_info;
669 GetObject(hfont_, sizeof(LOGFONT), &font_info); 682 GetObject(hfont_, sizeof(LOGFONT), &font_info);
670 font_name_ = base::UTF16ToUTF8(base::string16(font_info.lfFaceName)); 683 font_name_ = base::UTF16ToUTF8(base::string16(font_info.lfFaceName));
671 684
672 // Retrieve the font size from the GetTextMetrics API instead of referencing 685 // Retrieve the font size from the GetTextMetrics API instead of referencing
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 return new PlatformFontWin(native_font); 737 return new PlatformFontWin(native_font);
725 } 738 }
726 739
727 // static 740 // static
728 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 741 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
729 int font_size) { 742 int font_size) {
730 return new PlatformFontWin(font_name, font_size); 743 return new PlatformFontWin(font_name, font_size);
731 } 744 }
732 745
733 } // namespace gfx 746 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698