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 000000000..1f502317b Binary files /dev/null and b/test/shape/data/in-house/fonts/ba51123c80fa9526c9c3032cd41c22700a4bc3e2.ttf differ diff --git a/test/shape/data/in-house/tests/color-fonts.tests b/test/shape/data/in-house/tests/color-fonts.tests index 048bc2845..8ecd8be71 100644 --- a/test/shape/data/in-house/tests/color-fonts.tests +++ b/test/shape/data/in-house/tests/color-fonts.tests @@ -1,3 +1,10 @@ @font-funcs=ot ../fonts/ee39587d13b2afa5499cc79e45780aa79293bbd4.ttf;--show-extents;U+1F42F;[gid1=0+2963<0,2179,2963,-2789>] ../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>]