Truly independent web browser
LibGfx: Apply Fontconfig hinting rules to the selected font
Timothy Flynn3ab570547629
diff --git a/Libraries/LibGfx/Font/GlobalFontConfig.cpp b/Libraries/LibGfx/Font/GlobalFontConfig.cppindex c9b24803de7..2f0292f645a 100644--- a/Libraries/LibGfx/Font/GlobalFontConfig.cpp+++ b/Libraries/LibGfx/Font/GlobalFontConfig.cpp@@ -40,7 +40,8 @@ FontHintingOptions GlobalFontConfig::hinting_for_font(FlyString const& family, freturn options;auto family_name = family.bytes_as_string_view().to_byte_string();- FcPatternAddString(pattern, FC_FAMILY, reinterpret_cast<FcChar8 const*>(family_name.characters()));+ auto const* font_family = reinterpret_cast<FcChar8 const*>(family_name.characters());+ FcPatternAddString(pattern, FC_FAMILY, font_family);FcPatternAddDouble(pattern, FC_PIXEL_SIZE, pixel_size);FcPatternAddInteger(pattern, FC_WEIGHT, FcWeightFromOpenType(weight));@@ -56,6 +57,13 @@ FontHintingOptions GlobalFontConfig::hinting_for_font(FlyString const& family, fFcPatternDestroy(pattern);return options;}+ // Font-target rules apply to the selected family. Pattern substitution adds fallback families to the query.+ FcPatternDel(font_pattern, FC_FAMILY);+ if (!FcPatternAddString(font_pattern, FC_FAMILY, font_family)) {+ FcPatternDestroy(font_pattern);+ FcPatternDestroy(pattern);+ return options;+ }FcConfigSubstituteWithPat(m_config, font_pattern, pattern, FcMatchFont);FcBool hinting_enabled = FcTrue;