Title: [206692] trunk
Revision
206692
Author
mmaxfi...@apple.com
Date
2016-09-30 16:12:23 -0700 (Fri, 30 Sep 2016)

Log Message

Implement rendering of font-variation-settings
https://bugs.webkit.org/show_bug.cgi?id=162782

Reviewed by Zalan Bujtas.

Source/WebCore:

Because the heavy lifting for font-variation-settings is done by CoreText,
this patch is fairly minimal. It simply hooks up the CSS property to CoreText.

There is an existing bug in CoreText where variations inside fonts do not
survive the addition of a cascade list. Therefore, FontPlatformData::ctFont()
needs to work around this (conditionally) by resupplying the variation at
the same time as the cascade list. The CoreText bug is <rdar://problem/28449441>.

Tests: fast/text/variations/duplicate.html
       fast/text/variations/exist.html
       fast/text/variations/inheritance.html
       fast/text/variations/order.html
       fast/text/variations/outofbounds.html

* platform/graphics/FontCache.h:
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::preparePlatformFont):
(WebCore::fontWithFamily):
(WebCore::FontCache::createFontPlatformData):
(WebCore::FontCache::systemFallbackForCharacters):
* platform/graphics/cocoa/FontPlatformDataCocoa.mm:
(WebCore::cascadeToLastResortAttributesDictionary):
(WebCore::cascadeToLastResortAndVariationsFontDescriptor):
(WebCore::FontPlatformData::ctFont):
(WebCore::cascadeToLastResortFontDescriptor): Deleted.
* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::updateCachedSystemFontDescription):

LayoutTests:

* fast/text/variations/duplicate-expected.html: Added.
* fast/text/variations/duplicate.html: Added.
* fast/text/variations/exist-expected-mismatch.html: Added.
* fast/text/variations/exist.html: Added.
* fast/text/variations/getComputedStyle.html:
* fast/text/variations/inheritance-expected.html: Added.
* fast/text/variations/inheritance.html: Added.
* fast/text/variations/order-expected.html: Added.
* fast/text/variations/order.html: Added.
* fast/text/variations/outofbounds-expected.html: Added.
* fast/text/variations/outofbounds.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206691 => 206692)


--- trunk/LayoutTests/ChangeLog	2016-09-30 23:10:31 UTC (rev 206691)
+++ trunk/LayoutTests/ChangeLog	2016-09-30 23:12:23 UTC (rev 206692)
@@ -1,5 +1,24 @@
 2016-09-30  Myles C. Maxfield  <mmaxfi...@apple.com>
 
+        Implement rendering of font-variation-settings
+        https://bugs.webkit.org/show_bug.cgi?id=162782
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/text/variations/duplicate-expected.html: Added.
+        * fast/text/variations/duplicate.html: Added.
+        * fast/text/variations/exist-expected-mismatch.html: Added.
+        * fast/text/variations/exist.html: Added.
+        * fast/text/variations/getComputedStyle.html:
+        * fast/text/variations/inheritance-expected.html: Added.
+        * fast/text/variations/inheritance.html: Added.
+        * fast/text/variations/order-expected.html: Added.
+        * fast/text/variations/order.html: Added.
+        * fast/text/variations/outofbounds-expected.html: Added.
+        * fast/text/variations/outofbounds.html: Added.
+
+2016-09-30  Myles C. Maxfield  <mmaxfi...@apple.com>
+
         Implement animation of font-variation-settings
         https://bugs.webkit.org/show_bug.cgi?id=162783
 

Added: trunk/LayoutTests/fast/text/variations/duplicate-expected.html (0 => 206692)


--- trunk/LayoutTests/fast/text/variations/duplicate-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/duplicate-expected.html	2016-09-30 23:12:23 UTC (rev 206692)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+   window.internals.settings.setVariationFontsEnabled(true);
+</script>
+</head>
+<body>
+<div style="font-family: 'Skia'; font-variation-settings: 'wght' 3;">Test passes if this text has a weight of 3.</div>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/variations/duplicate.html (0 => 206692)


