Changeset 245672 in webkit
- Timestamp:
- May 22, 2019 9:18:43 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 12 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r245664 r245672 1 2019-05-22 Myles C. Maxfield <mmaxfield@apple.com> 2 3 font-optical-sizing applies the wrong variation value 4 https://bugs.webkit.org/show_bug.cgi?id=197528 5 <rdar://problem/50152854> 6 7 Reviewed by Antti Koivisto. 8 9 * fast/text/variations/optical-sizing-trak-2-expected-mismatch.html: Added. 10 * fast/text/variations/optical-sizing-trak-2.html: Added. 11 * fast/text/variations/optical-sizing-trak-expected.html: Added. 12 * fast/text/variations/optical-sizing-trak.html: Added. 13 * fast/text/variations/optical-sizing-units-2-expected-mismatch.html: Added. 14 * fast/text/variations/optical-sizing-units-2.html: Added. 15 * fast/text/variations/optical-sizing-units-expected.html: Added. 16 * fast/text/variations/optical-sizing-units.html: Added. 17 * fast/text/variations/resources/Amstelvar/Amstelvar-Roman-VF104.ttf: Added. 18 This font havariations/s been approved by the lawyers to add for layout tests. 19 * fast/text/variations/resources/Amstelvar/COPYRIGHT.md: Added. 20 * fast/text/variations/resources/Amstelvar/OFL.txt: Added. 21 * platform/win/TestExpectations: 22 1 23 2019-05-22 Antti Koivisto <antti@apple.com> 2 24 -
trunk/LayoutTests/platform/win/TestExpectations
r245647 r245672 3251 3251 fast/text/text-combine-shrink-on-color-change.html [ Failure ] 3252 3252 fast/text/trak-optimizeLegibility.html [ Failure ] 3253 fast/text/variations/advances.html [ Failure ] 3254 fast/text/variations/getComputedStyle.html [ Failure ] 3253 fast/text/variations [ Failure Pass ImageOnlyFailure ] 3255 3254 fast/text/whitespace/023.html [ Failure ] 3256 3255 fast/transforms/bounding-rect-zoom.html [ Failure ] … … 3381 3380 fast/text/emoji-single-parent-family-2.html [ ImageOnlyFailure ] 3382 3381 fast/text/emoji-single-parent-family.html [ ImageOnlyFailure ] 3383 fast/text/variations/exist.html [ ImageOnlyFailure ]3384 fast/text/variations/outofbounds.html [ ImageOnlyFailure ]3385 3382 http/tests/security/http-0.9/image-on-HTTP-0.9-default-port-page-allowed-ref-test.html [ ImageOnlyFailure ] 3386 3383 mathml/presentation/non-bmp-operators-stretching.html [ ImageOnlyFailure ] … … 3557 3554 fast/text/softbank-emoji.html [ Failure ] 3558 3555 fast/text/system-font-fallback-emoji.html [ Failure ] 3559 fast/text/variations/font-loading-api-parse-ranges.html [ Failure ]3560 fast/text/variations/optical-sizing.html [ Failure ]3561 3556 fast/text/web-font-load-invisible-during-loading.html [ Failure ] 3562 3557 fast/url/standard-url.html [ Failure ] … … 3624 3619 fast/text/multiple-codeunit-vertical-upright.html [ ImageOnlyFailure ] 3625 3620 fast/text/simple-line-layout-simple-text-but-complex-font-path.html [ ImageOnlyFailure ] 3626 fast/text/variations/font-face-format.html [ ImageOnlyFailure ]3627 fast/text/variations/font-face-format-woff2.html [ ImageOnlyFailure ]3628 3621 imported/blink/scrollbars/avoid-double-scrollbars-when-html-element-is-not-the-renderview.html [ ImageOnlyFailure ] 3629 3622 imported/w3c/i18n/bidi/bidi-plaintext-011.html [ ImageOnlyFailure ] … … 3693 3686 http/wpt/fetch/response-status-text.html [ Failure ] 3694 3687 js/dom/builtin-getter-name.html [ Failure ] 3695 fast/text/variations/font-selection-font-weight.html [ ImageOnlyFailure ]3696 3688 fast/forms/file/entries-api/webkitdirectory-open-panel.html [ Skip ] 3697 3689 … … 3741 3733 # Animated image throttling behaves differently on WK1. 3742 3734 svg/animations/animated-svg-image-outside-viewport-paused.html [ Skip ] 3743 3744 # This test requires Skia, which isn't available on Windows.3745 webkit.org/b/174079 fast/text/variations/skia-postscript-name.html [ ImageOnlyFailure ]3746 3735 3747 3736 # Beacon is not supported on WK1. -
trunk/Source/WTF/ChangeLog
r245647 r245672 1 2019-05-22 Myles C. Maxfield <mmaxfield@apple.com> 2 3 font-optical-sizing applies the wrong variation value 4 https://bugs.webkit.org/show_bug.cgi?id=197528 5 <rdar://problem/50152854> 6 7 Reviewed by Antti Koivisto. 8 9 * wtf/Platform.h: 10 1 11 2019-05-22 Ryan Haddad <ryanhaddad@apple.com> 2 12 -
trunk/Source/WTF/wtf/Platform.h
r245647 r245672 1556 1556 #endif 1557 1557 1558 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 50000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 120000) 1559 #define HAVE_CORETEXT_AUTO_OPTICAL_SIZING 1 1560 #endif 1561 -
trunk/Source/WebCore/ChangeLog
r245664 r245672 1 2019-05-22 Myles C. Maxfield <mmaxfield@apple.com> 2 3 font-optical-sizing applies the wrong variation value 4 https://bugs.webkit.org/show_bug.cgi?id=197528 5 <rdar://problem/50152854> 6 7 Reviewed by Antti Koivisto. 8 9 The OpenType spec says in 10 https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxistag_opsz 11 12 "Scale interpretation: Values can be interpreted as text size, in points." 13 14 It turns out that it means "typographic point size" which is equal to CSS pixels, not 15 CSS points. 16 17 There are two parts of the font that are sensitive to optical sizing: variation values and 18 the trak table. We don't want to set the variation value directly because then the trak table 19 won't be affected. Instead, we can use kCTFontOpticalSizeAttribute to set both of them together. 20 We will only do this when the CSS says text-rendering:optimizeLegibility or when the font has 21 an opsz axis but no STAT table. Otherwise, we won't do anything special, which lets CoreText 22 handle the default behavior for us. This gives us the same default behavior as the rest of the 23 system. 24 25 Tests: fast/text/variations/optical-sizing-trak-2.html 26 fast/text/variations/optical-sizing-trak.html 27 fast/text/variations/optical-sizing-units-2.html 28 fast/text/variations/optical-sizing-units.html 29 30 * platform/graphics/cocoa/FontCacheCoreText.cpp: 31 (WebCore::FontType::FontType): 32 (WebCore::preparePlatformFont): 33 (WebCore::fontWithFamily): 34 (WebCore::FontCache::systemFallbackForCharacters): 35 * platform/graphics/cocoa/FontCacheCoreText.h: 36 * platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp: 37 (WebCore::FontFamilySpecificationCoreText::fontRanges const): 38 * platform/graphics/mac/FontCustomPlatformData.cpp: 39 (WebCore::FontCustomPlatformData::fontPlatformData): 40 1 41 2019-05-22 Antti Koivisto <antti@apple.com> 2 42 -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r245647 r245672 485 485 if (!tables) 486 486 return; 487 bool foundStat = false; 488 bool foundTrak = false; 487 489 auto size = CFArrayGetCount(tables.get()); 488 490 for (CFIndex i = 0; i < size; ++i) { … … 498 500 break; 499 501 case 'STAT': 502 foundStat = true; 500 503 variationType = VariationType::OpenType18; 501 504 break; … … 508 511 openTypeShaping = true; 509 512 break; 513 case 'trak': 514 foundTrak = true; 515 break; 510 516 } 511 517 } 512 }513 514 enum class VariationType {515 NotVariable,516 TrueTypeGX,517 OpenType18 518 };518 if (foundStat && foundTrak) 519 trackingType = TrackingType::Automatic; 520 else if (foundTrak) 521 trackingType = TrackingType::Manual; 522 } 523 524 enum class VariationType : uint8_t { NotVariable, TrueTypeGX, OpenType18, }; 519 525 VariationType variationType { VariationType::NotVariable }; 526 enum class TrackingType : uint8_t { None, Automatic, Manual, }; 527 TrackingType trackingType { TrackingType::None }; 520 528 bool openTypeShaping { false }; 521 529 bool aatShaping { false }; 522 530 }; 523 531 524 RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescription& fontDescription, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, float size, bool applyWeightWidthSlopeVariations) 525 { 526 bool alwaysAddVariations = false; 527 528 // FIXME: Remove when <rdar://problem/29859207> is fixed 532 RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescription& fontDescription, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, bool applyWeightWidthSlopeVariations) 533 { 534 if (!originalFont) 535 return originalFont; 536 537 FontType fontType { originalFont }; 538 539 auto fontOpticalSizing = fontDescription.opticalSizing(); 540 529 541 #if ENABLE(VARIATION_FONTS) 530 542 auto defaultValues = defaultVariationValues(originalFont); 531 alwaysAddVariations = !defaultValues.isEmpty();532 543 533 544 auto fontSelectionRequest = fontDescription.fontSelectionRequest(); 534 auto fontOpticalSizing = fontDescription.opticalSizing();535 545 auto fontStyleAxis = fontDescription.fontStyleAxis(); 546 547 bool forceOpticalSizingOn = fontOpticalSizing == FontOpticalSizing::Enabled && fontType.variationType == FontType::VariationType::TrueTypeGX && defaultValues.contains({{'o', 'p', 's', 'z'}}); 548 bool forceVariations = defaultValues.contains({{'w', 'g', 'h', 't'}}) || defaultValues.contains({{'w', 'd', 't', 'h'}}) || (fontStyleAxis == FontStyleAxis::ital && defaultValues.contains({{'i', 't', 'a', 'l'}})) || (fontStyleAxis == FontStyleAxis::slnt && defaultValues.contains({{'s', 'l', 'n', 't'}})); 549 const auto& variations = fontDescription.variationSettings(); 536 550 #else 537 551 UNUSED_PARAM(fontFaceCapabilities); 538 UNUSED_PARAM(size);539 552 UNUSED_PARAM(applyWeightWidthSlopeVariations); 553 bool forceOpticalSizingOn = false; 540 554 #endif 541 555 542 556 const auto& features = fontDescription.featureSettings(); 543 557 const auto& variantSettings = fontDescription.variantSettings(); 544 const auto& variations = fontDescription.variationSettings();545 558 auto textRenderingMode = fontDescription.textRenderingMode(); 546 559 547 if (!originalFont || (!features.size() && (!alwaysAddVariations && variations.isEmpty()) && (textRenderingMode == TextRenderingMode::AutoTextRendering) && variantSettings.isAllNormal() 548 && (!fontFaceFeatures || !fontFaceFeatures->size()) && (!fontFaceVariantSettings || fontFaceVariantSettings->isAllNormal()))) 560 // We might want to check fontType.trackingType == FontType::TrackingType::Manual here, but in order to maintain compatibility with the rest of the system, we don't. 561 bool noFontFeatureSettings = features.isEmpty(); 562 #if ENABLE(VARIATION_FONTS) 563 bool noFontVariationSettings = !forceVariations && variations.isEmpty(); 564 #else 565 bool noFontVariationSettings = true; 566 #endif 567 bool textRenderingModeIsAuto = textRenderingMode == TextRenderingMode::AutoTextRendering; 568 bool variantSettingsIsNormal = variantSettings.isAllNormal(); 569 bool dontNeedToApplyOpticalSizing = fontOpticalSizing == FontOpticalSizing::Enabled && !forceOpticalSizingOn; 570 bool fontFaceDoesntSpecifyFeatures = !fontFaceFeatures || fontFaceFeatures->isEmpty(); 571 bool fontFaceDoesntSpecifyVariations = !fontFaceVariantSettings || fontFaceVariantSettings->isAllNormal(); 572 if (noFontFeatureSettings && noFontVariationSettings && textRenderingModeIsAuto && variantSettingsIsNormal && dontNeedToApplyOpticalSizing && fontFaceDoesntSpecifyFeatures && fontFaceDoesntSpecifyVariations) 549 573 return originalFont; 550 574 … … 580 604 for (auto& newFeature : features) 581 605 featuresToBeApplied.set(newFeature.tag(), newFeature.value()); 582 583 FontType fontType(originalFont);584 606 585 607 #if ENABLE(VARIATION_FONTS) … … 620 642 } 621 643 622 if (fontOpticalSizing == FontOpticalSizing::Enabled) {623 const float pxToPtRatio = 3.0f / 4;624 applyVariation({{'o', 'p', 's', 'z'}}, size * pxToPtRatio);625 }626 627 644 for (auto& newVariation : variations) 628 645 applyVariation(newVariation.tag(), newVariation.value()); 629 630 646 #endif // ENABLE(VARIATION_FONTS) 631 647 … … 656 672 #endif 657 673 658 if (textRenderingMode == TextRenderingMode::OptimizeLegibility) { 659 CGFloat size = CTFontGetSize(originalFont); 674 if (forceOpticalSizingOn || textRenderingMode == TextRenderingMode::OptimizeLegibility) { 675 #if HAVE(CORETEXT_AUTO_OPTICAL_SIZING) 676 CFDictionaryAddValue(attributes.get(), kCTFontOpticalSizeAttribute, CFSTR("auto")); 677 #else 678 auto size = CTFontGetSize(originalFont); 660 679 auto sizeNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &size)); 661 680 CFDictionaryAddValue(attributes.get(), kCTFontOpticalSizeAttribute, sizeNumber.get()); 662 } 681 #endif 682 } else if (fontOpticalSizing == FontOpticalSizing::Disabled) { 683 #if HAVE(CORETEXT_AUTO_OPTICAL_SIZING) 684 CFDictionaryAddValue(attributes.get(), kCTFontOpticalSizeAttribute, CFSTR("none")); 685 #endif 686 } 687 663 688 auto descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get())); 664 689 auto result = adoptCF(CTFontCreateCopyWithAttributes(originalFont, CTFontGetSize(originalFont), nullptr, descriptor.get())); … … 1224 1249 if (!fontLookup.result) 1225 1250 fontLookup = platformFontLookupWithFamily(family, request, size, fontDescription.shouldAllowUserInstalledFonts()); 1226 return preparePlatformFont(fontLookup.result.get(), fontDescription, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, size,!fontLookup.createdFromPostScriptName);1251 return preparePlatformFont(fontLookup.result.get(), fontDescription, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, !fontLookup.createdFromPostScriptName); 1227 1252 } 1228 1253 … … 1375 1400 1376 1401 auto result = lookupFallbackFont(platformData.font(), description.weight(), description.locale(), characters, length); 1377 result = preparePlatformFont(result.get(), description, nullptr, nullptr, { } , description.computedSize());1402 result = preparePlatformFont(result.get(), description, nullptr, nullptr, { }); 1378 1403 1379 1404 if (!result) -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h
r245647 r245672 51 51 }; 52 52 53 RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, const FontDescription&, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, float size,bool applyWeightWidthSlopeVariations = true);53 RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, const FontDescription&, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, bool applyWeightWidthSlopeVariations = true); 54 54 SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&, bool isPlatformFont = false); 55 55 RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomicString& family, FontSelectionRequest, float size, AllowUserInstalledFonts); -
trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp
r245647 r245672 109 109 #endif 110 110 111 font = preparePlatformFont(font.get(), fontDescription, nullptr, nullptr, { } , fontDescription.computedSize());111 font = preparePlatformFont(font.get(), fontDescription, nullptr, nullptr, { }); 112 112 113 113 bool syntheticBold, syntheticOblique; -
trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
r245647 r245672 47 47 FontWidthVariant widthVariant = fontDescription.widthVariant(); 48 48 RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(modifiedFontDescriptor.get(), size, nullptr)); 49 font = preparePlatformFont(font.get(), fontDescription, &fontFaceFeatures, &fontFaceVariantSettings, fontFaceCapabilities , fontDescription.computedSize());49 font = preparePlatformFont(font.get(), fontDescription, &fontFaceFeatures, &fontFaceVariantSettings, fontFaceCapabilities); 50 50 ASSERT(font); 51 51 return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant, fontDescription.textRenderingMode());
Note: See TracChangeset
for help on using the changeset viewer.