Unreviewed, rolling out r245598.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 May 2019 21:39:11 +0000 (21:39 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 May 2019 21:39:11 +0000 (21:39 +0000)
Breaks watchOS build.

Reverted changeset:

"font-optical-sizing applies the wrong variation value"
https://bugs.webkit.org/show_bug.cgi?id=197528
https://trac.webkit.org/changeset/245598

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245647 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/variations/optical-sizing-trak-2-expected-mismatch.html [deleted file]
LayoutTests/fast/text/variations/optical-sizing-trak-2.html [deleted file]
LayoutTests/fast/text/variations/optical-sizing-trak-expected.html [deleted file]
LayoutTests/fast/text/variations/optical-sizing-trak.html [deleted file]
LayoutTests/fast/text/variations/optical-sizing-units-2-expected-mismatch.html [deleted file]
LayoutTests/fast/text/variations/optical-sizing-units-2.html [deleted file]
LayoutTests/fast/text/variations/optical-sizing-units-expected.html [deleted file]
LayoutTests/fast/text/variations/optical-sizing-units.html [deleted file]
LayoutTests/fast/text/variations/resources/Amstelvar/Amstelvar-Roman-VF104.ttf [deleted file]
LayoutTests/fast/text/variations/resources/Amstelvar/COPYRIGHT.md [deleted file]
LayoutTests/fast/text/variations/resources/Amstelvar/OFL.txt [deleted file]
LayoutTests/platform/win/TestExpectations
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h
Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp
Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp

index 3bea4c3..a5dab5e 100644 (file)
@@ -1,3 +1,15 @@
+2019-05-22  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r245598.
+
+        Breaks watchOS build.
+
+        Reverted changeset:
+
+        "font-optical-sizing applies the wrong variation value"
+        https://bugs.webkit.org/show_bug.cgi?id=197528
+        https://trac.webkit.org/changeset/245598
+
 2019-05-22  Antoine Quint  <graouts@apple.com>
 
         [iOS] Compatibility mouse events aren't prevented by calling preventDefault() on pointerdown
diff --git a/LayoutTests/fast/text/variations/optical-sizing-trak-2-expected-mismatch.html b/LayoutTests/fast/text/variations/optical-sizing-trak-2-expected-mismatch.html
deleted file mode 100644 (file)
index 6bbe169..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<style>
-#target {
-    display: inline-block;
-    font: 10px "PingFang SC";
-    transform: scale(10);
-    transform-origin: left top;
-    text-rendering: optimizeLegibility;
-}
-</style>
-</head>
-<body>
-<span id="target">风雨中中国经济定能壮大</span>
-</body>
-</html>
diff --git a/LayoutTests/fast/text/variations/optical-sizing-trak-2.html b/LayoutTests/fast/text/variations/optical-sizing-trak-2.html
deleted file mode 100644 (file)
index c34bbbd..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<style>
-#target {
-    display: inline-block;
-    font: 10px "PingFang SC";
-    transform: scale(10);
-    transform-origin: left top;
-}
-</style>
-</head>
-<body>
-<span id="target">风雨中中国经济定能壮大</span>
-</body>
-</html>
diff --git a/LayoutTests/fast/text/variations/optical-sizing-trak-expected.html b/LayoutTests/fast/text/variations/optical-sizing-trak-expected.html
deleted file mode 100644 (file)
index cfa419f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<style>
-#target {
-    display: inline-block;
-    font: 10px "PingFang SC";
-    transform: scale(10);
-    transform-origin: left top;
-    font-optical-sizing: none;
-}
-</style>
-</head>
-<body>
-<p>
-This test makes sure that 'trak' tables are not honored in fonts that don't have 'STAT' tables. The test passes if the text is rendered identically to the expected file, pixel-per-pixel.
-</p>
-<span id="target">风雨中中国经济定能壮大</span>
-</body>
-</html>
diff --git a/LayoutTests/fast/text/variations/optical-sizing-trak.html b/LayoutTests/fast/text/variations/optical-sizing-trak.html
deleted file mode 100644 (file)
index d1ec6af..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<style>
-#target {
-    display: inline-block;
-    font: 10px "PingFang SC";
-    transform: scale(10);
-    transform-origin: left top;
-    font-optical-sizing: auto;
-}
-</style>
-</head>
-<body>
-<p>
-This test makes sure that 'trak' tables are not honored in fonts that don't have 'STAT' tables. The test passes if the text is rendered identically to the expected file, pixel-per-pixel.
-</p>
-<span id="target">风雨中中国经济定能壮大</span>
-</body>
-</html>
diff --git a/LayoutTests/fast/text/variations/optical-sizing-units-2-expected-mismatch.html b/LayoutTests/fast/text/variations/optical-sizing-units-2-expected-mismatch.html
deleted file mode 100644 (file)
index 34f8e6f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<style>
-@font-face {
-    font-family: "Amstelvar";
-    src: url("resources/Amstelvar/Amstelvar-Roman-VF104.ttf") format("truetype");
-}
-#target {
-    font: 100px "Amstelvar";
-    font-optical-sizing: auto;
-    font-variation-settings: "opsz" 10;
-}
-</style>
-</head>
-<body>
-<span id="target">Hello, world!</span>
-</body>
-</html>
diff --git a/LayoutTests/fast/text/variations/optical-sizing-units-2.html b/LayoutTests/fast/text/variations/optical-sizing-units-2.html
deleted file mode 100644 (file)
index 89d0bbc..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<style>
-@font-face {
-    font-family: "Amstelvar";
-    src: url("resources/Amstelvar/Amstelvar-Roman-VF104.ttf") format("truetype");
-}
-#target {
-    font: 100px "Amstelvar";
-    font-optical-sizing: auto;
-}
-</style>
-</head>
-<body>
-<span id="target">Hello, world!</span>
-</body>
-</html>
diff --git a/LayoutTests/fast/text/variations/optical-sizing-units-expected.html b/LayoutTests/fast/text/variations/optical-sizing-units-expected.html
deleted file mode 100644 (file)
index 9cca906..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<style>
-@font-face {
-    font-family: "Amstelvar";
-    src: url("resources/Amstelvar/Amstelvar-Roman-VF104.ttf") format("truetype");
-}
-#target {
-    display: inline-block;
-    font: 10px "Amstelvar";
-    transform: scale(10);
-    transform-origin: left top;
-    font-variation-settings: "opsz" 10;
-}
-</style>
-</head>
-<body>
-<p>This test makes sure that <code>font-optical-sizing: auto</code> applies the correct value to the <code>opsz</code> variation axis. The test passes if the text below matches the expected text, pixel-per-pixel.</p>
-<span id="target">Hello, world!</span>
-</body>
-</html>
diff --git a/LayoutTests/fast/text/variations/optical-sizing-units.html b/LayoutTests/fast/text/variations/optical-sizing-units.html
deleted file mode 100644 (file)
index feadc3c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<style>
-@font-face {
-    font-family: "Amstelvar";
-    src: url("resources/Amstelvar/Amstelvar-Roman-VF104.ttf") format("truetype");
-}
-#target {
-    display: inline-block;
-    font: 10px "Amstelvar";
-    transform: scale(10);
-    transform-origin: left top;
-    font-optical-sizing: auto;
-}
-</style>
-</head>
-<body>
-<p>This test makes sure that <code>font-optical-sizing: auto</code> applies the correct value to the <code>opsz</code> variation axis. The test passes if the text below matches the expected text, pixel-per-pixel.</p>
-<span id="target">Hello, world!</span>
-</body>
-</html>
diff --git a/LayoutTests/fast/text/variations/resources/Amstelvar/Amstelvar-Roman-VF104.ttf b/LayoutTests/fast/text/variations/resources/Amstelvar/Amstelvar-Roman-VF104.ttf
deleted file mode 100644 (file)
index 23c15c5..0000000
Binary files a/LayoutTests/fast/text/variations/resources/Amstelvar/Amstelvar-Roman-VF104.ttf and /dev/null differ
diff --git a/LayoutTests/fast/text/variations/resources/Amstelvar/COPYRIGHT.md b/LayoutTests/fast/text/variations/resources/Amstelvar/COPYRIGHT.md
deleted file mode 100644 (file)
index 819ec2f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Copyright 2016 The Amstelvar Project Authors (info@fontbureau.com)
diff --git a/LayoutTests/fast/text/variations/resources/Amstelvar/OFL.txt b/LayoutTests/fast/text/variations/resources/Amstelvar/OFL.txt
deleted file mode 100644 (file)
index 1e98121..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-Copyright 2016 The Amstelvar Project Authors (info@fontbureau.com)
-
-This Font Software is licensed under the SIL Open Font License, Version 1.1.
-This license is copied below, and is also available with a FAQ at:
-http://scripts.sil.org/OFL
-
-
------------------------------------------------------------
-SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
------------------------------------------------------------
-
-PREAMBLE
-The goals of the Open Font License (OFL) are to stimulate worldwide
-development of collaborative font projects, to support the font creation
-efforts of academic and linguistic communities, and to provide a free and
-open framework in which fonts may be shared and improved in partnership
-with others.
-
-The OFL allows the licensed fonts to be used, studied, modified and
-redistributed freely as long as they are not sold by themselves. The
-fonts, including any derivative works, can be bundled, embedded, 
-redistributed and/or sold with any software provided that any reserved
-names are not used by derivative works. The fonts and derivatives,
-however, cannot be released under any other type of license. The
-requirement for fonts to remain under this license does not apply
-to any document created using the fonts or their derivatives.
-
-DEFINITIONS
-"Font Software" refers to the set of files released by the Copyright
-Holder(s) under this license and clearly marked as such. This may
-include source files, build scripts and documentation.
-
-"Reserved Font Name" refers to any names specified as such after the
-copyright statement(s).
-
-"Original Version" refers to the collection of Font Software components as
-distributed by the Copyright Holder(s).
-
-"Modified Version" refers to any derivative made by adding to, deleting,
-or substituting -- in part or in whole -- any of the components of the
-Original Version, by changing formats or by porting the Font Software to a
-new environment.
-
-"Author" refers to any designer, engineer, programmer, technical
-writer or other person who contributed to the Font Software.
-
-PERMISSION & CONDITIONS
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of the Font Software, to use, study, copy, merge, embed, modify,
-redistribute, and sell modified and unmodified copies of the Font
-Software, subject to the following conditions:
-
-1) Neither the Font Software nor any of its individual components,
-in Original or Modified Versions, may be sold by itself.
-
-2) Original or Modified Versions of the Font Software may be bundled,
-redistributed and/or sold with any software, provided that each copy
-contains the above copyright notice and this license. These can be
-included either as stand-alone text files, human-readable headers or
-in the appropriate machine-readable metadata fields within text or
-binary files as long as those fields can be easily viewed by the user.
-
-3) No Modified Version of the Font Software may use the Reserved Font
-Name(s) unless explicit written permission is granted by the corresponding
-Copyright Holder. This restriction only applies to the primary font name as
-presented to the users.
-
-4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
-Software shall not be used to promote, endorse or advertise any
-Modified Version, except to acknowledge the contribution(s) of the
-Copyright Holder(s) and the Author(s) or with their explicit written
-permission.
-
-5) The Font Software, modified or unmodified, in part or in whole,
-must be distributed entirely under this license, and must not be
-distributed under any other license. The requirement for fonts to
-remain under this license does not apply to any document created
-using the Font Software.
-
-TERMINATION
-This license becomes null and void if any of the above conditions are
-not met.
-
-DISCLAIMER
-THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
-OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
-COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
-DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
-OTHER DEALINGS IN THE FONT SOFTWARE.
index 96c6d8c..5fe843c 100644 (file)
@@ -3250,7 +3250,8 @@ fast/text/system-font-weight-italic.html [ Failure ]
 fast/text/system-font-weight.html [ Failure ]
 fast/text/text-combine-shrink-on-color-change.html [ Failure ]
 fast/text/trak-optimizeLegibility.html [ Failure ]