--- trunk/LayoutTests/fast/text/variations/duplicate.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/duplicate.html	2016-09-30 23:12:23 UTC (rev 206692)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+   window.internals.settings.setVariationFontsEnabled(true);
+</script>
+</head>
+<body>
+<div style="font-family: 'Skia'; font-variation-settings: 'wght' 2, 'wght' 3;">Test passes if this text has a weight of 3.</div>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/variations/exist-expected-mismatch.html (0 => 206692)


--- trunk/LayoutTests/fast/text/variations/exist-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/exist-expected-mismatch.html	2016-09-30 23:12:23 UTC (rev 206692)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+   window.internals.settings.setVariationFontsEnabled(true);
+</script>
+</head>
+<body>
+<div style="font-family: 'Skia';">Test passes if this text is bold.</div>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/variations/exist.html (0 => 206692)


--- trunk/LayoutTests/fast/text/variations/exist.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/exist.html	2016-09-30 23:12:23 UTC (rev 206692)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+   window.internals.settings.setVariationFontsEnabled(true);
+</script>
+</head>
+<body>
+<div style="font-family: '-apple-system'; font-variation-settings: 'wght' 1.8;">Test passes if this text is bold.</div>
+</body>
+</html>

Modified: trunk/LayoutTests/fast/text/variations/getComputedStyle.html (206691 => 206692)


--- trunk/LayoutTests/fast/text/variations/getComputedStyle.html	2016-09-30 23:10:31 UTC (rev 206691)
+++ trunk/LayoutTests/fast/text/variations/getComputedStyle.html	2016-09-30 23:12:23 UTC (rev 206692)
@@ -29,4 +29,4 @@
 </script>
 <script src=""
 </body>
-</html>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/variations/inheritance-expected.html (0 => 206692)


--- trunk/LayoutTests/fast/text/variations/inheritance-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/inheritance-expected.html	2016-09-30 23:12:23 UTC (rev 206692)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+   window.internals.settings.setVariationFontsEnabled(true);
+</script>
+</head>
+<body>
+<div style="font-family: 'Skia'; font-variation-settings: 'wght' 2;">Test passes if this text is bold.</div>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/variations/inheritance.html (0 => 206692)


--- trunk/LayoutTests/fast/text/variations/inheritance.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/inheritance.html	2016-09-30 23:12:23 UTC (rev 206692)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+   window.internals.settings.setVariationFontsEnabled(true);
+</script>
+</head>
+<body>
+<div style="font-family: 'Skia'; font-variation-settings: 'wght' 2;"><div>Test passes if this text is bold.</div></div>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/variations/order-expected.html (0 => 206692)


--- trunk/LayoutTests/fast/text/variations/order-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/order-expected.html	2016-09-30 23:12:23 UTC (rev 206692)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+   window.internals.settings.setVariationFontsEnabled(true);
+</script>
+</head>
+<body>
+<div style="font-family: 'Skia'; font-variation-settings: 'wdth' 1.2, 'wght' 2;">Test passes if this text has a weight of 3.</div>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/variations/order.html (0 => 206692)


--- trunk/LayoutTests/fast/text/variations/order.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/order.html	2016-09-30 23:12:23 UTC (rev 206692)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+   window.internals.settings.setVariationFontsEnabled(true);
+</script>
+</head>
+<body>
+<div style="font-family: 'Skia'; font-variation-settings: 'wght' 2, 'wdth' 1.2;">Test passes if this text has a weight of 3.</div>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/variations/outofbounds-expected.html (0 => 206692)


--- trunk/LayoutTests/fast/text/variations/outofbounds-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/outofbounds-expected.html	2016-09-30 23:12:23 UTC (rev 206692)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+   window.internals.settings.setVariationFontsEnabled(true);
+</script>
+</head>
+<body>
+<div style="font-family: 'Skia';">Test passes if this text is not bold.</div>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/variations/outofbounds.html (0 => 206692)


