From e30e3c2f17fb26cddc91e9f950f6f26948fa8e0e Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 28 Sep 2026 16:15:37 +0100 Subject: Go on past a runaway GSUB as HarfBuzz does A font whose GSUB grows the buffer past its bounds (text-rendering-tests' GSUB-3) made vega_shape fail. HarfBuzz goes on with the glyphs of the last pass that finished: every later pass does nothing, positions are the default advances. Vega's buffer operations already stand still once the buffer is unsuccessful, so it now goes on too, and a broken font shows what HarfBuzz shows rather than nothing. HarfBuzz's suite: 5018 of 5199 the same, none failing. --- docs/design/004-text.md | 4 ++++ text/harfbuzz-suite.known | 3 --- text/shape.c | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/design/004-text.md b/docs/design/004-text.md index 58a53ad..2f629cb 100644 --- a/docs/design/004-text.md +++ b/docs/design/004-text.md @@ -258,6 +258,10 @@ U+180B–180E만 넣고 네 번째 자유 이체 선택자(U+180F)를 빠뜨렸 색인을 담는다. 글꼴 24개, 계획 96개의 무작위 실행이 HarfBuzz와 같다. 처음에는 형식 2가 달랐다. HarfBuzz가 등급 표 밖의 글리프를 다이제스트로 거르므로, 거짓 양성이 된 공백이 등급 0으로 커닝되었다. +GSUB가 끝없이 늘리는 글꼴(text-rendering-tests의 GSUB-3)에서 Vega는 버퍼 한도를 넘으면 실패를 돌려주었다. HarfBuzz는 +마지막으로 끝난 패스의 글리프로 계속한다. 그 뒤의 패스는 아무것도 하지 않고, 위치는 기본 advance가 된다. Vega도 그렇게 +한다. 깨진 글꼴에서도 글이 사라지지 않고 HarfBuzz와 같은 모습으로 남는다(5,018건이 같다). + ## 비례폭 글줄 [text/layout.c](../../text/layout.c)는 검증한 부품을 UAX #9 3.4절과 UAX #14가 말하는 순서로 잇는다. diff --git a/text/harfbuzz-suite.known b/text/harfbuzz-suite.known index 76a5be4..ad77ac2 100644 --- a/text/harfbuzz-suite.known +++ b/text/harfbuzz-suite.known @@ -15,6 +15,3 @@ in-house/arabic-fallback-shaping.tests:6 # Myanmar as Zawgyi encodes it (Qaag; refused). in-house/myanmar-zawgyi.tests:* - -# No plan for the run. -text-rendering-tests/GSUB-3.tests:1 diff --git a/text/shape.c b/text/shape.c index 8db4a7a..3ab8245 100644 --- a/text/shape.c +++ b/text/shape.c @@ -4060,7 +4060,9 @@ long vega_shape(VegaShaper *b, const VegaShaping *s, const uint32_t *codes, size info->gprops = gen_cat(info) != VEGA_MN || is_default_ignorable(info) ? BASE_GLYPH : MARK; } apply_table(s, &plan, b, 0); - if (!b->successful || !ensure(b, b->len)) return -1; + /* Past the buffer's bounds (a runaway GSUB), HarfBuzz goes on with the + * glyphs of the last pass that finished, every later pass doing + * nothing; so does this. */ position(s, &plan, b); /* Hide what shows nothing: the space glyph, with nothing to advance. */ @@ -4101,7 +4103,6 @@ long vega_shape(VegaShaper *b, const VegaShaping *s, const uint32_t *codes, size } if (plan.shaper == VEGA_SHAPER_ARABIC) apply_stch(s, b); - if (!b->successful) return -1; if (b->glyphs_allocated < b->len) { VegaShaped *glyphs = realloc(b->glyphs, b->len * sizeof(*glyphs)); -- cgit v1.2.3