Title: [213505] trunk
Revision
213505
Author
mmaxfi...@apple.com
Date
2017-03-06 23:30:27 -0800 (Mon, 06 Mar 2017)

Log Message

Apply well-known-axis variation values at the right time in preparePlatformFont()
https://bugs.webkit.org/show_bug.cgi?id=168896

Reviewed by Jon Lee.

Source/WebCore:

Simply plumb the FontSelectionRequest to the place where font variations are implemented.

Test: fast/text/variations/font-selection-properties.html

* platform/graphics/FontCache.h:
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::preparePlatformFont):
(WebCore::fontWithFamily):
(WebCore::FontCache::createFontPlatformData):
(WebCore::FontCache::systemFallbackForCharacters):
* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):

LayoutTests:

* fast/text/variations/font-selection-properties-expected.html: Added.
* fast/text/variations/font-selection-properties.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (213504 => 213505)


--- trunk/LayoutTests/ChangeLog	2017-03-07 07:19:51 UTC (rev 213504)
+++ trunk/LayoutTests/ChangeLog	2017-03-07 07:30:27 UTC (rev 213505)
@@ -1,3 +1,13 @@
+2017-03-06  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Apply well-known-axis variation values at the right time in preparePlatformFont()
+        https://bugs.webkit.org/show_bug.cgi?id=168896
+
+        Reviewed by Jon Lee.
+
+        * fast/text/variations/font-selection-properties-expected.html: Added.
+        * fast/text/variations/font-selection-properties.html: Added.
+
 2017-03-06  Brent Fulgham  <bfulg...@apple.com>
 
         Validate DOM after potentially destructive actions during parser insert operations

Added: trunk/LayoutTests/fast/text/variations/font-selection-properties-expected.html (0 => 213505)


--- trunk/LayoutTests/fast/text/variations/font-selection-properties-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/font-selection-properties-expected.html	2017-03-07 07:30:27 UTC (rev 213505)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+	font-family: "Boxis";
+	src: url("resources/Boxis-VF.ttf");
+}
+</style>
+</head>
+<body>
+This test makes sure that the font selection properties affect font variations.
+<div style="font-family: Boxis; font-variation-settings: 'wdth' 900;">Hello</div>
+<div style="font-family: Boxis; font-variation-settings: 'wdth' 100;">Hello</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/variations/font-selection-properties.html (0 => 213505)


--- trunk/LayoutTests/fast/text/variations/font-selection-properties.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/font-selection-properties.html	2017-03-07 07:30:27 UTC (rev 213505)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+	font-family: "Boxis";
+	src: url("resources/Boxis-VF.ttf");
+}
+</style>
+</head>
+<body>
+This test makes sure that the font selection properties affect font variations.
+<div style="font-family: Boxis; font-stretch: 900;">Hello</div>
+<div style="font-family: Boxis; font-stretch: 900; font-variation-settings: 'wdth' 100;">Hello</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (213504 => 213505)


--- trunk/Source/WebCore/ChangeLog	2017-03-07 07:19:51 UTC (rev 213504)
+++ trunk/Source/WebCore/ChangeLog	2017-03-07 07:30:27 UTC (rev 213505)
@@ -1,5 +1,25 @@
 2017-03-06  Myles C. Maxfield  <mmaxfi...@apple.com>
 
+        Apply well-known-axis variation values at the right time in preparePlatformFont()
+        https://bugs.webkit.org/show_bug.cgi?id=168896
+
+        Reviewed by Jon Lee.
+
+        Simply plumb the FontSelectionRequest to the place where font variations are implemented.
+
+        Test: fast/text/variations/font-selection-properties.html
+
+        * platform/graphics/FontCache.h:
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::preparePlatformFont):
+        (WebCore::fontWithFamily):
+        (WebCore::FontCache::createFontPlatformData):
+        (WebCore::FontCache::systemFallbackForCharacters):
+        * platform/graphics/mac/FontCustomPlatformData.cpp:
+        (WebCore::FontCustomPlatformData::fontPlatformData):
+
+2017-03-06  Myles C. Maxfield  <mmaxfi...@apple.com>
+
         Unreviewed post-review fixup after r213464
         https://bugs.webkit.org/show_bug.cgi?id=169255
 

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (213504 => 213505)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2017-03-07 07:19:51 UTC (rev 213504)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2017-03-07 07:30:27 UTC (rev 213505)
@@ -275,7 +275,7 @@
     bool needsSyntheticOblique;
 };
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, TextRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings&, const FontVariationSettings&);
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, TextRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings&, FontSelectionRequest, const FontVariationSettings&);
 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 (213504 => 213505)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-03-07 07:19:51 UTC (rev 213504)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-03-07 07:30:27 UTC (rev 213505)
@@ -422,7 +422,7 @@
 #endif
 
 #define WORKAROUND_CORETEXT_VARIATIONS_UNSPECIFIED_VALUE_BUG ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 110000))
-#if ENABLE(VARIATION_FONTS) && WORKAROUND_CORETEXT_VARIATIONS_UNSPECIFIED_VALUE_BUG
+#if ENABLE(VARIATION_FONTS) && (PLATFORM(IOS) || WORKAROUND_CORETEXT_VARIATIONS_UNSPECIFIED_VALUE_BUG)
 static inline bool fontIsSystemFont(CTFontRef font)
 {
     if (CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get()))