--- trunk/LayoutTests/fast/text/variations/outofbounds.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/outofbounds.html	2016-09-30 23:12:23 UTC (rev 206692)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+   window.internals.settings.setVariationFontsEnabled(true);
+</script>
+</head>
+<body>
+<div style="font-family: 'Skia'; font-variation-settings: 'wght' 27;">Test passes if this text is not bold.</div>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (206691 => 206692)


--- trunk/Source/WebCore/ChangeLog	2016-09-30 23:10:31 UTC (rev 206691)
+++ trunk/Source/WebCore/ChangeLog	2016-09-30 23:12:23 UTC (rev 206692)
@@ -1,3 +1,40 @@
+2016-09-30  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Implement rendering of font-variation-settings
+        https://bugs.webkit.org/show_bug.cgi?id=162782
+
+        Reviewed by Zalan Bujtas.
+
+        Because the heavy lifting for font-variation-settings is done by CoreText,
+        this patch is fairly minimal. It simply hooks up the CSS property to CoreText.
+
+        There is an existing bug in CoreText where variations inside fonts do not
+        survive the addition of a cascade list. Therefore, FontPlatformData::ctFont()
+        needs to work around this (conditionally) by resupplying the variation at
+        the same time as the cascade list. The CoreText bug is <rdar://problem/28449441>.
+
+        Tests: fast/text/variations/duplicate.html
+               fast/text/variations/exist.html
+               fast/text/variations/inheritance.html
+               fast/text/variations/order.html
+               fast/text/variations/outofbounds.html
+
+        * platform/graphics/FontCache.h:
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::preparePlatformFont):
+        (WebCore::fontWithFamily):
+        (WebCore::FontCache::createFontPlatformData):
+        (WebCore::FontCache::systemFallbackForCharacters):
+        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+        (WebCore::cascadeToLastResortAttributesDictionary):
+        (WebCore::cascadeToLastResortAndVariationsFontDescriptor):
+        (WebCore::FontPlatformData::ctFont):
+        (WebCore::cascadeToLastResortFontDescriptor): Deleted.
+        * platform/graphics/mac/FontCustomPlatformData.cpp:
+        (WebCore::FontCustomPlatformData::fontPlatformData):
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::updateCachedSystemFontDescription):
+
 2016-09-29  Sam Weinig  <s...@webkit.org>
 
         Add initial support for IDL union conversion

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (206691 => 206692)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2016-09-30 23:10:31 UTC (rev 206691)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2016-09-30 23:12:23 UTC (rev 206692)
@@ -259,7 +259,7 @@
     bool needsSyntheticOblique;
 };
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, TextRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings&);
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, TextRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings&, const FontVariationSettings&);
 FontWeight fontWeightFromCoreText(CGFloat weight);
 uint16_t toCoreTextFontWeight(FontWeight);
 bool isFontWeightBold(FontWeight);

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


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2016-09-30 23:10:31 UTC (rev 206691)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2016-09-30 23:12:23 UTC (rev 206692)
@@ -143,6 +143,7 @@
 }
 
 typedef HashMap<FontTag, int, FourCharacterTagHash, FourCharacterTagHashTraits> FeaturesMap;
