Modified: trunk/Source/WebCore/ChangeLog (210369 => 210370)
--- trunk/Source/WebCore/ChangeLog 2017-01-05 20:24:59 UTC (rev 210369)
+++ trunk/Source/WebCore/ChangeLog 2017-01-05 20:31:28 UTC (rev 210370)
@@ -1,3 +1,22 @@
+2017-01-05 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [Cocoa] Variation fonts without variations specified are not rendered as if the default variations were specified
+ https://bugs.webkit.org/show_bug.cgi?id=166672
+ <rdar://problem/29779119>
+ <rdar://problem/29848883>
+
+ Reviewed by Simon Fraser.
+
+ CoreText has a bug (<rdar://problem/29859207>) where variation fonts without
+ a specified variation value are rendered as if the minimum value is specified,
+ rather than the default value. The solution is to apply default values where
+ they are omitted.
+
+ Test: fast/text/variations/advances.html
+
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::preparePlatformFont):
+
2017-01-05 Zalan Bujtas <za...@apple.com>
Mark the dedicated root linebox for trailing floats in empty inlines dirty.
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (210369 => 210370)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2017-01-05 20:24:59 UTC (rev 210369)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2017-01-05 20:31:28 UTC (rev 210370)
@@ -411,10 +411,6 @@
auto b2 = (rawAxisIdentifier & 0xFF0000) >> 16;
auto b3 = (rawAxisIdentifier & 0xFF00) >> 8;
auto b4 = rawAxisIdentifier & 0xFF;
- ASSERT(b1 >= 0 && b1 <= std::numeric_limits<char>::max());
- ASSERT(b2 >= 0 && b2 <= std::numeric_limits<char>::max());
- ASSERT(b3 >= 0 && b3 <= std::numeric_limits<char>::max());
- ASSERT(b4 >= 0 && b4 <= std::numeric_limits<char>::max());
FontTag resultKey = {{ static_cast<char>(b1), static_cast<char>(b2), static_cast<char>(b3), static_cast<char>(b4) }};
VariationDefaults resultValues = { rawDefaultValue, rawMinimumValue, rawMaximumValue };
result.set(resultKey, resultValues);
@@ -425,7 +421,18 @@
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() && variations.isEmpty() && (textRenderingMode == AutoTextRendering) && variantSettings.isAllNormal()
+ bool alwaysAddVariations = false;
+
+ // FIXME: Remove when <rdar://problem/29859207> is fixed
+#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)
+ auto defaultValues = defaultVariationValues(originalFont);
+#if WORKAROUND_CORETEXT_VARIATIONS_UNSPECIFIED_VALUE_BUG
+ alwaysAddVariations = !defaultValues.isEmpty();
+#endif
+#endif
+
+ if (!originalFont || (!features.size() && (!alwaysAddVariations && variations.isEmpty()) && (textRenderingMode == AutoTextRendering) && variantSettings.isAllNormal()
&& (!fontFaceFeatures || !fontFaceFeatures->size()) && (!fontFaceVariantSettings || fontFaceVariantSettings->isAllNormal())))
return originalFont;
@@ -462,27 +469,38 @@
featuresToBeApplied.set(newFeature.tag(), newFeature.value());
#if ENABLE(VARIATION_FONTS)
- auto defaultValues = defaultVariationValues(originalFont);
-
VariationsMap variationsToBeApplied;
- for (auto& newVariation : variations) {
- auto iterator = defaultValues.find(newVariation.tag());
- if (iterator != defaultValues.end()) {
- float valueToApply = std::max(std::min(newVariation.value(), iterator->value.maximumValue), iterator->value.minimumValue);
- // FIXME: Remove when <rdar://problem/28707822> is fixed
+ auto applyVariationValue = [&](const FontTag& tag, float value, bool isDefaultValue) {
+ // FIXME: Remove when <rdar://problem/28707822> is fixed
#define WORKAROUND_CORETEXT_VARIATIONS_DEFAULT_VALUE_BUG (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 110000)
#if WORKAROUND_CORETEXT_VARIATIONS_DEFAULT_VALUE_BUG
- if (valueToApply == iterator->value.defaultValue)
- valueToApply += 0.0001;
+ if (isDefaultValue)
+ value += 0.0001;
#endif
#undef WORKAROUND_CORETEXT_VARIATIONS_DEFAULT_VALUE_BUG
+ variationsToBeApplied.set(tag, value);
+ };
- variationsToBeApplied.set(newVariation.tag(), valueToApply);
- }
+ for (auto& newVariation : variations) {
+ auto iterator = defaultValues.find(newVariation.tag());
+ if (iterator == defaultValues.end())
+ continue;
+ float valueToApply = clampTo(newVariation.value(), iterator->value.minimumValue, iterator->value.maximumValue);
+ bool isDefaultValue = valueToApply == iterator->value.defaultValue;
+ applyVariationValue(newVariation.tag(), valueToApply, isDefaultValue);
}
+
+#if WORKAROUND_CORETEXT_VARIATIONS_UNSPECIFIED_VALUE_BUG
+ for (auto& defaultValue : defaultValues) {
+ if (!variationsToBeApplied.contains(defaultValue.key))
+ applyVariationValue(defaultValue.key, defaultValue.value.defaultValue, true);
+ }
#endif
+#undef WORKAROUND_CORETEXT_VARIATIONS_UNSPECIFIED_VALUE_BUG
+#endif // ENABLE(VARIATION_FONTS)
+
RetainPtr<CFMutableDictionaryRef> attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
if (!featuresToBeApplied.isEmpty()) {
RetainPtr<CFMutableArrayRef> featureArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, features.size(), &kCFTypeArrayCallBacks));