Turn off antialiasing when rendering with Ahem, for testing
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Nov 2019 20:33:39 +0000 (20:33 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Nov 2019 20:33:39 +0000 (20:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=204197
Source/WebCore:

<rdar://problem/57190712>

Reviewed by Myles C. Maxfield.

If the font family name matches "Ahem", turn off antialiasing when rendering text,
because many CSS tests assume that Ahem glyphs can be compared with positioned elements
in ref tests.

Since Ahem is a font only used for testing, I don't think this behavior needs to be
controlled by a setting.

* platform/graphics/Font.cpp:
(WebCore::Font::Font):
* platform/graphics/Font.h:
(WebCore::Font::allowsAntialiasing const):
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::FontCascade::drawGlyphs):
* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::isAhemFont):
(WebCore::Font::platformInit):

LayoutTests:

Reviewed by Myles C. Maxfield.

* TestExpectations:

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

LayoutTests/ChangeLog
LayoutTests/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/Font.h
Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm
Source/WebCore/platform/graphics/cocoa/FontCocoa.mm

index 07b5cd3..97c29ee 100644 (file)
@@ -1,3 +1,12 @@
+2019-11-20  Simon Fraser  <simon.fraser@apple.com>
+
+        Turn off antialiasing when rendering with Ahem, for testing
+        https://bugs.webkit.org/show_bug.cgi?id=204197
+
+        Reviewed by Myles C. Maxfield.
+
+        * TestExpectations:
+
 2019-11-20  Per Arne Vollan  <pvollan@apple.com>
 
         Layout Test fast/text/font-antialiasing-save-restore.html is failing
index d477d58..6fddfb5 100644 (file)
@@ -1873,10 +1873,6 @@ imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-child-002.xht
 imported/w3c/web-platform-tests/css/css-multicol/columnfill-auto-max-height-001.html
 imported/w3c/web-platform-tests/css/css-multicol/columnfill-auto-max-height-002.html
 imported/w3c/web-platform-tests/css/css-multicol/large-actual-column-count.html
-imported/w3c/web-platform-tests/css/css-multicol/multicol-basic-001.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-multicol/multicol-basic-002.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-multicol/multicol-basic-003.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-multicol/multicol-basic-004.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-multicol/multicol-breaking-000.html
 imported/w3c/web-platform-tests/css/css-multicol/multicol-breaking-001.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-multicol/multicol-breaking-002.html [ ImageOnlyFailure ]
@@ -1901,21 +1897,14 @@ imported/w3c/web-platform-tests/css/css-multicol/multicol-nested-margin-002.xht
 imported/w3c/web-platform-tests/css/css-multicol/multicol-nested-margin-003.xht [ ImageOnlyFailure ] 
 imported/w3c/web-platform-tests/css/css-multicol/multicol-nested-margin-004.xht [ ImageOnlyFailure ] 
 imported/w3c/web-platform-tests/css/css-multicol/multicol-nested-margin-005.xht [ ImageOnlyFailure ] 
-imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-002.xht [ ImageOnlyFailure ]
 webkit.org/b/148816 imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-004.xht [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-color-inherit-002.xht [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-fraction-003.xht [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-nested-balancing-001.html
 imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-nested-balancing-002.html
 imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-nested-balancing-003.html
 imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-nested-balancing-004.html
-imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-px-001.xht [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-shorthand-2.xht [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-stacking-001.xht [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-multicol/multicol-shorthand-001.xht [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-004.html
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-010.html
-imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-block-sibling-003.xht [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-button-001.html
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-button-002.html
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-button-003.html
@@ -1923,13 +1912,10 @@ imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-child-001.xht
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-children-height-005.html
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-children-height-008.html
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-margin-002.xht [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-margin-bottom-001.xht [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-margin-nested-001.xht [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-margin-nested-002.xht [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-margin-nested-003.xht [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-margin-nested-firstchild-001.xht [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-multicol/multicol-span-all-rule-001.html
-imported/w3c/web-platform-tests/css/css-multicol/multicol-span-none-001.xht [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-multicol/multicol-under-vertical-rl-scroll.html
 imported/w3c/web-platform-tests/css/css-multicol/multicol-width-004.html
 imported/w3c/web-platform-tests/css/css-multicol/multicol-width-005.html
@@ -2299,26 +2285,6 @@ webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/line-breaking/l
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/line-breaking/line-breaking-011.html [ ImageOnlyFailure ]
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/line-breaking/line-breaking-ic-002.html [ ImageOnlyFailure ]
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/line-breaking/line-breaking-ic-003.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-001.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-002.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-003.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-004.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-005.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-006.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-007.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-008.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-009.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-010.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-014.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-015.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-016.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-end-017.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justify-001.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justify-002.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justify-003.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justify-004.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justify-005.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justify-006.html [ ImageOnlyFailure ]
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justifyall-001.html [ ImageOnlyFailure ]
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justifyall-002.html [ ImageOnlyFailure ]
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justifyall-003.html [ ImageOnlyFailure ]
@@ -2327,20 +2293,6 @@ webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-justifyall-006.html [ ImageOnlyFailure ]
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last-010.html [ ImageOnlyFailure ]
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last-011.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-001.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-002.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-003.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-004.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-005.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-006.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-007.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-008.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-009.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-010.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-014.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-015.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-016.html [ ImageOnlyFailure ]
-webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-align/text-align-start-017.html [ ImageOnlyFailure ]
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-indent/text-indent-percentage-001.xht [ ImageOnlyFailure ]
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-justify/text-justify-001.html [ ImageOnlyFailure ]
 webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/text-transform/text-transform-capitalize-018.html [ ImageOnlyFailure Pass ]
index de30d9c..e71f5c6 100644 (file)
@@ -1,3 +1,28 @@
+2019-11-20  Simon Fraser  <simon.fraser@apple.com>
+
+        Turn off antialiasing when rendering with Ahem, for testing
+        https://bugs.webkit.org/show_bug.cgi?id=204197
+        <rdar://problem/57190712>
+
+        Reviewed by Myles C. Maxfield.
+
+        If the font family name matches "Ahem", turn off antialiasing when rendering text,
+        because many CSS tests assume that Ahem glyphs can be compared with positioned elements
+        in ref tests.
+
+        Since Ahem is a font only used for testing, I don't think this behavior needs to be
+        controlled by a setting.
+
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::Font):
+        * platform/graphics/Font.h:
+        (WebCore::Font::allowsAntialiasing const):
+        * platform/graphics/cocoa/FontCascadeCocoa.mm:
+        (WebCore::FontCascade::drawGlyphs):
+        * platform/graphics/cocoa/FontCocoa.mm:
+        (WebCore::isAhemFont):
+        (WebCore::Font::platformInit):
+
 2019-11-20  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][IFC] Cache InlinteTextItem width when possible
index 84088fe..68d3972 100644 (file)
@@ -62,6 +62,7 @@ Font::Font(const FontPlatformData& platformData, Origin origin, Interstitial int
     , m_isBrokenIdeographFallback(false)
     , m_hasVerticalGlyphs(false)
     , m_isUsedInSystemFallbackCache(false)
+    , m_allowsAntialiasing(true)
 #if PLATFORM(IOS_FAMILY)
     , m_shouldNotBeUsedForArabic(false)
 #endif
index 9f40b31..677617a 100644 (file)
@@ -183,6 +183,7 @@ public:
     Origin origin() const { return m_origin; }
     bool isInterstitial() const { return m_isInterstitial; }
     Visibility visibility() const { return m_visibility; }
+    bool allowsAntialiasing() const { return m_allowsAntialiasing; }
 
 #if !LOG_DISABLED
     String description() const;
@@ -310,6 +311,8 @@ private:
     unsigned m_hasVerticalGlyphs : 1;
 
     unsigned m_isUsedInSystemFallbackCache : 1;
+    
+    unsigned m_allowsAntialiasing : 1;
 
 #if PLATFORM(IOS_FAMILY)
     unsigned m_shouldNotBeUsedForArabic : 1;
index 7ca82f4..a5f18a2 100644 (file)
@@ -209,6 +209,9 @@ void FontCascade::drawGlyphs(GraphicsContext& context, const Font& font, const G
     bool shouldAntialias = true;
     bool shouldSmoothFonts = true;
     
+    if (!font.allowsAntialiasing())
+        smoothingMode = FontSmoothingMode::NoSmoothing;
+
     switch (smoothingMode) {
     case FontSmoothingMode::Antialiased:
         shouldSmoothFonts = false;
index 7007af4..de9a170 100644 (file)
@@ -113,6 +113,11 @@ static bool needsAscentAdjustment(CFStringRef familyName)
 
 #endif
 
+static bool isAhemFont(CFStringRef familyName)
+{
+    return familyName && caseInsensitiveCompare(familyName, CFSTR("Ahem"));
+}
+
 void Font::platformInit()
 {
 #if PLATFORM(IOS_FAMILY)
@@ -141,6 +146,11 @@ void Font::platformInit()
     }
 
     auto familyName = adoptCF(CTFontCopyFamilyName(m_platformData.font()));
+
+    // Disable antialiasing when rendering with Ahem because many tests require this.
+    if (isAhemFont(familyName.get()))
+        m_allowsAntialiasing = false;
+
 #if PLATFORM(MAC)
     // We need to adjust Times, Helvetica, and Courier to closely match the
     // vertical metrics of their Microsoft counterparts that are the de facto