+typedef HashMap<FontTag, float, FourCharacterTagHash, FourCharacterTagHashTraits> VariationsMap;
 
 static FeaturesMap computeFeatureSettingsFromVariants(const FontVariantSettings& variantSettings)
 {
@@ -360,9 +361,9 @@
     return result;
 }
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings& variantSettings)
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings& variantSettings, const FontVariationSettings& variations)
 {
-    if (!originalFont || (!features.size() && (textRenderingMode == AutoTextRendering) && variantSettings.isAllNormal()
+    if (!originalFont || (!features.size() && variations.isEmpty() && (textRenderingMode == AutoTextRendering) && variantSettings.isAllNormal()
         && (!fontFaceFeatures || !fontFaceFeatures->size()) && (!fontFaceVariantSettings || fontFaceVariantSettings->isAllNormal())))
         return originalFont;
 
@@ -398,8 +399,12 @@
     for (auto& newFeature : features)
         featuresToBeApplied.set(newFeature.tag(), newFeature.value());
 
+    VariationsMap variationsToBeApplied;
+    for (auto& newVariation : variations)
+        variationsToBeApplied.set(newVariation.tag(), newVariation.value());
+
     RetainPtr<CFMutableDictionaryRef> attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
-    if (featuresToBeApplied.size()) {
+    if (!featuresToBeApplied.isEmpty()) {
         RetainPtr<CFMutableArrayRef> featureArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, features.size(), &kCFTypeArrayCallBacks));
         for (auto& p : featuresToBeApplied) {
             auto feature = FontFeature(p.key, p.value);
@@ -408,6 +413,18 @@
         }
         CFDictionaryAddValue(attributes.get(), kCTFontFeatureSettingsAttribute, featureArray.get());
     }
+
+    if (!variationsToBeApplied.isEmpty()) {
+        auto variationDictionary = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+        for (auto& p : variationsToBeApplied) {
+            long long bitwiseTag = p.key[0] << 24 | p.key[1] << 16 | p.key[2] << 8 | p.key[3];
+            auto tagNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberLongLongType, &bitwiseTag));
+            auto valueNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &p.value));
+            CFDictionarySetValue(variationDictionary.get(), tagNumber.get(), valueNumber.get());
+        }
+        CFDictionaryAddValue(attributes.get(), kCTFontVariationAttribute, variationDictionary.get());
+    }
+
     if (textRenderingMode == OptimizeLegibility) {
         CGFloat size = CTFontGetSize(originalFont);
         RetainPtr<CFNumberRef> sizeNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &size));
@@ -676,7 +693,7 @@
 }
 #endif
 
-static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, CTFontSymbolicTraits desiredTraits, FontWeight weight, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const TextRenderingMode& textRenderingMode, float size)
+static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, CTFontSymbolicTraits desiredTraits, FontWeight weight, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontVariationSettings& variationSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const TextRenderingMode& textRenderingMode, float size)
 {
     if (family.isEmpty())
         return nullptr;
@@ -689,7 +706,7 @@
         foundFont = platformFontWithFamily(family, desiredTraits, weight, textRenderingMode, size);
 #endif
     }
-    return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, featureSettings, variantSettings);
+    return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, featureSettings, variantSettings, variationSettings);
 }
 
 #if PLATFORM(MAC)
@@ -729,7 +746,7 @@
     CTFontSymbolicTraits traits = computeTraits(fontDescription);
     float size = fontDescription.computedPixelSize();
 
-    RetainPtr<CTFontRef> font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size);
+    RetainPtr<CTFontRef> font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size);
 
 #if PLATFORM(MAC)
     if (!font) {
@@ -740,7 +757,7 @@
         // Ignore the result because we want to use our own algorithm to actually find the font.
         autoActivateFont(family.string(), size);
 
-        font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size);
+        font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size);
     }
 #endif
 
@@ -784,7 +801,7 @@
 
     const FontPlatformData& platformData = originalFontData->platformData();
     RetainPtr<CTFontRef> result = platformLookupFallbackFont(platformData.font(), description.weight(), description.locale(), characters, length);
-    result = preparePlatformFont(result.get(), description.textRenderingMode(), nullptr, nullptr, description.featureSettings(), description.variantSettings());
+    result = preparePlatformFont(result.get(), description.textRenderingMode(), nullptr, nullptr, description.featureSettings(), description.variantSettings(), description.variationSettings());
     if (!result)
         return lastResortFallbackFont(description);
 

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm (206691 => 206692)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2016-09-30 23:10:31 UTC (rev 206691)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2016-09-30 23:12:23 UTC (rev 206692)
@@ -99,11 +99,11 @@
     return TextSpacingProportional;
 }
 
