Title: [219102] trunk
Revision
219102
Author
mmaxfi...@apple.com
Date
2017-07-03 15:46:29 -0700 (Mon, 03 Jul 2017)

Log Message

REGRESSION(Variation Fonts): Specifying Skia by PostScript name does not yield the expected result
https://bugs.webkit.org/show_bug.cgi?id=174079
<rdar://problem/33040854>

Reviewed by Alex Christensen.

Source/WebCore:

Because Skia is a variation font, its PostScript name contains values to apply to its variation
axes. However, WebKit's variation code was overwriting these intrinsive values with ones specified
by CSS. Therefore, the intrinsic ones were being ignored. The solution is just to pass a flag from
the lookup code to the variations code describing if the font was created via a PostScript name,
and to not apply the CSS properties to it if it was.

Test: fast/text/variations/skia-postscript-name.html

* platform/graphics/FontCache.h:
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::preparePlatformFont):
(WebCore::platformFontLookupWithFamily):
(WebCore::fontWithFamily):

LayoutTests:

* fast/text/variations/skia-postscript-name-expected-mismatch.html: Added.
* fast/text/variations/skia-postscript-name.html: Added.
* platform/ios-simulator/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219101 => 219102)


--- trunk/LayoutTests/ChangeLog	2017-07-03 22:29:17 UTC (rev 219101)
+++ trunk/LayoutTests/ChangeLog	2017-07-03 22:46:29 UTC (rev 219102)
@@ -1,3 +1,15 @@
+2017-07-03  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        REGRESSION(Variation Fonts): Specifying Skia by PostScript name does not yield the expected result
+        https://bugs.webkit.org/show_bug.cgi?id=174079
+        <rdar://problem/33040854>
+
+        Reviewed by Alex Christensen.
+
+        * fast/text/variations/skia-postscript-name-expected-mismatch.html: Added.
+        * fast/text/variations/skia-postscript-name.html: Added.
+        * platform/ios-simulator/TestExpectations:
+
 2017-07-03  Per Arne Vollan  <pvol...@apple.com>
 
         [Win] Update expectations for layout tests.

Added: trunk/LayoutTests/fast/text/variations/skia-postscript-name-expected-mismatch.html (0 => 219102)


--- trunk/LayoutTests/fast/text/variations/skia-postscript-name-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/skia-postscript-name-expected-mismatch.html	2017-07-03 22:46:29 UTC (rev 219102)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div style="font: 100px 'Skia';">e</div>
+</body>
+</html>
+

Added: trunk/LayoutTests/fast/text/variations/skia-postscript-name.html (0 => 219102)


--- trunk/LayoutTests/fast/text/variations/skia-postscript-name.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/skia-postscript-name.html	2017-07-03 22:46:29 UTC (rev 219102)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div style="font: 100px 'Skia-Regular_Light-Extended';">e</div>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (219101 => 219102)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-07-03 22:29:17 UTC (rev 219101)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-07-03 22:46:29 UTC (rev 219102)
@@ -141,4 +141,7 @@
 http/tests/security/contentSecurityPolicy/WebAssembly-blocked.html [ Failure ]
 
 # WebGL tests which need triaging https://bugs.webkit.org/b/174100
-webgl/1.0.2/conformance/uniforms/uniform-default-values.html [ Failure ]
\ No newline at end of file
+webgl/1.0.2/conformance/uniforms/uniform-default-values.html [ Failure ]
+
+# This test requires Skia, which isn't available on iOS.
+webkit.org/b/174079 fast/text/variations/skia-postscript-name.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (219101 => 219102)


--- trunk/Source/WebCore/ChangeLog	2017-07-03 22:29:17 UTC (rev 219101)
+++ trunk/Source/WebCore/ChangeLog	2017-07-03 22:46:29 UTC (rev 219102)
@@ -1,3 +1,25 @@
+2017-07-03  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        REGRESSION(Variation Fonts): Specifying Skia by PostScript name does not yield the expected result
+        https://bugs.webkit.org/show_bug.cgi?id=174079
+        <rdar://problem/33040854>
+
+        Reviewed by Alex Christensen.
+
+        Because Skia is a variation font, its PostScript name contains values to apply to its variation
+        axes. However, WebKit's variation code was overwriting these intrinsive values with ones specified
+        by CSS. Therefore, the intrinsic ones were being ignored. The solution is just to pass a flag from
+        the lookup code to the variations code describing if the font was created via a PostScript name,
+        and to not apply the CSS properties to it if it was.
+
+        Test: fast/text/variations/skia-postscript-name.html
+
+        * platform/graphics/FontCache.h:
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::preparePlatformFont):
+        (WebCore::platformFontLookupWithFamily):
+        (WebCore::fontWithFamily):
+
 2017-07-03  Brady Eidson  <beid...@apple.com>
 
         Switch all WebKit API related to favicons from WebIconDatabase over to new WebCore::IconLoader mechanism.

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (219101 => 219102)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2017-07-03 22:29:17 UTC (rev 219101)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2017-07-03 22:46:29 UTC (rev 219102)
@@ -281,7 +281,7 @@
     bool needsSyntheticOblique;
 };
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, const FontDescription&, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, float size);
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, const FontDescription&, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, float size, bool applyWeightWidthSlopeVariations = true);
 SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&, bool isPlatformFont = false);
 RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomicString& family, FontSelectionRequest, float size);
 RetainPtr<CTFontRef> platformFontWithFamily(const AtomicString& family, FontSelectionRequest, TextRenderingMode, float size);

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (219101 => 219102)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-07-03 22:29:17 UTC (rev 219101)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-07-03 22:46:29 UTC (rev 219102)
@@ -513,7 +513,7 @@
     bool aatShaping { false };
 };
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescription& fontDescription, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, float size)
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescription& fontDescription, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, float size, bool applyWeightWidthSlopeVariations)
 {
     bool alwaysAddVariations = false;
 
@@ -528,6 +528,7 @@
 #else
     UNUSED_PARAM(fontFaceCapabilities);
     UNUSED_PARAM(size);
+    UNUSED_PARAM(applyWeightWidthSlopeVariations);
 #endif
 
     const auto& features = fontDescription.featureSettings();
@@ -587,7 +588,7 @@
     };
 
     // The system font is somewhat magical. Don't mess with its variations.