-fast/text/variations [ Failure Pass ImageOnlyFailure ]
+fast/text/variations/advances.html [ Failure ]
+fast/text/variations/getComputedStyle.html [ Failure ]
 fast/text/whitespace/023.html [ Failure ]
 fast/transforms/bounding-rect-zoom.html [ Failure ]
 fast/xsl/xslt-extra-content-at-end.xml [ Failure ]
@@ -3379,6 +3380,8 @@ fast/text/complex-small-caps-non-bmp-capitalize.html [ ImageOnlyFailure ]
 fast/text/cursive-zh.html [ ImageOnlyFailure ]
 fast/text/emoji-single-parent-family-2.html [ ImageOnlyFailure ]
 fast/text/emoji-single-parent-family.html [ ImageOnlyFailure ]
+fast/text/variations/exist.html [ ImageOnlyFailure ]
+fast/text/variations/outofbounds.html [ ImageOnlyFailure ]
 http/tests/security/http-0.9/image-on-HTTP-0.9-default-port-page-allowed-ref-test.html [ ImageOnlyFailure ]
 mathml/presentation/non-bmp-operators-stretching.html [ ImageOnlyFailure ]
 security/contentSecurityPolicy/image-with-blob-url-allowed-by-img-src-star-with-AllowContentSecurityPolicySourceStarToMatchAnyProtocol-enabled.html [ ImageOnlyFailure ]
