[Cocoa] Testing fix after r210591
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jan 2017 21:40:12 +0000 (21:40 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jan 2017 21:40:12 +0000 (21:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166672

Unreviewed.

Fixes fast/text/trak-optimizeLegibility.html and
fast/text/system-font-features.html

* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::fontIsSystemFont):
(WebCore::preparePlatformFont):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210597 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp

index 65c9ea3..e353301 100644 (file)
@@ -1,3 +1,17 @@
+2017-01-11  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Cocoa] Testing fix after r210591
+        https://bugs.webkit.org/show_bug.cgi?id=166672
+
+        Unreviewed.
+
+        Fixes fast/text/trak-optimizeLegibility.html and
+        fast/text/system-font-features.html
+
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::fontIsSystemFont):
+        (WebCore::preparePlatformFont):
+
 2017-01-11  Chris Dumez  <cdumez@apple.com>
 
         Iterating over URLSearchParams does not work
index fa5389e..4128a0d 100644 (file)
@@ -419,6 +419,14 @@ static VariationDefaultsMap defaultVariationValues(CTFontRef font)
 }
 #endif
 
+static inline bool fontIsSystemFont(CTFontRef font)
+{
+    if (CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get()))
+        return true;
+    auto name = adoptCF(CTFontCopyPostScriptName(font));
+    return CFStringGetLength(name.get()) > 0 && CFStringGetCharacterAtIndex(name.get(), 0) == '.';
+}
+
 RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings& variantSettings, const FontVariationSettings& variations)
 {
     bool alwaysAddVariations = false;
@@ -428,8 +436,7 @@ RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMo
 #if ENABLE(VARIATION_FONTS)
     auto defaultValues = defaultVariationValues(originalFont);
 #if WORKAROUND_CORETEXT_VARIATIONS_UNSPECIFIED_VALUE_BUG
-    bool isSystemFont = CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(originalFont)).get());
-    alwaysAddVariations = !isSystemFont && !defaultValues.isEmpty();
+    alwaysAddVariations = !defaultValues.isEmpty();
 #endif
 #endif
 
@@ -495,9 +502,11 @@ RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMo
     }
 
 #if WORKAROUND_CORETEXT_VARIATIONS_UNSPECIFIED_VALUE_BUG
-    for (auto& defaultValue : defaultValues) {
-        if (!variationsToBeApplied.contains(defaultValue.key))
-            applyVariationValue(defaultValue.key, defaultValue.value.defaultValue, true);
+    if (!fontIsSystemFont(originalFont)) {
+        for (auto& defaultValue : defaultValues) {
+            if (!variationsToBeApplied.contains(defaultValue.key))
+                applyVariationValue(defaultValue.key, defaultValue.value.defaultValue, true);
+        }
     }
 #endif
 #undef WORKAROUND_CORETEXT_VARIATIONS_UNSPECIFIED_VALUE_BUG