-    if (!fontIsSystemFont(originalFont)) {
+    if (applyWeightWidthSlopeVariations && !fontIsSystemFont(originalFont)) {
         float weight = fontSelectionRequest.weight;
         float width = fontSelectionRequest.width;
         float slope = fontSelectionRequest.slope;
@@ -1115,15 +1116,20 @@
     return result;
 }
 
-static RetainPtr<CTFontRef> platformFontLookupWithFamily(const AtomicString& family, FontSelectionRequest request, float size)
+struct FontLookup {
+    RetainPtr<CTFontRef> result;
+    bool createdFromPostScriptName { false };
+};
+
+static FontLookup platformFontLookupWithFamily(const AtomicString& family, FontSelectionRequest request, float size)
 {
     const auto& whitelist = fontWhitelist();
     if (!isSystemFont(family) && whitelist.size() && !whitelist.contains(family))
-        return nullptr;
+        return { nullptr };
 
 #if SHOULD_USE_CORE_TEXT_FONT_LOOKUP
     CTFontSymbolicTraits traits = (isFontWeightBold(request.weight) ? kCTFontTraitBold : 0) | (isItalic(request.slope) ? kCTFontTraitItalic : 0);
-    return adoptCF(CTFontCreateForCSS(family.string().createCFString().get(), static_cast<float>(request.weight), traits, size));
+    return { adoptCF(CTFontCreateForCSS(family.string().createCFString().get(), static_cast<float>(request.weight), traits, size)) };
 #else
     const auto& familyFonts = FontDatabase::singleton().collectionForFamily(family.string());
     if (familyFonts.isEmpty()) {
@@ -1136,29 +1142,29 @@
         // but if a <b> appears as a descendent element, it will be honored too.
         const auto& postScriptFont = FontDatabase::singleton().fontForPostScriptName(family);
         if (!postScriptFont.fontDescriptor)
-            return nullptr;
+            return { nullptr };
         if ((isItalic(request.slope) && !isItalic(postScriptFont.capabilities.slope.maximum))
             || (isFontWeightBold(request.weight) && !isFontWeightBold(postScriptFont.capabilities.weight.maximum))) {
             auto postScriptFamilyName = adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(postScriptFont.fontDescriptor.get(), kCTFontFamilyNameAttribute)));
             if (!postScriptFamilyName)
-                return nullptr;
+                return { nullptr };
             const auto& familyFonts = FontDatabase::singleton().collectionForFamily(String(postScriptFamilyName.get()));
             if (familyFonts.isEmpty())
-                return nullptr;
+                return { nullptr };
             if (const auto* installedFont = findClosestFont(familyFonts, request)) {
                 if (!installedFont->fontDescriptor)
-                    return nullptr;
-                return adoptCF(CTFontCreateWithFontDescriptor(installedFont->fontDescriptor.get(), size, nullptr));
+                    return { nullptr };
+                return { adoptCF(CTFontCreateWithFontDescriptor(installedFont->fontDescriptor.get(), size, nullptr)), true };
             }
-            return nullptr;
+            return { nullptr };
         }
-        return adoptCF(CTFontCreateWithFontDescriptor(postScriptFont.fontDescriptor.get(), size, nullptr));
+        return { adoptCF(CTFontCreateWithFontDescriptor(postScriptFont.fontDescriptor.get(), size, nullptr)), true };
     }
 
     if (const auto* installedFont = findClosestFont(familyFonts, request))
-        return adoptCF(CTFontCreateWithFontDescriptor(installedFont->fontDescriptor.get(), size, nullptr));
+        return { adoptCF(CTFontCreateWithFontDescriptor(installedFont->fontDescriptor.get(), size, nullptr)), false };
 
-    return nullptr;
+    return { nullptr };
 #endif
 }
 
@@ -1184,10 +1190,11 @@
         return nullptr;
 
     const auto& request = fontDescription.fontSelectionRequest();
-    auto foundFont = platformFontWithFamilySpecialCase(family, request, size);
-    if (!foundFont)
-        foundFont = platformFontLookupWithFamily(family, request, size);
-    return preparePlatformFont(foundFont.get(), fontDescription, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, size);
+    FontLookup fontLookup;
+    fontLookup.result = platformFontWithFamilySpecialCase(family, request, size);
+    if (!fontLookup.result)
+        fontLookup = platformFontLookupWithFamily(family, request, size);
+    return preparePlatformFont(fontLookup.result.get(), fontDescription, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, size, !fontLookup.createdFromPostScriptName);
 }
 
 #if PLATFORM(MAC)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to