@@ -3553,6 +3556,8 @@ fast/text/font-style-parse.html [ Failure ]
 fast/text/font-weight-parse.html [ Failure ]
 fast/text/softbank-emoji.html [ Failure ]
 fast/text/system-font-fallback-emoji.html [ Failure ]
+fast/text/variations/font-loading-api-parse-ranges.html [ Failure ]
+fast/text/variations/optical-sizing.html [ Failure ]
 fast/text/web-font-load-invisible-during-loading.html [ Failure ]
 fast/url/standard-url.html [ Failure ]
 fast/url/tab-and-newline-stripping.html [ Failure ]
@@ -3618,6 +3623,8 @@ fast/text/accessibility-bold-system-font-2.html [ ImageOnlyFailure ]
 fast/text/emoji-overlap.html [ ImageOnlyFailure ]
 fast/text/multiple-codeunit-vertical-upright.html [ ImageOnlyFailure ]
 fast/text/simple-line-layout-simple-text-but-complex-font-path.html [ ImageOnlyFailure ]
+fast/text/variations/font-face-format.html [ ImageOnlyFailure ]
+fast/text/variations/font-face-format-woff2.html [ ImageOnlyFailure ]
 imported/blink/scrollbars/avoid-double-scrollbars-when-html-element-is-not-the-renderview.html [ ImageOnlyFailure ]
 imported/w3c/i18n/bidi/bidi-plaintext-011.html [ ImageOnlyFailure ]
 svg/custom/anchor-on-use.svg [ ImageOnlyFailure ]
