Truly independent web browser
LibGfx: Give a lone Hangul filler its glyph’s advance
sideshowbarkera1ac2700e0fd
diff --git a/Libraries/LibGfx/TextLayout.cpp b/Libraries/LibGfx/TextLayout.cppindex 0982009dec2..ff4423624cd 100644--- a/Libraries/LibGfx/TextLayout.cpp+++ b/Libraries/LibGfx/TextLayout.cpp@@ -535,6 +535,11 @@ static bool cluster_takes_letter_spacing(Utf16View const& string, u32 cluster_streturn cluster_start >= string.length_in_code_units() || !is_cursive_script(string.code_point_at(cluster_start));}+static bool is_hangul_filler(u32 code_point)+{+ return code_point == 0x115F || code_point == 0x1160 || code_point == 0x3164 || code_point == 0xFFA0;+}+// https://drafts.csswg.org/css-text-3/#white-space-phase-2// 4. If there remains any sequence of white space, other space separators, and/or preserved tabs at the end of a line// (after bidi reordering [CSS-WRITING-MODES-4]):@@ -627,11 +632,19 @@ static ShapedGlyphs build_origin_relative_shape(Utf16View const& string, Font coauto starting_offset = glyph_info[index].cluster;if (starting_offset >= string.length_in_code_units())return true;+ auto has_hangul_filler = false;for (auto code_point : string.substring_view(starting_offset, cluster_length_in_code_units(index))) {+ if (is_hangul_filler(code_point)) {+ has_hangul_filler = true;+ continue;+ }if (!Unicode::code_point_has_default_ignorable_code_point_property(code_point))return true;}- return false;+ // AD-HOC: The Hangul fillers have the Default_Ignorable_Code_Point property, but fonts give them a spacing+ // glyph, and a filler that stands alone takes that glyph's advance. A filler no font has a glyph for+ // stays invisible, rather than showing the missing-glyph box.+ return has_hangul_filler && glyph_info[index].codepoint != 0;};// NB: HarfBuzz positions glyphs in font space, where y grows upward, so its y offsets and advances are negateddiff --git a/Tests/LibWeb/Text/expected/hangul-syllable-with-choseong-filler.txt b/Tests/LibWeb/Text/expected/hangul-syllable-with-choseong-filler.txtindex 082ad978582..76747889541 100644--- a/Tests/LibWeb/Text/expected/hangul-syllable-with-choseong-filler.txt+++ b/Tests/LibWeb/Text/expected/hangul-syllable-with-choseong-filler.txt@@ -1,3 +1,5 @@syllable with a filler initial has a width: truesyllable with a kiyeok initial has a width: true-lone filler has no width: true+lone filler has a width: true+lone jungseong filler has a width: true+lone filler with no glyph has no width: truediff --git a/Tests/LibWeb/Text/input/hangul-syllable-with-choseong-filler.html b/Tests/LibWeb/Text/input/hangul-syllable-with-choseong-filler.htmlindex 9d5a1835079..a4d7a85b8ca 100644--- a/Tests/LibWeb/Text/input/hangul-syllable-with-choseong-filler.html+++ b/Tests/LibWeb/Text/input/hangul-syllable-with-choseong-filler.html@@ -13,8 +13,11 @@<span id="filler">ᅟᆓ</span><!-- U+1100 HANGUL CHOSEONG KIYEOK, then U+1193 --><span id="kiyeok">ᄀᆓ</span>-<!-- U+115F alone -->+<!-- U+115F alone, and U+1160 HANGUL JUNGSEONG FILLER alone: the font draws each as a spacing glyph. --><span id="lone-filler">ᅟ</span>+<span id="lone-jungseong-filler">ᅠ</span>+<!-- U+3164 HANGUL FILLER alone, in a font with no Hangul at all: Nothing has a glyph for it. -->+<span id="lone-filler-without-glyph" style="font: 40px serif">ㅤ</span><script src="include.js"></script><script>asyncTest(async done => {@@ -22,7 +25,9 @@const width = id => document.getElementById(id).getBoundingClientRect().width;println(`syllable with a filler initial has a width: ${width("filler") > 0}`);println(`syllable with a kiyeok initial has a width: ${width("kiyeok") > 0}`);- println(`lone filler has no width: ${width("lone-filler") === 0}`);+ println(`lone filler has a width: ${width("lone-filler") > 0}`);+ println(`lone jungseong filler has a width: ${width("lone-jungseong-filler") > 0}`);+ println(`lone filler with no glyph has no width: ${width("lone-filler-without-glyph") === 0}`);done();});</script>