Title: [206896] trunk
Revision
206896
Author
mmaxfi...@apple.com
Date
2016-10-06 20:21:27 -0700 (Thu, 06 Oct 2016)

Log Message

Variation fonts don't affect glyph advances
https://bugs.webkit.org/show_bug.cgi?id=163093

Reviewed by Darin Adler.

Source/WebCore:

Work around known bug <rdar://problem/28662086>. For variation fonts,
CTFontGetAdvancesForGlyphs() gives correct answers but
CTFontGetUnsummedAdvancesForGlyphsAndStyle() doesn't.

Test: fast/text/variations/advances.html

* platform/graphics/FontPlatformData.h:
(WebCore::FontPlatformData::hasVariations):
* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::Font::platformWidthForGlyph):
* platform/graphics/cocoa/FontPlatformDataCocoa.mm:
(WebCore::FontPlatformData::FontPlatformData):

LayoutTests:

* platform/ios-simulator/TestExpectations: Mark the test
as failing on iOS because that OS doesn't have Skia.
* fast/text/variations/advances-expected.txt: Added.
* fast/text/variations/advances.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206895 => 206896)


--- trunk/LayoutTests/ChangeLog	2016-10-07 03:03:57 UTC (rev 206895)
+++ trunk/LayoutTests/ChangeLog	2016-10-07 03:21:27 UTC (rev 206896)
@@ -1,3 +1,15 @@
+2016-10-06  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Variation fonts don't affect glyph advances
+        https://bugs.webkit.org/show_bug.cgi?id=163093
+
+        Reviewed by Darin Adler.
+
+        * platform/ios-simulator/TestExpectations: Mark the test
+        as failing on iOS because that OS doesn't have Skia.
+        * fast/text/variations/advances-expected.txt: Added.
+        * fast/text/variations/advances.html: Added.
+
 2016-10-06  Gyuyoung Kim  <gyuyoung....@webkit.org>
 
         [EFL] Skip to test imported/w3c/web-platform-tests/

Added: trunk/LayoutTests/fast/text/variations/advances-expected.txt (0 => 206896)


--- trunk/LayoutTests/fast/text/variations/advances-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/advances-expected.txt	2016-10-07 03:21:27 UTC (rev 206896)
@@ -0,0 +1,11 @@
+PASS regular.offsetWidth is not wide.offsetWidth
+PASS regular.offsetWidth is not narrow.offsetWidth
+PASS narrow.offsetWidth is not wide.offsetWidth
+PASS regular.offsetWidth is specifiedregular.offsetWidth
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ham
+ham
+ham
+ham

Added: trunk/LayoutTests/fast/text/variations/advances.html (0 => 206896)


--- trunk/LayoutTests/fast/text/variations/advances.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/advances.html	2016-10-07 03:21:27 UTC (rev 206896)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div><span id="regular" style="font: 100px 'Skia';">ham</span></div>
+<div><span id="wide" style="font: 100px 'Skia'; font-variation-settings: 'wdth' 1.25;">ham</span></div>
+<div><span id="specifiedregular" style="font: 100px 'Skia'; font-variation-settings: 'wdth' 1;">ham</span></div>
+<div><span id="narrow" style="font: 100px 'Skia'; font-variation-settings: 'wdth' 0.62;">ham</span></div>
+<script>
+var regular = document.getElementById("regular");
+var wide = document.getElementById("wide");
+var specifiedregular = document.getElementById("specifiedregular");
+var narrow = document.getElementById("narrow");
+
+shouldNotBe("regular.offsetWidth", "wide.offsetWidth");
+shouldNotBe("regular.offsetWidth", "narrow.offsetWidth");
+shouldNotBe("narrow.offsetWidth", "wide.offsetWidth");
+shouldBe("regular.offsetWidth", "specifiedregular.offsetWidth");
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (206895 => 206896)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-10-07 03:03:57 UTC (rev 206895)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-10-07 03:21:27 UTC (rev 206896)
@@ -2672,3 +2672,6 @@
 webkit.org/b/162739 fast/images/gif-loop-count.html [ Pass ImageOnlyFailure ]
 
 webkit.org/b/163009 media/modern-media-controls/icon-button/icon-button-active-state.html [ Failure ]