@@ -3685,6 +3692,7 @@ http/tests/security/contentSecurityPolicy/allow-favicon.html [ Failure ]
 http/wpt/entries-api/interfaces.html [ Failure ]
 http/wpt/fetch/response-status-text.html [ Failure ]
 js/dom/builtin-getter-name.html [ Failure ]
+fast/text/variations/font-selection-font-weight.html [ ImageOnlyFailure ]
 fast/forms/file/entries-api/webkitdirectory-open-panel.html [ Skip ]
 
 # Requires WK2 loading support
@@ -3733,6 +3741,9 @@ imported/w3c/web-platform-tests/wasm/wasm_stream_compile_test.html  [ Skip ]
 # Animated image throttling behaves differently on WK1.
 svg/animations/animated-svg-image-outside-viewport-paused.html [ Skip ]
 
+# This test requires Skia, which isn't available on Windows.
+webkit.org/b/174079 fast/text/variations/skia-postscript-name.html [ ImageOnlyFailure ]
+
 # Beacon is not supported on WK1.
 http/tests/blink/sendbeacon/ [ Skip ]
 http/tests/inspector/network/beacon-type.html [ Skip ]
index 278ebc0..1e771f3 100644 (file)
@@ -1,3 +1,15 @@
+2019-05-22  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r245598.
+
+        Breaks watchOS build.
+
+        Reverted changeset:
+
+        "font-optical-sizing applies the wrong variation value"
+        https://bugs.webkit.org/show_bug.cgi?id=197528
+        https://trac.webkit.org/changeset/245598
+
 2019-05-21  Ross Kirsling  <ross.kirsling@sony.com>
 
         [PlayStation] Don't call fcntl.
