Title: [219418] trunk/Source/WebCore
Revision
219418
Author
timo...@hatcher.name
Date
2017-07-12 12:16:44 -0700 (Wed, 12 Jul 2017)

Log Message

Improve font matching with FontConfig and FreeType
https://bugs.webkit.org/show_bug.cgi?id=174374

Reviewed by Michael Catanzaro.

* platform/graphics/freetype/FontCacheFreeType.cpp:
(WebCore::FontCache::createFontPlatformData): Loop through all family name matches from FcFontMatch.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (219417 => 219418)


--- trunk/Source/WebCore/ChangeLog	2017-07-12 19:08:06 UTC (rev 219417)
+++ trunk/Source/WebCore/ChangeLog	2017-07-12 19:16:44 UTC (rev 219418)
@@ -1,3 +1,13 @@
+2017-07-12  Timothy Hatcher  <timo...@hatcher.name>
+
+        Improve font matching with FontConfig and FreeType
+        https://bugs.webkit.org/show_bug.cgi?id=174374
+
+        Reviewed by Michael Catanzaro.
+
+        * platform/graphics/freetype/FontCacheFreeType.cpp:
+        (WebCore::FontCache::createFontPlatformData): Loop through all family name matches from FcFontMatch.
+
 2017-07-12  Youenn Fablet  <you...@apple.com>
 
         Reactivate audio ducking when restarting the shared unit

Modified: trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp (219417 => 219418)


--- trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp	2017-07-12 19:08:06 UTC (rev 219417)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp	2017-07-12 19:16:44 UTC (rev 219418)
@@ -364,15 +364,22 @@
     if (!resultPattern) // No match.
         return nullptr;
 
+    // Loop through each font family of the result to see if it fits the one we requested.
+    bool matchedFontFamily = false;
     FcChar8* fontConfigFamilyNameAfterMatching;
-    FcPatternGetString(resultPattern.get(), FC_FAMILY, 0, &fontConfigFamilyNameAfterMatching);
-    String familyNameAfterMatching = String::fromUTF8(reinterpret_cast<char*>(fontConfigFamilyNameAfterMatching));
+    for (int i = 0; FcPatternGetString(resultPattern.get(), FC_FAMILY, i, &fontConfigFamilyNameAfterMatching) == FcResultMatch; ++i) {
+        // If Fontconfig gave us a different font family than the one we requested, we should ignore it
+        // and allow WebCore to give us the next font on the CSS fallback list. The exceptions are if
+        // this family name is a commonly-used generic family, or if the families are strongly-aliased.
+        // Checking for a strong alias comes last, since it is slow.
+        String familyNameAfterMatching = String::fromUTF8(reinterpret_cast<char*>(fontConfigFamilyNameAfterMatching));
+        if (equalIgnoringASCIICase(familyNameAfterConfiguration, familyNameAfterMatching) || isCommonlyUsedGenericFamily(familyNameString) || areStronglyAliased(familyNameAfterConfiguration, familyNameAfterMatching)) {
+            matchedFontFamily = true;
+            break;
+        }
+    }
 
-    // If Fontconfig gave us a different font family than the one we requested, we should ignore it
-    // and allow WebCore to give us the next font on the CSS fallback list. The exceptions are if
-    // this family name is a commonly-used generic family, or if the families are strongly-aliased.
-    // Checking for a strong alias comes last, since it is slow.
-    if (!equalIgnoringASCIICase(familyNameAfterConfiguration, familyNameAfterMatching) && !isCommonlyUsedGenericFamily(familyNameString) && !areStronglyAliased(familyNameAfterConfiguration, familyNameAfterMatching))
+    if (!matchedFontFamily)
         return nullptr;
 
     // Verify that this font has an encoding compatible with Fontconfig. Fontconfig currently
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to