haikuwebkit/LayoutTests/fast/text/resources
Myles C. Maxfield 8c589fafa5 overwriteCodePoint() in createAndFillGlyphPage() is wrong
https://bugs.webkit.org/show_bug.cgi?id=215643
<rdar://problem/67430461>

Reviewed by Alan Bujtas.

Source/WebCore:

The CSS spec says that certain characters have to be invisible. Previously, we were doing this
by just treating these characters as if they were the zero width space character. However, this
is wrong for 2 reasons:

1. If the primary font supports the desired character but doesn't support the zero width space
       character, we'll fallback past it and trigger a download for secondary fonts until
       we find one that supports the ZWS character (which the page didn't even ask for!)
2. Shaping is Turing-complete, and expects that the correct glyphIDs are fed into the shaper.
       We can't just arbitrarily swap out glyphIDs before shaping just because we feel like it.

Instead, the solution is to handle these invisible characters after font fallback, and after
shaping. This patch does it just like we handle adding letter-spacing, word-spacing, and
justification after shaping - by iterating over the glyphs output by the shaper and seeing if
any need to be adjusted.

This patch also includes a fix for the situation where the glyph buffer might be left in an
inconsistent state, where the array of glyphs is shorter than the array of characters -
this new codepath added in this patch revealed this existing problem, and fixes it here too.

Test: fast/text/zwj-ligature.html

* platform/graphics/Font.cpp:
(WebCore::createAndFillGlyphPage):
(WebCore::overrideControlCharacters): Deleted.
* platform/graphics/GlyphBuffer.h:
(WebCore::GlyphBuffer::glyphAt const):
(WebCore::GlyphBuffer::deleteGlyphWithoutAffectingSize):
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::applyCSSVisibilityRules):
(WebCore::WidthIterator::advance):
* platform/graphics/WidthIterator.h:

Source/WTF:

* wtf/unicode/CharacterNames.h:

LayoutTests:

* fast/text/resources/Ahem-GSUB-ligatures.ttf: Added.
* fast/text/zwj-ligature-expected.html: Added.
* fast/text/zwj-ligature.html: Added.
* platform/mac/fast/text/format-control-expected.txt: Progression! A new ligature is formed that wasn't formed before.
      Also, this ligature is formed in both Chrome and Firefox, so we match them now.
* platform/win/TestExpectations:

Canonical link: https://commits.webkit.org/240804@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281389 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-22 05:41:27 +00:00
..
Ahem-10000A.ttf PUA characters have the wrong advance in the fast text codepath 2021-07-13 07:52:36 +00:00
Ahem-GSUB-ligatures.ttf overwriteCodePoint() in createAndFillGlyphPage() is wrong 2021-08-22 05:41:27 +00:00
Ahem-SVG.ttf
Ahem-fixed-pitch.ttf
Ahem-multi-code-unit.ttf
Ahem-negative-line-gap.ttf
Ahem-trak.ttf [Cocoa] Stop treating the system font as a non-variable font 2021-08-20 03:21:05 +00:00
Ahem-zero-width-shaping-font-mismatch.ttf
AhemErroneousMonospace.ttf
Gulf-regular.ttf
Helvetica_light.svg
LiebeTest-calt.woff
LiebeTest-dlig.woff
LiebeTest-liga.woff
LiebeTest-swsh.woff
UniversTofu-GSUB-rvrn.ttf [Cocoa] Single characters don't get shaped in the fast text codepath 2021-08-21 19:18:51 +00:00
ahem.woff2
arabic-duplicate-glyph-font.svg
bad-encoding.xml
bogus.svg
bustedfont.svg
collection.ttc
collection2.ttc
font-overflow-layout-rect.svg
gw432047.ttf
header-totalsfntsize-001.ttf
header-totalsfntsize-001.woff2
invalid-locale.html
line-breaks-cr.txt
line-breaks-crlf.txt
line-breaks-lf.txt
tatechuyoko.svg
test-find.js
tiny-ligature-font.svg
word-break-next-linebox-not-dirty-crash.html