index 447bb18..9973a4d 100644 (file)
 #define HAVE_AVPLAYER_RESOURCE_CONSERVATION_LEVEL 1
 #endif
 
-#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)
-#define HAVE_CORETEXT_AUTO_OPTICAL_SIZING 1
-#endif
-
index 387beae..9d5dd9d 100644 (file)
@@ -1,3 +1,15 @@
+2019-05-22  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r245598.
+
+        Breaks watchOS build.
+
+        Reverted changeset:
+
+        "font-optical-sizing applies the wrong variation value"
+        https://bugs.webkit.org/show_bug.cgi?id=197528
+        https://trac.webkit.org/changeset/245598
+
 2019-05-22  Daniel Bates  <dabates@apple.com>
 
         WebKit does not generate an ESC key event for CMD+.
index 5037762..5f68b83 100644 (file)
@@ -484,8 +484,6 @@ struct FontType {
         auto tables = adoptCF(CTFontCopyAvailableTables(font, kCTFontTableOptionNoOptions));
         if (!tables)
             return;
-        bool foundStat = false;
-        bool foundTrak = false;
         auto size = CFArrayGetCount(tables.get());
         for (CFIndex i = 0; i < size; ++i) {
             // This is so yucky.
@@ -499,7 +497,6 @@ struct FontType {
                     variationType = VariationType::TrueTypeGX;
                 break;
             case 'STAT':
-                foundStat = true;
                 variationType = VariationType::OpenType18;
                 break;
             case 'morx':
@@ -510,38 +507,35 @@ struct FontType {
             case 'GSUB':
                 openTypeShaping = true;
                 break;
-            case 'trak':
-                foundTrak = true;
-                break;
             }
         }
-        if (foundStat && foundTrak)
-            trackingType = TrackingType::Automatic;
-        else if (foundTrak)
-            trackingType = TrackingType::Manual;
     }
 
-    enum class VariationType : uint8_t { NotVariable, TrueTypeGX, OpenType18, };
+    enum class VariationType {
+        NotVariable,
+        TrueTypeGX,
+        OpenType18
+    };
     VariationType variationType { VariationType::NotVariable };
-    enum class TrackingType : uint8_t { None, Automatic, Manual, };
-    TrackingType trackingType { TrackingType::None };
     bool openTypeShaping { false };
     bool aatShaping { false };
 };
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescription& fontDescription, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, bool applyWeightWidthSlopeVariations)
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescription& fontDescription, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, float size, bool applyWeightWidthSlopeVariations)
 {
-    if (!originalFont)
-        return originalFont;
+    bool alwaysAddVariations = false;
 
+    // FIXME: Remove when <rdar://problem/29859207> is fixed
 #if ENABLE(VARIATION_FONTS)
     auto defaultValues = defaultVariationValues(originalFont);
+    alwaysAddVariations = !defaultValues.isEmpty();
 
     auto fontSelectionRequest = fontDescription.fontSelectionRequest();
     auto fontOpticalSizing = fontDescription.opticalSizing();
     auto fontStyleAxis = fontDescription.fontStyleAxis();
 #else
     UNUSED_PARAM(fontFaceCapabilities);
+    UNUSED_PARAM(size);
     UNUSED_PARAM(applyWeightWidthSlopeVariations);
 #endif
 
@@ -550,20 +544,8 @@ RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescr
     const auto& variations = fontDescription.variationSettings();
     auto textRenderingMode = fontDescription.textRenderingMode();
 
-    FontType fontType { originalFont };
-
-    bool forceOpticalSizingOn = fontOpticalSizing == FontOpticalSizing::Enabled && fontType.variationType == FontType::VariationType::TrueTypeGX && defaultValues.contains({{'o', 'p', 's', 'z'}});
-    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'}}));
-
-    // 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.
-    bool noFontFeatureSettings = features.isEmpty();
-    bool noFontVariationSettings = !forceVariations && variations.isEmpty();
-    bool textRenderingModeIsAuto = textRenderingMode == TextRenderingMode::AutoTextRendering;
-    bool variantSettingsIsNormal = variantSettings.isAllNormal();
-    bool dontNeedToApplyOpticalSizing = fontOpticalSizing == FontOpticalSizing::Enabled && !forceOpticalSizingOn;
-    bool fontFaceDoesntSpecifyFeatures = !fontFaceFeatures || fontFaceFeatures->isEmpty();
-    bool fontFaceDoesntSpecifyVariations = !fontFaceVariantSettings || fontFaceVariantSettings->isAllNormal();
-    if (noFontFeatureSettings && noFontVariationSettings && textRenderingModeIsAuto && variantSettingsIsNormal && dontNeedToApplyOpticalSizing && fontFaceDoesntSpecifyFeatures && fontFaceDoesntSpecifyVariations)
+    if (!originalFont || (!features.size() && (!alwaysAddVariations && variations.isEmpty()) && (textRenderingMode == TextRenderingMode::AutoTextRendering) && variantSettings.isAllNormal()
+        && (!fontFaceFeatures || !fontFaceFeatures->size()) && (!fontFaceVariantSettings || fontFaceVariantSettings->isAllNormal())))
         return originalFont;
 
     // This algorithm is described at http://www.w3.org/TR/css3-fonts/#feature-precedence
@@ -598,6 +580,8 @@ RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescr
     for (auto& newFeature : features)
         featuresToBeApplied.set(newFeature.tag(), newFeature.value());
 
+    FontType fontType(originalFont);
+
 #if ENABLE(VARIATION_FONTS)
     VariationsMap variationsToBeApplied;
 
@@ -635,8 +619,14 @@ RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescr
             applyVariation({{'s', 'l', 'n', 't'}}, slope);
     }
 
