From e8a7f183fee4518138da29a3db8889b3510620de Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 1 Nov 2026 19:26:02 -0700 Subject: [PATCH] [paint] Preserve void extents through transformations (#6548) Honk paints an empty outline as one of its COLR layers. Transforming its void bounding box orders the sentinel corners into a real rectangle at (-1,-1)-(0,0), even with the identity transform. That rectangle expands the accent's ink bounds toward the origin and shifts fallback marks by hundreds of units. Keep void extents void when applying a transform. Add shaping regressions for normal and double scale and vertical layout using a default-instance Honk subset, with its OFL embedded in the name table. Current read-fonts already computes the correct COLR bounds. Removing only the empty layer also makes unpatched HarfBuzz match HarfRust, confirming the cause of harfrust#553. Update the existing vertical-origin overflow fixture to use an explicit COLR clip box. Assert that its height still clamps to INT_MIN so the original negation-overflow regression stays covered after void bounds stop producing artificial ink. Testing: meson test -C build (276 passed). Fixes: https://github.com/harfbuzz/harfrust/issues/553 Assisted-by: OpenAI Codex --- src/hb-geometry.hh | 3 ++ test/api/test-ot-face.c | 31 ++++++++++-------- ...51123c80fa9526c9c3032cd41c22700a4bc3e2.ttf | Bin 0 -> 12140 bytes .../data/in-house/tests/color-fonts.tests | 7 ++++ 4 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 test/shape/data/in-house/fonts/ba51123c80fa9526c9c3032cd41c22700a4bc3e2.ttf diff --git a/src/hb-geometry.hh b/src/hb-geometry.hh index ade9d8405..18671be79 100644 --- a/src/hb-geometry.hh +++ b/src/hb-geometry.hh @@ -188,6 +188,9 @@ struct hb_transform_t void transform_extents (hb_extents_t &extents) const { + /* Transforming a void box's sentinel corners would give it area. */ + if (unlikely (extents.is_void ())) return; + Float quad_x[4], quad_y[4]; quad_x[0] = extents.xmin; diff --git a/test/api/test-ot-face.c b/test/api/test-ot-face.c index 30e474543..a31a96ff0 100644 --- a/test/api/test-ot-face.c +++ b/test/api/test-ot-face.c @@ -219,28 +219,33 @@ test_ot_var_axis_on_zero_named_instance (void) static void test_ot_font_v_origin_extents_overflow (void) { + /* A COLRv1 glyph with a clip box from y=-32768 to y=32767. At the + * scale below, its height clamps to INT_MIN, exercising the overflow + * guard without relying on bounds manufactured from an empty outline. */ static const char data[] = { - 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x43, 0x4f, 0x4c, 0x52, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x09, - 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x10, 0x00, 0x00, - 0x00, 0x22, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, - 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x11, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0c, - 0x00, 0x00, 0x17, 0x00, 0x00, 0x02, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - (char) 0xff, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x00, - 0x00, 0x04, 0x20, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x04, 0x03, 0x20, - 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00 + 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x43, 0x4f, 0x4c, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, + 0x00, 0x00, 0x00, 0x46, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, + 0x02, (char) 0xff, (char) 0xff, 0x40, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00, (char) 0x80, 0x00, 0x00, 0x01, + 0x7f, (char) 0xff }; hb_blob_t *blob = hb_blob_create (data, sizeof (data), HB_MEMORY_MODE_READONLY, NULL, NULL); hb_face_t *face = hb_face_create (blob, 0); + hb_face_set_upem (face, 1); hb_font_t *font = hb_font_create (face); hb_position_t x, y; - hb_font_set_scale (font, 12, 12); + hb_font_set_scale (font, 65536, 65536); + hb_glyph_extents_t extents; + g_assert_true (hb_font_get_glyph_extents (font, 0, &extents)); + g_assert_cmpint (extents.height, ==, G_MININT); g_assert_true (hb_font_get_glyph_v_origin (font, 0, &x, &y)); - g_assert_cmpint (y, ==, -1073741719); + g_assert_cmpint (y, ==, 1073709056); hb_font_destroy (font); hb_face_destroy (face); diff --git a/test/shape/data/in-house/fonts/ba51123c80fa9526c9c3032cd41c22700a4bc3e2.ttf b/test/shape/data/in-house/fonts/ba51123c80fa9526c9c3032cd41c22700a4bc3e2.ttf new file mode 100644 index 0000000000000000000000000000000000000000..1f502317b8a27484e28d37760eee794c432e9fcb GIT binary patch literal 12140 zcmd5?Yiu0Xbw0DRTr#UCEmBquMP4pNnPMbrclnS^%Q7D#MOHLPk(3-cj-}u5=8v_166D zl~+XeqU~%ya=5cgHW9M^-!WcsWaxPNk8l3?7b5%6C$;@U`!dUa@%AqP`wZHrhlbmR zzx&^R_*0DULA!NyCOd!s?|*QgNF;^!!O866Jg%Fu-dnhqP3F!|Z2t92$1wgP2zq;J zJUh1Ymw*2T@U6#q^AtMP)vx?H+K18JIW@C%E^|-hZL~i?yE`{Gn%(%y=5EZ-pLFLC=I1$ zk&CCr`4-{a>jqas;_ifZ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Pa& z&pYKwSt^CpvPxrZyo_6{Y!;Bur$99;D%M4O*4B$S$GFX?eHix>7-Ljjvfq+=-@)7a zVt-rk3nFgH6go|{`P8JXfvoTMP1r9aS;nB>N;4=9cMf%c3`i#)< zVJW`W+Jx`j!hipOW-{ExFAL>49D_J|adhEm#euI%r4dIxj@r1O=D7>!Iw{9FE1Plt zifqDpn{33nUpC;}BkOUF$vS-gwHfp9=YAm9c*O@~Qrar(|4L%5@@p?kNvrIdkZ7wk zG>F^E6(g;%7r@1DpNvl`NmMITkAq)|@h@rk+ip16>aZ_n&aOEd5PVBk#%Z!0M;U0^ z2HUH}w;u=4#<#iR{Scq6ox?HoQ_nkf#`At~5JwlJXFho2M{hs$KB@-98*%TuH#c~L zpT6Poqc(e7yLQdM7G8nfK-qN)ua4t*-}%a8fYHB?{u] ../fonts/fcbaa518d3cce441ed37ae3b1fed6a19e9b54efd.ttf;--show-extents;U+1F600;[gid4=0+2550<0,1898,2555,-2405>] + +# Honk (OFL), pinned to MORF=15, SHLN=0. The accent's first COLR layer is empty. +# An empty clip must stay empty when transformed, rather than adding ink +# at the origin and changing mark placement (harfbuzz/harfrust#553). +../fonts/ba51123c80fa9526c9c3032cd41c22700a4bc3e2.ttf;--show-extents;U+1E49,0306;[nmacronbelow=0+1060<-40,968,1140,-1152>|uni0306=0@-1024,199+0<128,1168,732,-274>] +../fonts/ba51123c80fa9526c9c3032cd41c22700a4bc3e2.ttf;--show-extents --font-size=4000;U+1E49,0306;[nmacronbelow=0+2120<-80,1936,2280,-2304>|uni0306=0@-2048,398+0<256,2336,1464,-548>] +../fonts/ba51123c80fa9526c9c3032cd41c22700a4bc3e2.ttf;--show-extents --direction=ttb;U+1E49,0306;[nmacronbelow=0@-530,-1612+0,-2440<-40,968,1140,-1152>|uni0306=0@36,1733+0<128,1168,732,-274>]