+
+# This variation font test requires Skia which isn't available on iOS.
+webkit.org/b/163093 fast/text/variations/advances.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (206895 => 206896)


--- trunk/Source/WebCore/ChangeLog	2016-10-07 03:03:57 UTC (rev 206895)
+++ trunk/Source/WebCore/ChangeLog	2016-10-07 03:21:27 UTC (rev 206896)
@@ -1,3 +1,23 @@
+2016-10-06  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Variation fonts don't affect glyph advances
+        https://bugs.webkit.org/show_bug.cgi?id=163093
+
+        Reviewed by Darin Adler.
+
+        Work around known bug <rdar://problem/28662086>. For variation fonts,
+        CTFontGetAdvancesForGlyphs() gives correct answers but
+        CTFontGetUnsummedAdvancesForGlyphsAndStyle() doesn't.
+
+        Test: fast/text/variations/advances.html
+
+        * platform/graphics/FontPlatformData.h:
+        (WebCore::FontPlatformData::hasVariations):
+        * platform/graphics/cocoa/FontCocoa.mm:
+        (WebCore::Font::platformWidthForGlyph):
+        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+        (WebCore::FontPlatformData::FontPlatformData):
+
 2016-10-06  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r206713.

Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (206895 => 206896)


--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2016-10-07 03:03:57 UTC (rev 206895)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2016-10-07 03:21:27 UTC (rev 206896)
@@ -138,6 +138,8 @@
     bool isSystemFont() const { return m_isSystemFont; }
 #endif
 
+    bool hasVariations() const { return m_hasVariations; }
+
 #if USE(CG) && (PLATFORM(WIN) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 100000))
     CGFontRef cgFont() const { return m_cgFont.get(); }
 #endif
@@ -277,6 +279,7 @@
     bool m_isColorBitmapFont { false };
     bool m_isHashTableDeletedValue { false };
     bool m_isSystemFont { false };
+    bool m_hasVariations { false };
     // The values above are common to all ports
 
 #if PLATFORM(IOS)

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (206895 => 206896)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm	2016-10-07 03:03:57 UTC (rev 206895)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm	2016-10-07 03:21:27 UTC (rev 206896)
@@ -624,8 +624,8 @@
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
     if (platformData().size()) {
         CTFontOrientation orientation = horizontal || m_isBrokenIdeographFallback ? kCTFontOrientationHorizontal : kCTFontOrientationVertical;
-        // FIXME: Remove this special-casing when <rdar://problem/28197291> is fixed.
-        if (CTFontIsAppleColorEmoji(m_platformData.ctFont()))
+        // FIXME: Remove this special-casing when <rdar://problem/28197291> and <rdar://problem/28662086> are fixed.
+        if (CTFontIsAppleColorEmoji(m_platformData.ctFont()) || m_platformData.hasVariations())
             CTFontGetAdvancesForGlyphs(m_platformData.ctFont(), orientation, &glyph, &advance, 1);
         else
             CTFontGetUnsummedAdvancesForGlyphsAndStyle(m_platformData.ctFont(), orientation, style, &glyph, &advance, 1);

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm (206895 => 206896)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2016-10-07 03:03:57 UTC (rev 206895)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2016-10-07 03:21:27 UTC (rev 206896)
@@ -50,6 +50,8 @@
     m_font = font;
     m_isColorBitmapFont = CTFontGetSymbolicTraits(font) & kCTFontTraitColorGlyphs;
     m_isSystemFont = CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(m_font.get())).get());
+    auto variations = adoptCF(static_cast<CFDictionaryRef>(CTFontCopyAttribute(font, kCTFontVariationAttribute)));
+    m_hasVariations = variations && CFDictionaryGetCount(variations.get());
 
 #if PLATFORM(IOS)
     m_isEmoji = CTFontIsAppleColorEmoji(m_font.get());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to