+    if (fontOpticalSizing == FontOpticalSizing::Enabled) {
+        const float pxToPtRatio = 3.0f / 4;
+        applyVariation({{'o', 'p', 's', 'z'}}, size * pxToPtRatio);
+    }
+
     for (auto& newVariation : variations)
         applyVariation(newVariation.tag(), newVariation.value());
+
 #endif // ENABLE(VARIATION_FONTS)
 
     auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
@@ -665,20 +655,11 @@ RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescr
     }
 #endif
 
-    if (forceOpticalSizingOn || textRenderingMode == TextRenderingMode::OptimizeLegibility) {
-#if HAVE(CORETEXT_AUTO_OPTICAL_SIZING)
-        CFDictionaryAddValue(attributes.get(), kCTFontOpticalSizeAttribute, CFSTR("auto"));
-#else
-        auto size = CTFontGetSize(originalFont);
+    if (textRenderingMode == TextRenderingMode::OptimizeLegibility) {
+        CGFloat size = CTFontGetSize(originalFont);
         auto sizeNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &size));
         CFDictionaryAddValue(attributes.get(), kCTFontOpticalSizeAttribute, sizeNumber.get());
-#endif
-    } else if (fontOpticalSizing == FontOpticalSizing::Disabled) {
-#if HAVE(CORETEXT_AUTO_OPTICAL_SIZING)
-        CFDictionaryAddValue(attributes.get(), kCTFontOpticalSizeAttribute, CFSTR("none"));
-#endif
     }
