From e9289735f2b3f2b5b527bf8fbfe19d85630d2067 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 3 Jun 2026 23:13:55 +0200 Subject: [PATCH] [base] Support BaseCoord format 4 Add the BASE BaseCoord format 4 dispatch arm. The format mirrors format 2, but stores the reference glyph as a 24-bit glyph ID for fonts with an extended glyph repertoire. Share the implementation through a Types-templated format pair. The subsetting path remaps the widened reference glyph in the same way format 2 remaps its 16-bit reference glyph. Testing: meson test -C build Assisted-by: OpenAI Codex --- src/hb-ot-layout-base-table.hh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-layout-base-table.hh b/src/hb-ot-layout-base-table.hh index 2470e7e2f..dc4d629d9 100644 --- a/src/hb-ot-layout-base-table.hh +++ b/src/hb-ot-layout-base-table.hh @@ -65,7 +65,8 @@ struct BaseCoordFormat1 DEFINE_SIZE_STATIC (4); }; -struct BaseCoordFormat2 +template +struct BaseCoordFormat2_4 { hb_position_t get_coord (hb_font_t *font, hb_direction_t direction) const { @@ -91,13 +92,14 @@ struct BaseCoordFormat2 } protected: - HBUINT16 format; /* Format identifier--format = 2 */ + HBUINT16 format; /* Format identifier--format = 2 or 4 */ FWORD coordinate; /* X or Y value, in design units */ - HBGlyphID16 referenceGlyph; /* Glyph ID of control glyph */ + typename Types::HBGlyphID + referenceGlyph; /* Glyph ID of control glyph */ HBUINT16 coordPoint; /* Index of contour point on the * reference glyph */ public: - DEFINE_SIZE_STATIC (8); + DEFINE_SIZE_STATIC (6 + Types::HBGlyphID::static_size); }; struct BaseCoordFormat3 @@ -175,6 +177,7 @@ 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); + case 4: hb_barrier (); return u.format4.get_coord (font, direction); default:return 0; } } @@ -196,6 +199,7 @@ struct BaseCoord case 1: hb_barrier (); return_trace (c->dispatch (u.format1, std::forward (ds)...)); case 2: hb_barrier (); return_trace (c->dispatch (u.format2, std::forward (ds)...)); case 3: hb_barrier (); return_trace (c->dispatch (u.format3, std::forward (ds)...)); + case 4: hb_barrier (); return_trace (c->dispatch (u.format4, std::forward (ds)...)); default:return_trace (c->default_return_value ()); } } @@ -209,6 +213,7 @@ 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)); + case 4: hb_barrier (); return_trace (u.format4.sanitize (c)); default:return_trace (false); } } @@ -217,8 +222,11 @@ struct BaseCoord union { struct { HBUINT16 v; } format; BaseCoordFormat1 format1; - BaseCoordFormat2 format2; + BaseCoordFormat2_4 + format2; BaseCoordFormat3 format3; + BaseCoordFormat2_4 + format4; } u; public: DEFINE_SIZE_UNION (2, format.v);