From ea6dbcf627e9a440590d0d35ff16ca7ae60d5719 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 28 Sep 2026 16:13:58 +0100 Subject: Kern with class subtables too (kern formats 2 and 3) The kern table's class subtables, OpenType's and Apple's, as HarfBuzz reads them (hb-aat-layout-kerx-table.hh, hb-ot-kern-table.hh): format 2's class tables give byte offsets into a kerning array, format 3's byte classes index a value list. Both go through the same pass as pairs (marks skipped, the kerning split between the pair). Format 2 filters the glyphs by the class tables' digests, as HarfBuzz's accelerator does, so a digest's false positive reads class 0 there too; what a subtable reads must lie within it, the last one's within the table. The build checks the subtables as HarfBuzz's sanitizer does, and still refuses state machines (format 1) and cross-stream kerning. text/test-kern.py makes fonts with format 2 and 3 subtables in every order, with the edge cases that reading has (value 1, glyphs outside a table, offsets below the array or odd, values past a subtable's or the table's end, classes and indexes past their counts): 24 fonts, 96 plans, the same as HarfBuzz. make check runs it where fontTools is. HarfBuzz's suite: 5017 of 5199 the same. --- text/shape.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'text/shape.h') diff --git a/text/shape.h b/text/shape.h index 690430c..e02f0e4 100644 --- a/text/shape.h +++ b/text/shape.h @@ -121,6 +121,8 @@ typedef struct { const unsigned char *sequences; /* variation sequences */ uint32_t sequence_count; VegaTable gdef, gsub, gpos, kern; + VegaDigest *kern_sets; /* each kern subtable's left and right glyphs (format 2's), as HarfBuzz digests them */ + uint32_t kern_subtables; VegaTable fallback; /* Arabic fallback shaping's lookups, a GSUB table */ uint32_t fallback_count; uint8_t fallback_features[7]; /* what each is for: init, medi, fina, isol, rlig x3 (0..6) */ -- cgit v1.2.3