-static CTFontDescriptorRef cascadeToLastResortFontDescriptor()
+static CFDictionaryRef cascadeToLastResortAttributesDictionary()
 {
-    static CTFontDescriptorRef descriptor;
-    if (descriptor)
-        return descriptor;
+    static CFDictionaryRef attributes = nullptr;
+    if (attributes)
+        return attributes;
 
     RetainPtr<CTFontDescriptorRef> lastResort = adoptCF(CTFontDescriptorCreateWithNameAndSize(CFSTR("LastResort"), 0));
 
@@ -112,11 +112,37 @@
 
     const void* keys[] = { kCTFontCascadeListAttribute };
     const void* values[] = { array.get() };
-    RetainPtr<CFDictionaryRef> attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+    attributes = CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
 
-    descriptor = CTFontDescriptorCreateWithAttributes(attributes.get());
+    return attributes;
+}
 
-    return descriptor;
+static RetainPtr<CTFontDescriptorRef> cascadeToLastResortAndVariationsFontDescriptor(CTFontRef originalFont)
+{
+// FIXME: Remove this when <rdar://problem/28449441> is fixed.
+#define WORKAROUND_CORETEXT_VARIATIONS_WITH_FALLBACK_LIST_BUG ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 110000))
+
+#if WORKAROUND_CORETEXT_VARIATIONS_WITH_FALLBACK_LIST_BUG
+    CFDictionaryRef attributes = cascadeToLastResortAttributesDictionary();
+    auto variations = adoptCF(static_cast<CFDictionaryRef>(CTFontCopyAttribute(originalFont, kCTFontVariationAttribute)));
+    if (!variations)
+#endif
+    {
+        UNUSED_PARAM(originalFont);
+
+        static CTFontDescriptorRef descriptor = nullptr;
+        if (descriptor)
+            return descriptor;
+
+        descriptor = CTFontDescriptorCreateWithAttributes(attributes);
+        return descriptor;
+    }
+#if WORKAROUND_CORETEXT_VARIATIONS_WITH_FALLBACK_LIST_BUG
+    auto mutableAttributes = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 2, attributes));
+    CFDictionaryAddValue(mutableAttributes.get(), kCTFontVariationAttribute, variations.get());
+    return adoptCF(CTFontDescriptorCreateWithAttributes(mutableAttributes.get()));
+#endif
+#undef WORKAROUND_CORETEXT_VARIATIONS_WITH_FALLBACK_LIST_BUG
 }
 
 CTFontRef FontPlatformData::ctFont() const
@@ -128,7 +154,7 @@
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 100000)
     ASSERT(m_cgFont);
 #endif
-    m_ctFont = adoptCF(CTFontCreateCopyWithAttributes(m_font.get(), m_size, 0, cascadeToLastResortFontDescriptor()));
+    m_ctFont = adoptCF(CTFontCreateCopyWithAttributes(m_font.get(), m_size, 0, cascadeToLastResortAndVariationsFontDescriptor(m_font.get()).get()));
 
     if (m_widthVariant != RegularWidth) {
         int featureTypeValue = kTextSpacingType;

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp (206691 => 206692)


--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2016-09-30 23:10:31 UTC (rev 206691)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2016-09-30 23:12:23 UTC (rev 206692)
@@ -40,7 +40,7 @@
     FontOrientation orientation = fontDescription.orientation();
     FontWidthVariant widthVariant = fontDescription.widthVariant();
     RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr));
-    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), &fontFaceFeatures, &fontFaceVariantSettings, fontDescription.featureSettings(), fontDescription.variantSettings());
+    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), &fontFaceFeatures, &fontFaceVariantSettings, fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings());
     ASSERT(font);
     return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant, fontDescription.textRenderingMode());
 }

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (206691 => 206692)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2016-09-30 23:10:31 UTC (rev 206691)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2016-09-30 23:12:23 UTC (rev 206692)
@@ -1278,7 +1278,7 @@
 
     ASSERT(fontDescriptor);
     RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 0, nullptr));
-    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), nullptr, nullptr, fontDescription.featureSettings(), fontDescription.variantSettings());
+    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), nullptr, nullptr, fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings());
     fontDescription.setIsAbsoluteSize(true);
     fontDescription.setOneFamily(textStyle);
     fontDescription.setSpecifiedSize(CTFontGetSize(font.get()));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to