From d49a6b110bced49fa318b0dd45bf409218df9ee5 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 7 Feb 2017 15:36:17 -0800 Subject: [PATCH] Obtain test font attributes from the font description (#3396) Fixes https://github.com/flutter/flutter/issues/7724 --- runtime/test_font_selector.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/runtime/test_font_selector.cc b/runtime/test_font_selector.cc index 0ec0fd8e1fd..49fc7c548e7 100644 --- a/runtime/test_font_selector.cc +++ b/runtime/test_font_selector.cc @@ -20,7 +20,7 @@ TestFontSelector::TestFontSelector() = default; TestFontSelector::~TestFontSelector() = default; PassRefPtr TestFontSelector::getFontData( - const FontDescription&, + const FontDescription& fontDescription, const AtomicString& familyName) { if (test_font_data_ != nullptr) { return test_font_data_; @@ -28,8 +28,15 @@ PassRefPtr TestFontSelector::getFontData( auto typeface = SkTypeface::MakeFromStream(GetTestFontData().release()); - FontPlatformData platform_data(typeface, "Ahem", 14.0, false, false, - FontOrientation::Horizontal, false); + bool syntheticBold = (fontDescription.weight() >= FontWeight600 || + fontDescription.isSyntheticBold()); + bool syntheticItalic = (fontDescription.style() || + fontDescription.isSyntheticItalic()); + FontPlatformData platform_data(typeface, "Ahem", + fontDescription.effectiveFontSize(), + syntheticBold, syntheticItalic, + fontDescription.orientation(), + fontDescription.useSubpixelPositioning()); test_font_data_ = SimpleFontData::create(platform_data, CustomFontData::create());