@@ -118,8 +118,12 @@ RefPtr<Font> FontCache::systemFallbackForCharacterCluster(const FontDescription&
118118
119119 // FIXME: handle synthetic properties.
120120 auto features = computeFeatures (description, { });
121- auto typeface = fontManager ().matchFamilyStyleCharacter (nullptr , skiaFontStyle (description), bcp47.data (), bcp47.size (), baseCharacter);
122- FontPlatformData alternateFontData (WTFMove (typeface), description.computedSize (), false /* syntheticBold */ , false /* syntheticOblique */ , description.orientation (), description.widthVariant (), description.textRenderingMode (), WTFMove (features));
121+ auto skFontStyle = skiaFontStyle (description);
122+ auto typeface = fontManager ().matchFamilyStyleCharacter (nullptr , skFontStyle, bcp47.data (), bcp47.size (), baseCharacter);
123+ auto syntheticBold = description.hasAutoFontSynthesisWeight () && skFontStyle.weight () >= SkFontStyle::kSemiBold_Weight && !typeface->isBold ();
124+ auto syntheticOblique = description.hasAutoFontSynthesisStyle () && skFontStyle.slant () != SkFontStyle::kUpright_Slant && !typeface->isItalic ();
125+ FontPlatformData alternateFontData (WTFMove (typeface), description.computedSize (), syntheticBold, syntheticOblique, description.orientation (), description.widthVariant (), description.textRenderingMode (), WTFMove (features));
126+
123127 return fontForPlatformData (alternateFontData);
124128}
125129
@@ -148,13 +152,17 @@ Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescripti
148152 return font.releaseNonNull ();
149153
150154 // Passing nullptr as family name makes Skia use a weak match.
151- auto typeface = fontManager ().matchFamilyStyle (nullptr , skiaFontStyle (fontDescription));
155+ auto skFontStyle = skiaFontStyle (fontDescription);
156+ auto typeface = fontManager ().matchFamilyStyle (nullptr , skFontStyle);
152157 if (!typeface) {
153158 // LastResort is guaranteed to be non-null, so fallback to empty font with not glyphs.
154159 typeface = SkTypeface::MakeEmpty ();
155160 }
156161
157- FontPlatformData platformData (WTFMove (typeface), fontDescription.computedSize (), false /* syntheticBold */ , false /* syntheticOblique */ ,
162+ auto syntheticBold = fontDescription.hasAutoFontSynthesisWeight () && skFontStyle.weight () >= SkFontStyle::kSemiBold_Weight && !typeface->isBold ();
163+ auto syntheticOblique = fontDescription.hasAutoFontSynthesisStyle () && skFontStyle.slant () != SkFontStyle::kUpright_Slant && !typeface->isItalic ();
164+
165+ FontPlatformData platformData (WTFMove (typeface), fontDescription.computedSize (), syntheticBold, syntheticOblique,
158166 fontDescription.orientation (), fontDescription.widthVariant (), fontDescription.textRenderingMode (), computeFeatures (fontDescription, { }));
159167 return fontForPlatformData (platformData);
160168}
@@ -351,14 +359,18 @@ Vector<hb_feature_t> FontCache::computeFeatures(const FontDescription& fontDescr
351359std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData (const FontDescription& fontDescription, const AtomString& family, const FontCreationContext& fontCreationContext, OptionSet<FontLookupOptions> options)
352360{
353361 auto familyName = getFamilyNameStringFromFamily (family);
354- auto typeface = fontManager ().matchFamilyStyle (familyName.utf8 ().data (), skiaFontStyle (fontDescription));
362+ auto skFontStyle = skiaFontStyle (fontDescription);
363+ auto typeface = fontManager ().matchFamilyStyle (familyName.utf8 ().data (), skFontStyle);
355364 if (!typeface)
356365 return nullptr ;
357366
358367 auto size = fontDescription.adjustedSizeForFontFace (fontCreationContext.sizeAdjust ());
359368 auto features = computeFeatures (fontDescription, fontCreationContext);
360- UNUSED_PARAM (options);
361- FontPlatformData platformData (WTFMove (typeface), size, false /* syntheticBold */ , false /* syntheticOblique */ , fontDescription.orientation (), fontDescription.widthVariant (), fontDescription.textRenderingMode (), WTFMove (features));
369+ auto syntheticBold = fontDescription.hasAutoFontSynthesisWeight () && !options.contains (FontLookupOptions::DisallowBoldSynthesis)
370+ && skFontStyle.weight () >= SkFontStyle::kSemiBold_Weight && !typeface->isBold ();
371+ auto syntheticOblique = fontDescription.hasAutoFontSynthesisStyle () && !options.contains (FontLookupOptions::DisallowObliqueSynthesis)
372+ && skFontStyle.slant () != SkFontStyle::kUpright_Slant && !typeface->isItalic ();
373+ FontPlatformData platformData (WTFMove (typeface), size, syntheticBold, syntheticOblique, fontDescription.orientation (), fontDescription.widthVariant (), fontDescription.textRenderingMode (), WTFMove (features));
362374
363375 platformData.updateSizeWithFontSizeAdjust (fontDescription.fontSizeAdjust (), fontDescription.computedSize ());
364376 auto platformDataUniquePtr = makeUnique<FontPlatformData>(platformData);
0 commit comments