Title: [280103] trunk
Revision
280103
Author
[email protected]
Date
2021-07-20 13:47:36 -0700 (Tue, 20 Jul 2021)

Log Message

REGRESSION(r272379): Characters with no fonts that support them are drawn as two .notdef glyphs in the fast text codepath
https://bugs.webkit.org/show_bug.cgi?id=228097
<rdar://problem/80798113>

Reviewed by Alan Bujtas.

Source/WebCore:

If a character is not in BMP, and we don't have a glyph for it,
we'll end up with two 0 glyphs in a row for the two surrogates of the character.
We need to make sure that, after shaping, these double-0-glyphs aren't preserved.

Test: fast/text/double-notdef-simple-text-codepath.html

* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::applyFontTransforms):

LayoutTests:

* fast/text/double-notdef-simple-text-codepath-expected.html: Added.
* fast/text/double-notdef-simple-text-codepath.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (280102 => 280103)


--- trunk/LayoutTests/ChangeLog	2021-07-20 20:40:10 UTC (rev 280102)
+++ trunk/LayoutTests/ChangeLog	2021-07-20 20:47:36 UTC (rev 280103)
@@ -1,3 +1,14 @@
+2021-07-20  Myles C. Maxfield  <[email protected]>
+
+        REGRESSION(r272379): Characters with no fonts that support them are drawn as two .notdef glyphs in the fast text codepath
+        https://bugs.webkit.org/show_bug.cgi?id=228097
+        <rdar://problem/80798113>
+
+        Reviewed by Alan Bujtas.
+
+        * fast/text/double-notdef-simple-text-codepath-expected.html: Added.
+        * fast/text/double-notdef-simple-text-codepath.html: Added.
+
 2021-07-20  Arcady Goldmints-Orlov  <[email protected]>
 
         [GLIB] Test gardening, update baselines after r279987

Added: trunk/LayoutTests/fast/text/double-notdef-simple-text-codepath-expected.html (0 => 280103)


--- trunk/LayoutTests/fast/text/double-notdef-simple-text-codepath-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/double-notdef-simple-text-codepath-expected.html	2021-07-20 20:47:36 UTC (rev 280103)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+This test makes sure that .notdef does not draw twice for a single character in the simple text codepath. The test passes if this text you're reading right now is the only thing you can see on the page.
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/double-notdef-simple-text-codepath.html (0 => 280103)


--- trunk/LayoutTests/fast/text/double-notdef-simple-text-codepath.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/double-notdef-simple-text-codepath.html	2021-07-20 20:47:36 UTC (rev 280103)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+This test makes sure that .notdef does not draw twice for a single character in the simple text codepath. The test passes if this text you're reading right now is the only thing you can see on the page.
+<div style="position: relative;">
+<div id="target" style="position: absolute; top: 0px; left: 0px; font-family: 'Hiragino Kaku Gothic Pro';">&#x224CA;</div>
+<div id="cover" style="position: absolute; top: 0px; left: 0px; width: 100px; height: 100px; background: white;"></div>
+</div>
+<script>
+var target = document.getElementById("target");
+var cover = document.getElementById("cover");
+cover.style.width = "" + target.offsetWidth + "px";
+cover.style.height = "" + target.offsetHeight + "px";
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (280102 => 280103)


--- trunk/Source/WebCore/ChangeLog	2021-07-20 20:40:10 UTC (rev 280102)
+++ trunk/Source/WebCore/ChangeLog	2021-07-20 20:47:36 UTC (rev 280103)
@@ -1,5 +1,22 @@
 2021-07-20  Myles C. Maxfield  <[email protected]>
 
+        REGRESSION(r272379): Characters with no fonts that support them are drawn as two .notdef glyphs in the fast text codepath
+        https://bugs.webkit.org/show_bug.cgi?id=228097
+        <rdar://problem/80798113>
+
+        Reviewed by Alan Bujtas.
+
+        If a character is not in BMP, and we don't have a glyph for it,
+        we'll end up with two 0 glyphs in a row for the two surrogates of the character.
+        We need to make sure that, after shaping, these double-0-glyphs aren't preserved.
+
+        Test: fast/text/double-notdef-simple-text-codepath.html
+
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::applyFontTransforms):
+
+2021-07-20  Myles C. Maxfield  <[email protected]>
+
         Use references instead of pointers in WidthIterator::advanceInternal()
         https://bugs.webkit.org/show_bug.cgi?id=228099
 

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (280102 => 280103)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2021-07-20 20:40:10 UTC (rev 280102)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2021-07-20 20:47:36 UTC (rev 280103)
@@ -106,6 +106,26 @@
     ASSERT(lastGlyphCount <= glyphBufferSize);
 
     font.applyTransforms(glyphBuffer, lastGlyphCount, m_currentCharacterIndex, m_enableKerning, m_requiresShaping, m_font.fontDescription().computedLocale(), m_run.text(), m_run.direction());
+
+    // <rdar://problem/80798113>: If a character is not in BMP, and we don't have a glyph for it,
+    // we'll end up with two 0 glyphs in a row for the two surrogates of the character.
+    // We need to make sure that, after shaping, these double-0-glyphs aren't preserved.
+    // FIXME: Delete this when rdar://80818297 is fixed everywhere.
+    if (&font == &m_font.primaryFont() && !m_run.text().is8Bit()) {
+        for (unsigned i = 0; i < glyphBuffer.size() - 1; ++i) {
+            if (!glyphBuffer.glyphAt(i) && !glyphBuffer.glyphAt(i + 1)) {
+                if (const auto& firstStringOffset = glyphBuffer.checkedStringOffsetAt(i, m_run.length())) {
+                    if (const auto& secondStringOffset = glyphBuffer.checkedStringOffsetAt(i + 1, m_run.length())) {
+                        if (secondStringOffset.value() == firstStringOffset.value() + 1
+                            && U_IS_LEAD(m_run.text()[firstStringOffset.value()]) && U_IS_TRAIL(m_run.text()[secondStringOffset.value()])) {
+                            glyphBuffer.remove(i + 1, 1);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
     glyphBufferSize = glyphBuffer.size();
     advances = glyphBuffer.advances(0);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to