REGRESSION(r182192): Ligatures do not interact correctly with SHY in some fonts
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Oct 2015 22:08:27 +0000 (22:08 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Oct 2015 22:08:27 +0000 (22:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150006

Reviewed by Simon Fraser.

Source/WebCore:

When performing font transforms and we encounter kCGFontIndexInvalid, we filter it out of the
GlyphBuffer. However, this filter was only interacting with part of the GlyphBuffer instead
of the whole thing. This causes glyph IDs from one font to be rendered with other fonts,
thereby showing garbage glyphs.

However, now that <rdar://problem/20230073> is fixed, we don't need to perform this filter in
the first place.

Test: fast/text/undefined-glyph-with-ligature.html

* platform/graphics/GlyphBuffer.h:
(WebCore::GlyphBuffer::copyItem):
(WebCore::GlyphBuffer::swap):
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::applyFontTransforms):

LayoutTests:

* fast/text/resources/tiny-ligature-font.svg: Added.
* fast/text/undefined-glyph-with-ligature-expected.html: Added.
* fast/text/undefined-glyph-with-ligature.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/resources/tiny-ligature-font.svg [new file with mode: 0644]
LayoutTests/fast/text/undefined-glyph-with-ligature-expected.html [new file with mode: 0644]
LayoutTests/fast/text/undefined-glyph-with-ligature.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/WidthIterator.cpp

index b72f2c9..cf743c3 100644 (file)
@@ -1,3 +1,14 @@
+2015-10-12  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        REGRESSION(r182192): Ligatures do not interact correctly with SHY in some fonts
+        https://bugs.webkit.org/show_bug.cgi?id=150006
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/resources/tiny-ligature-font.svg: Added.
+        * fast/text/undefined-glyph-with-ligature-expected.html: Added.
+        * fast/text/undefined-glyph-with-ligature.html: Added.
+
 2015-10-12  Antoine Quint  <graouts@apple.com>
 
         [SVG] Handle endEvent for svg animations
 2015-10-12  Antoine Quint  <graouts@apple.com>
 
         [SVG] Handle endEvent for svg animations
diff --git a/LayoutTests/fast/text/resources/tiny-ligature-font.svg b/LayoutTests/fast/text/resources/tiny-ligature-font.svg
new file mode 100644 (file)
index 0000000..a0d54b2
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" standalone="yes"?>
+<svg  version="1.1" viewBox="0 0 160 160" xmlns = 'http://www.w3.org/2000/svg' xmlns:xlink="http://www.w3.org/1999/xlink">
+  <defs>
+    <font id="Litherum" horiz-adv-x="1000">
+      <font-face units-per-em="1000" ascent="1000" descent="0">
+      </font-face>
+    <glyph unicode="A" horiz-adv-x="1000" d="M 500 0 H 1000 V 600 H 500 z"/>
+    <glyph unicode="B" horiz-adv-x="1000" d="M 500 0 H 1000 V 600 H 500 z"/>
+    <glyph unicode="AB" horiz-adv-x="1000" d="M 500 0 H 1000 V 600 H 500 z"/>
+    <glyph unicode=" B" horiz-adv-x="1000" d="M 500 0 H 1000 V 600 H 500 z"/>
+    </font>
+  </defs>
+</svg>
diff --git a/LayoutTests/fast/text/undefined-glyph-with-ligature-expected.html b/LayoutTests/fast/text/undefined-glyph-with-ligature-expected.html
new file mode 100644 (file)
index 0000000..0c56fcf
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: Litherum;
+    src: url("resources/tiny-ligature-font.svg") format("svg");
+}
+</style>
+</head>
+<body>
+This test makes sure that the combination of ligatures and nonexistant glyphs do not cause arbitrary glyphs to be rendered.
+The test passes if you see two black rectangles below, and nothing else.
+<div style="font-family: Litherum;">ABA</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/undefined-glyph-with-ligature.html b/LayoutTests/fast/text/undefined-glyph-with-ligature.html
new file mode 100644 (file)
index 0000000..398420d
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: Litherum;
+    src: url("resources/tiny-ligature-font.svg") format("svg");
+}
+</style>
+</head>
+<body>
+This test makes sure that the combination of ligatures and nonexistant glyphs do not cause arbitrary glyphs to be rendered.
+The test passes if you see two black rectangles below, and nothing else.
+<div style="font-family: Litherum;">AB&shy;A</div>
+</body>
+</html>
index e8e0033..a11dd4b 100644 (file)
@@ -1,3 +1,26 @@
+2015-10-12  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        REGRESSION(r182192): Ligatures do not interact correctly with SHY in some fonts
+        https://bugs.webkit.org/show_bug.cgi?id=150006
+
+        Reviewed by Simon Fraser.
+
+        When performing font transforms and we encounter kCGFontIndexInvalid, we filter it out of the
+        GlyphBuffer. However, this filter was only interacting with part of the GlyphBuffer instead
+        of the whole thing. This causes glyph IDs from one font to be rendered with other fonts,
+        thereby showing garbage glyphs.
+
+        However, now that <rdar://problem/20230073> is fixed, we don't need to perform this filter in
+        the first place.
+
+        Test: fast/text/undefined-glyph-with-ligature.html
+
+        * platform/graphics/GlyphBuffer.h:
+        (WebCore::GlyphBuffer::copyItem):
+        (WebCore::GlyphBuffer::swap):
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::applyFontTransforms):
+
 2015-10-12  Antoine Quint  <graouts@apple.com>
 
         [SVG] Handle endEvent for svg animations
 2015-10-12  Antoine Quint  <graouts@apple.com>
 
         [SVG] Handle endEvent for svg animations
index 08cef7c..4981441 100644 (file)
@@ -155,19 +155,6 @@ inline float WidthIterator::applyFontTransforms(GlyphBuffer* glyphBuffer, bool l
     }
     charactersTreatedAsSpace.clear();
 
     }
     charactersTreatedAsSpace.clear();
 
-#if PLATFORM(MAC) || PLATFORM(IOS)
-    // Workaround for <rdar://problem/20230073> FIXME: Please remove this when no longer needed.
-    GlyphBufferGlyph* glyphs = glyphBuffer->glyphs(0);
-    int filteredIndex = lastGlyphCount;
-    for (int i = lastGlyphCount; i < glyphBufferSize; ++i) {
-        glyphs[filteredIndex] = glyphs[i];
-        advances[filteredIndex] = advances[i];
-        if (glyphs[filteredIndex] != kCGFontIndexInvalid)
-            ++filteredIndex;
-    }
-    glyphBufferSize = filteredIndex;
-#endif
-
     for (int i = lastGlyphCount; i < glyphBufferSize; ++i)
         widthDifference += advances[i].width();
 
     for (int i = lastGlyphCount; i < glyphBufferSize; ++i)
         widthDifference += advances[i].width();