-
     auto descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
     auto result = adoptCF(CTFontCreateCopyWithAttributes(originalFont, CTFontGetSize(originalFont), nullptr, descriptor.get()));
     return result;
@@ -1242,7 +1223,7 @@ static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, const Fon
     fontLookup.result = platformFontWithFamilySpecialCase(family, request, size, fontDescription.shouldAllowUserInstalledFonts());
     if (!fontLookup.result)
         fontLookup = platformFontLookupWithFamily(family, request, size, fontDescription.shouldAllowUserInstalledFonts());
-    return preparePlatformFont(fontLookup.result.get(), fontDescription, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, !fontLookup.createdFromPostScriptName);
+    return preparePlatformFont(fontLookup.result.get(), fontDescription, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, size, !fontLookup.createdFromPostScriptName);
 }
 
 #if PLATFORM(MAC)
@@ -1393,7 +1374,7 @@ RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& descr
         m_fontNamesRequiringSystemFallbackForPrewarming.add(fullName);
 
     auto result = lookupFallbackFont(platformData.font(), description.weight(), description.locale(), characters, length);
-    result = preparePlatformFont(result.get(), description, nullptr, nullptr, { });
+    result = preparePlatformFont(result.get(), description, nullptr, nullptr, { }, description.computedSize());
 
     if (!result)
         return lastResortFallbackFont(description);
index d11db98..5cf6cd2 100644 (file)
@@ -50,7 +50,7 @@ struct SynthesisPair {
     bool needsSyntheticOblique;
 };
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, const FontDescription&, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, bool applyWeightWidthSlopeVariations = true);
+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, AllowUserInstalledFonts);
 RetainPtr<CTFontRef> platformFontWithFamily(const AtomicString& family, FontSelectionRequest, TextRenderingMode, float size);
index c8911c4..b749cda 100644 (file)
@@ -108,7 +108,7 @@ FontRanges FontFamilySpecificationCoreText::fontRanges(const FontDescription& fo
             fontForSynthesisComputation = physicalFont;
 #endif
 
-        font = preparePlatformFont(font.get(), fontDescription, nullptr, nullptr, { });
+        font = preparePlatformFont(font.get(), fontDescription, nullptr, nullptr, { }, fontDescription.computedSize());
 
         bool syntheticBold, syntheticOblique;
         std::tie(syntheticBold, syntheticOblique) = computeNecessarySynthesis(fontForSynthesisComputation.get(), fontDescription).boldObliquePair();
index 3d5ef09..8c19a7f 100644 (file)
@@ -46,7 +46,7 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription&
     FontOrientation orientation = fontDescription.orientation();
     FontWidthVariant widthVariant = fontDescription.widthVariant();
     RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(modifiedFontDescriptor.get(), size, nullptr));
-    font = preparePlatformFont(font.get(), fontDescription, &fontFaceFeatures, &fontFaceVariantSettings, fontFaceCapabilities);
+    font = preparePlatformFont(font.get(), fontDescription, &fontFaceFeatures, &fontFaceVariantSettings, fontFaceCapabilities, fontDescription.computedSize());
     ASSERT(font);
     return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant, fontDescription.textRenderingMode());
 }