@@ -432,7 +432,7 @@
 }
 #endif
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings& variantSettings, const FontVariationSettings& variations)
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings& variantSettings, FontSelectionRequest fontSelectionRequest, const FontVariationSettings& variations)
 {
     bool alwaysAddVariations = false;
 
@@ -439,10 +439,10 @@
     // FIXME: Remove when <rdar://problem/29859207> is fixed
 #if ENABLE(VARIATION_FONTS)
     auto defaultValues = defaultVariationValues(originalFont);
-#if WORKAROUND_CORETEXT_VARIATIONS_UNSPECIFIED_VALUE_BUG
     alwaysAddVariations = !defaultValues.isEmpty();
+#else
+    UNUSED_PARAM(fontSelectionRequest);
 #endif
-#endif
 
     if (!originalFont || (!features.size() && (!alwaysAddVariations && variations.isEmpty()) && (textRenderingMode == AutoTextRendering) && variantSettings.isAllNormal()
         && (!fontFaceFeatures || !fontFaceFeatures->size()) && (!fontFaceVariantSettings || fontFaceVariantSettings->isAllNormal())))
@@ -496,14 +496,26 @@
         variationsToBeApplied.set(tag, value);
     };
 
-    for (auto& newVariation : variations) {
-        auto iterator = defaultValues.find(newVariation.tag());
+    auto applyVariation = [&](const FontTag& tag, float value) {
+        auto iterator = defaultValues.find(tag);
         if (iterator == defaultValues.end())
-            continue;
-        float valueToApply = clampTo(newVariation.value(), iterator->value.minimumValue, iterator->value.maximumValue);
+            return;
+        float valueToApply = clampTo(value, iterator->value.minimumValue, iterator->value.maximumValue);
         bool isDefaultValue = valueToApply == iterator->value.defaultValue;
-        applyVariationValue(newVariation.tag(), valueToApply, isDefaultValue);
+        applyVariationValue(tag, valueToApply, isDefaultValue);
+    };
+
+#if PLATFORM(IOS)
+    // The system font is somewhat magical. Don't mess with its variations.
+    if (!fontIsSystemFont(originalFont))
+#endif
+    {
+        applyVariation({{'w', 'g', 'h', 't'}}, static_cast<float>(fontSelectionRequest.weight));
+        applyVariation({{'w', 'd', 't', 'h'}}, static_cast<float>(fontSelectionRequest.width));
+        applyVariation({{'s', 'l', 'n', 't'}}, static_cast<float>(fontSelectionRequest.slope));
     }
+    for (auto& newVariation : variations)
+        applyVariation(newVariation.tag(), newVariation.value());
 
 #if WORKAROUND_CORETEXT_VARIATIONS_UNSPECIFIED_VALUE_BUG
     if (!fontIsSystemFont(originalFont)) {
@@ -951,7 +963,7 @@
     FontCache::singleton().invalidate();
 }
 
-static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, FontSelectionRequest request, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontVariationSettings& variationSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const TextRenderingMode& textRenderingMode, float size)
+static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, FontSelectionRequest request, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontVariationSettings& variationSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const TextRenderingMode& textRenderingMode, FontSelectionRequest fontSelectionRequest, float size)
 {
     if (family.isEmpty())
         return nullptr;
@@ -959,7 +971,7 @@
     auto foundFont = platformFontWithFamilySpecialCase(family, request, size);
     if (!foundFont)
         foundFont = platformFontLookupWithFamily(family, request, size);
-    return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, featureSettings, variantSettings, variationSettings);
+    return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, featureSettings, variantSettings, fontSelectionRequest, variationSettings);
 }
 
 #if PLATFORM(MAC)
@@ -998,7 +1010,7 @@
 {
     float size = fontDescription.computedPixelSize();
 
-    auto font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size);
+    auto font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), size);
 
 #if PLATFORM(MAC)
     if (!font) {
@@ -1009,7 +1021,7 @@
         // Ignore the result because we want to use our own algorithm to actually find the font.
         autoActivateFont(family.string(), size);
 
-        font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size);
+        font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), size);
     }
 #endif
 
@@ -1097,7 +1109,7 @@
 
     const FontPlatformData& platformData = originalFontData->platformData();
     auto result = lookupFallbackFont(platformData.font(), description.weight(), description.locale(), characters, length);
-    result = preparePlatformFont(result.get(), description.textRenderingMode(), nullptr, nullptr, description.featureSettings(), description.variantSettings(), description.variationSettings());
+    result = preparePlatformFont(result.get(), description.textRenderingMode(), nullptr, nullptr, description.featureSettings(), description.variantSettings(), description.fontSelectionRequest(), description.variationSettings());
     if (!result)
         return lastResortFallbackFont(description);
 

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


--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2017-03-07 07:19:51 UTC (rev 213504)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2017-03-07 07:30:27 UTC (rev 213505)
@@ -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(), fontDescription.variationSettings());
+    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), &fontFaceFeatures, &fontFaceVariantSettings, fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.fontSelectionRequest(), fontDescription.variationSettings());
     ASSERT(font);
     return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant, fontDescription.textRenderingMode());
 }

Modified: trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h (213504 => 213505)


--- trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h	2017-03-07 07:19:51 UTC (rev 213504)
+++ trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h	2017-03-07 07:30:27 UTC (rev 213505)
@@ -125,7 +125,6 @@
 
 CTFontRef CTFontCreatePhysicalFontForCharactersWithLanguage(CTFontRef, const UTF16Char* characters, CFIndex length, CFStringRef language, CFIndex* coveredLength);
 bool CTFontIsAppleColorEmoji(CTFontRef);
-bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
 CTFontRef CTFontCreateForCharacters(CTFontRef currentFont, const UTF16Char *characters, CFIndex length, CFIndex *coveredLength);
 
 WTF_EXTERN_C_END
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to