[BASE] Guard extended BaseCoord format

Keep BaseCoord format 4 behind HB_NO_BEYOND_64K, matching the other
24-bit Layout formats.

Add API coverage for reading a format 4 baseline coordinate.

Assisted-by: OpenAI Codex
This commit is contained in:
Behdad Esfahbod committed 2026-06-05 13:36:58 +02:00
1 parent 9af6b3ad96
commit a6cddbc589
2 files changed
+46

No files matched your search

+8
View File
@@ -177,7 +177,9 @@ struct BaseCoord
case 1: hb_barrier (); return u.format1.get_coord (font, direction);
case 2: hb_barrier (); return u.format2.get_coord (font, direction);
case 3: hb_barrier (); return u.format3.get_coord (font, var_store, direction);
#ifndef HB_NO_BEYOND_64K
case 4: hb_barrier (); return u.format4.get_coord (font, direction);
#endif
default:return 0;
}
}
@@ -199,7 +201,9 @@ struct BaseCoord
case 1: hb_barrier (); return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
case 2: hb_barrier (); return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
case 3: hb_barrier (); return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...));
#ifndef HB_NO_BEYOND_64K
case 4: hb_barrier (); return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...));
#endif
default:return_trace (c->default_return_value ());
}
}
@@ -213,7 +217,9 @@ struct BaseCoord
case 1: hb_barrier (); return_trace (u.format1.sanitize (c));
case 2: hb_barrier (); return_trace (u.format2.sanitize (c));
case 3: hb_barrier (); return_trace (u.format3.sanitize (c));
#ifndef HB_NO_BEYOND_64K
case 4: hb_barrier (); return_trace (u.format4.sanitize (c));
#endif
default:return_trace (false);
}
}
@@ -225,8 +231,10 @@ struct BaseCoord
BaseCoordFormat2_4<Layout::SmallTypes>
format2;
BaseCoordFormat3 format3;
#ifndef HB_NO_BEYOND_64K
BaseCoordFormat2_4<Layout::MediumTypes>
format4;
#endif
} u;
public:
DEFINE_SIZE_UNION (2, format.v);
+38
View File
@@ -109,6 +109,43 @@ test_ot_layout_base_with_fallback (void)
hb_face_destroy (face);
}
static void
test_ot_layout_base_format4 (void)
{
static const char BASE_data[] = {
0, 1, 0, 0, /* version */
0, 8, /* horizontal axis offset */
0, 0, /* vertical axis offset */
0, 4, /* base tag list offset */
0, 10, /* base script list offset */
0, 1, 'r', 'o', 'm', 'n', /* base tag list */
0, 1, 'l', 'a', 't', 'n', 0, 8, /* base script list */
0, 6, 0, 0, 0, 0, /* base script */
0, 0, 0, 1, 0, 6, /* base values */
0, 4, 0, 123, 0, 0, 0, 0, 0, /* BaseCoord format 4 */
};
hb_face_t *face = hb_face_builder_create ();
HB_FACE_ADD_TABLE (face, "BASE", BASE_data);
hb_font_t *font = hb_font_create (face);
hb_position_t position;
#ifndef HB_NO_BEYOND_64K
g_assert_true (hb_ot_layout_get_baseline (font, HB_OT_LAYOUT_BASELINE_TAG_ROMAN,
HB_DIRECTION_LTR,
HB_TAG ('l','a','t','n'),
HB_TAG_NONE, &position));
g_assert_cmpint (position, ==, 123);
#else
g_assert_false (hb_ot_layout_get_baseline (font, HB_OT_LAYOUT_BASELINE_TAG_ROMAN,
HB_DIRECTION_LTR,
HB_TAG ('l','a','t','n'),
HB_TAG_NONE, &position));
#endif
hb_font_destroy (font);
hb_face_destroy (face);
}
int
main (int argc, char **argv)
{
@@ -116,6 +153,7 @@ main (int argc, char **argv)
hb_test_add (test_ot_layout_base);
hb_test_add (test_ot_layout_base_with_fallback);
hb_test_add (test_ot_layout_base_format4);
return hb_test_run();
}