From 63c31a9e6ce4cef3c95a694cf3187abeb200ee26 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 30 Oct 2026 14:53:21 -0600 Subject: [PATCH 01/18] [gpos] Skip non-increasing Coverage indices in PairPosFormat1::intersects fast path The slow-population fast path of PairPosFormat1_3::intersects() walked the glyph set and indexed pairSet by the Coverage index of each glyph. In a well-formed font those indices increase with glyph id, but a broken Coverage can repeat an index, so one PairSet could be scanned once per glyph, giving quadratic time. Track the last index used and skip any that does not increase (and any NOT_COVERED), following the existing "Broken table. Skip." convention, so each PairSet is scanned at most once. Well-formed fonts are unchanged. Adds a fuzzer regression font. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-6GSU471N. Co-Authored-By: Claude Opus 4.8 --- src/OT/Layout/GPOS/PairPosFormat1.hh | 8 ++++++++ ...pairpos1-coverage-repeated-index-timeout.ttf | Bin 0 -> 53636 bytes 2 files changed, 8 insertions(+) create mode 100644 test/fuzzing/fonts/gpos-pairpos1-coverage-repeated-index-timeout.ttf diff --git a/src/OT/Layout/GPOS/PairPosFormat1.hh b/src/OT/Layout/GPOS/PairPosFormat1.hh index 47e80b6bf..26446874f 100644 --- a/src/OT/Layout/GPOS/PairPosFormat1.hh +++ b/src/OT/Layout/GPOS/PairPosFormat1.hh @@ -56,9 +56,17 @@ struct PairPosFormat1_3 if (pairSet.len > glyphs->get_population () * hb_bit_storage ((unsigned) pairSet.len)) { + unsigned next = 0; for (hb_codepoint_t g : glyphs->iter ()) { unsigned i = cov.get_coverage (g); + if (i == NOT_COVERED) continue; + /* Broken table. Skip. Important to avoid DoS. + * Coverage indices must increase with glyph id, as the + * Coverage iterator used below enforces; otherwise one + * PairSet could be scanned once per glyph. */ + if (unlikely (i < next)) continue; + next = i + 1; if ((this+pairSet[i]).intersects (glyphs, valueFormat)) return true; } diff --git a/test/fuzzing/fonts/gpos-pairpos1-coverage-repeated-index-timeout.ttf b/test/fuzzing/fonts/gpos-pairpos1-coverage-repeated-index-time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gb@5Cx(@6o>**APPi*C=dmrKop1qQ6LILfhZ6KqCgag0#P6eM1d#}1)@L{ zhyqa{3Pgb@5Cx(@6o>**APPi*C=dmrKop1qQ6LILfhZ6KqCgag0#P6eM1d#}1)@L{ zhyqa{3Pgb@5Cx(@6o>**APPi*C=dmrKop1qQ6LILfhZ6K5RjTY6hk#?)^A2ilKBh? z2{*5(Lx)~{eU4izUrT!PI3-Hv4=I&E5}!-PZ6qg!znRK+OG8@Hk)8}>Bomp*LRPYI zJK4E|JIO&#a*^A=nU{RzrvL>h#9iD?VeX*__fphPQ=Af%q!gvOk22g(S<3MM<#~__ zRHPD>sX|q%@etK{m>N7nO=?k_I@F~e^=Uvu8qt_0JW5lV(VWL5rI5Q7=QP=+y_5sYLM zFYz*?d4(~IWgM?Eo(W835|f$2YrM`>rtt=EGM%@W!Axc`o40v~Im~4q^I5<`7V$3c zv6v++Wf{wPpAT5UN>=e9AMr7(S;HrM%39X3o(+7)Mm}c~o7ut_e92b6;%m0?4d1ez z9qeQmyV=8ce9vC?v7ZARTKB1p?pIlr(*r86 z2US58RY{dqMO9Tz52?ByRt-I(nyRJRs-wE9r}}E3hH9k7YNAKgRL#^}kEw-P>T$Kw z6M9mu)kaULt=g%*I;f*Msk6GMtGcPXdZ?#*ski#5ubx&vJ)>v!oSxSU>aPKMQ3Ewd zgEd4$HB7@bLL)UwFX?5C)+-vLu^OjWHC_`mQIj-TQ}mi%*Hlf@8+udI^_FI6rewSHo6T_+yR=(-^qs!fUhUI<9ne7?(hvGkKj~-vqQg3( zqxx09>6nh|gih*rozfrrQ-A4ioz@xsqq91v^SYpaby1geSyyyb*K}Psl#nFxy^u)a dCcg(#d!N=MZn Date: Fri, 30 Oct 2026 14:53:41 -0600 Subject: [PATCH 02/18] [subset] Skip PairPosFormat2 classes outside the class matrix when collecting variation indices collect_pair_variation_indices() added every class returned by the two ClassDefs to class1_set / class2_set without bounding them by class1Count / class2Count. A ClassDef can map glyphs to classes far outside the value matrix, so the collected sets could be enormous and the subsequent nested loop quadratic, although apply() and the serialization loops only ever touch classes inside the matrix. Bound the collected classes by class1Count / class2Count, the same bound the rest of the code already uses. Output is byte-identical; adds a fuzzer regression font. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-C60AYSA3. Co-Authored-By: Claude Opus 4.8 --- src/OT/Layout/GPOS/PairPosFormat2.hh | 7 +++++-- ...os-pairpos2-class-outside-matrix-timeout.ttf | Bin 0 -> 66501 bytes 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 test/fuzzing/fonts/gpos-pairpos2-class-outside-matrix-timeout.ttf diff --git a/src/OT/Layout/GPOS/PairPosFormat2.hh b/src/OT/Layout/GPOS/PairPosFormat2.hh index 46ceb984f..15c2ab83b 100644 --- a/src/OT/Layout/GPOS/PairPosFormat2.hh +++ b/src/OT/Layout/GPOS/PairPosFormat2.hh @@ -34,7 +34,9 @@ void collect_pair_variation_indices (hb_collect_variation_indices_context_t *c, else { unsigned klass1 = class_def1.get (cp); - class1_set.add (klass1); + /* Classes outside the matrix have no values; apply() ignores them too. */ + if (klass1 < class1_count) + class1_set.add (klass1); } } @@ -42,7 +44,8 @@ void collect_pair_variation_indices (hb_collect_variation_indices_context_t *c, for (const unsigned cp : + c->glyph_set->iter () | hb_filter (klass2_glyphs)) { unsigned klass2 = class_def2.get (cp); - class2_set.add (klass2); + if (klass2 < class2_count) + class2_set.add (klass2); } if (class1_set.is_empty () diff --git a/test/fuzzing/fonts/gpos-pairpos2-class-outside-matrix-timeout.ttf b/test/fuzzing/fonts/gpos-pairpos2-class-outside-matrix-timeout.ttf new file mode 100644 index 0000000000000000000000000000000000000000..a2d1b68cba56545ec5aac911b81124c7369d6980 GIT binary patch literal 66501 zcmZ77W7H$TwlLtXs?<*`|9G;$ zo&jd~$K}87LihhV`1;o&{Lfjz|2-`Xg1i55@Ekn<$B+K?^WgkHzV@$g2iyPgsegSw znE#LW{p-WQ@PEA7UylQE|9H8-UIWzl$Fu$Q0-(S@9`CQG04e@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1=oGZ>9=ZW*i`QrR>fw*8?C@vfqiHpX?;^J|M zxMW-^E*+PN%f{v6@^OW@Vq7V%99M~}#?|8LagDfUTq~{}*NN-K_2T+*gScVbC~h1# ziJQjF;^uLSxMkcbZXLIY+s5tU_Hl=}W85k39CwMk#@*uXagVrX+$-)K_lf(){bDS} zV-OQD8B;MGGcg-;F&_)D7)vpX6OF5PeKI!0fUAN8!>9kU;m7oFloxP|7OgZGjGA7CCgT{UrbRa%-cvz^YU`%W Date: Tue, 10 Nov 2026 11:22:15 -0600 Subject: [PATCH 03/18] [ft] Reselect the COLR palette instead of copying it per paint (#6617) * [ft] Reselect the COLR palette instead of copying it per paint #6490 lets paint callbacks run with the FT face unlocked, so a callback can paint another glyph that selects a different palette on the same FT_Face, changing the colors FreeType's palette buffer holds. It guarded against that by heap-copying the whole palette on every COLRv1 glyph paint. Instead, remember on the hb_ft_font_t which palette hb-ft last selected, and when a palette color is about to be read (with the lock held) and another palette has been selected since, select ours again. The common case costs one compare and no allocation. Testing: meson test -C build passes. test-paint's ft_reentrant_paint, which paints with palette 1 from inside the custom-palette callback, fails with the reselect disabled and passes with it. Follow-up to #6490 Co-Authored-By: Claude Opus 5.5 * [ft] Drop palette bookkeeping; rely on FT_Palette_Select's no-op FT_Palette_Select already skips its work when the requested palette is the one already selected on the face, and returns the palette pointer either way (freetype src/base/ftcolor.c). So the selected_palette member added to track it, and the guard around the re-select, are unnecessary: _hb_ft_get_solid_color re-selects our palette unconditionally after a callback may have changed it, and FreeType no-ops the common case where it is already current. Removes hb_ft_font_t::selected_palette and both of its assignments. Co-Authored-By: Claude Opus 4.8 --------- Co-authored-by: Claude Opus 5.5 --- src/hb-ft-colr.hh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/hb-ft-colr.hh b/src/hb-ft-colr.hh index 575ac289c..b734cc795 100644 --- a/src/hb-ft-colr.hh +++ b/src/hb-ft-colr.hh @@ -189,6 +189,15 @@ _hb_ft_get_solid_color (hb_ft_paint_context_t *c, return; } + /* A callback may have painted another glyph, selecting another palette on + * the face while it was unlocked. Re-select ours unconditionally: + * FT_Palette_Select is a no-op in FreeType when our palette is already + * current, and returns the palette pointer either way. */ + FT_Color *palette = nullptr; + (void) FT_Palette_Select (c->ft_font->ft_face, c->palette_index, &palette); + c->palette = hb_array ((const FT_Color *) palette, + palette ? c->palette.length : 0); + FT_Color ft_color = c->palette ? c->palette[color_index.palette_index] : FT_Color {}; *color = HB_COLOR (ft_color.blue, ft_color.green, @@ -551,6 +560,7 @@ hb_ft_paint_glyph_colr (hb_font_t *font, if (!palette) { // https://github.com/harfbuzz/harfbuzz/issues/5116 + palette_index = 0; (void) FT_Palette_Select(ft_face, 0, &palette); } @@ -563,13 +573,6 @@ hb_ft_paint_glyph_colr (hb_font_t *font, FT_COLOR_NO_ROOT_TRANSFORM, &paint)) { - /* Callbacks may select another palette on the same face. */ - hb_vector_t palette_copy; - palette_copy.extend (palette_array); - if (unlikely (palette_copy.in_error ())) - return false; - palette_array = palette_copy.as_array (); - hb_ft_paint_context_t c (ft_font, font, paint_funcs, paint_data, palette_array, palette_index, foreground); From e4802120b6aa00dc08f3c02ce60d05088d928bf2 Mon Sep 17 00:00:00 2001 From: ebraminio Date: Tue, 10 Nov 2026 20:56:23 +0330 Subject: [PATCH 04/18] [subset] Keep hinting for fonts that require it (#6588) * [subset] Keep hinting for fonts that require it Some legacy fonts have hinting programs that must be run for correct rendering; dropping them changes glyph advances and outlines. FreeType refuses to load these fonts without hinting, so do the same in the subsetter by ignoring HB_SUBSET_FLAGS_NO_HINTING for them. Only TrueType-outline fonts qualify. Identify them by family name, and by the length and checksum of their cvt, fpgm, and prep tables. The lists and the name-to-ASCII semantics are ported from FreeType's src/truetype/ttobjs.c; fontations has the same logic in read-fonts/src/tables/glyf/hint_reliant.rs. Keep the detection in hb-subset-hinting.hh rather than the subsetter, and add tests for both paths. Assisted-by: DeepSeek * [subset] Refine hint-dependent font detection - Store family names in a fixed-size table to avoid relocations. - Read the name table directly instead of building the name accelerator, and select the record with FreeType's platform and language priority. - Use hb_vector_t::set_storage() for the name buffer; treat an allocation failure as a non-match. - Pick the family name the way FreeType does: honor the OS/2 WWS bit, and do not fall through to a lower-priority family name when the preferred one exists but does not match. - Add equality operators and use CheckSum::set_for_data() for table checksums, rejecting unaligned data and handling the trailing bytes. - Use face->table.glyf and drop the beyond-64K guard. - Use ISALPHA/TOUPPER for the PDF randomization tag check. - Add a regression test for the OS/2 WWS family selection. Assisted-by: DeepSeek * [perf] Add NO_HINTING subset benchmarks Add a per-test NO_HINTING flag and enable it for the static TrueType font benchmarks, so subsetting through the hint-dependent-font detection path is measured. Benchmark names get a /nohinting suffix. Assisted-by: DeepSeek * [subset] Allow unaligned and unpadded checksum data CalcTableChecksum() can add a trailing partial word. Use that so _table_checksum() can pass arbitrary table data directly to CheckSum::set_for_data() instead of rejecting unaligned data and splitting off the padded prefix. Add unit coverage for padded, unpadded, and unaligned data. Assisted-by: DeepSeek * [subset] Rename and cache the hint-dependent face check Prefix the entry point with _hb_subset, and cache the answer in face user data so repeated subsetting of the same face does not repeat the name and table scans. Assisted-by: DeepSeek * [subset] Avoid allocating for the hint-dependent cache Store the hint_dependent_cache_t value in the face user-data pointer instead of allocating a bool. UNCACHED is zero, CACHED_FALSE is one, and CACHED_TRUE is two. Assisted-by: DeepSeek * [test] Validate checksums against Python-generated vectors Generate deterministic buffers and expected OpenType checksums with an independent Python implementation, covering unaligned offsets and lengths that are not multiples of four. The generator is committed as src/generate-checksum-vectors.py and rewrites the marked block in the unit test. Assisted-by: DeepSeek * [test] Drop the checksum vector generator Keep the Python-generated vectors embedded in test-checksum.cc, but remove the generator script and its markers. The comment records that the values were generated independently with Python. Assisted-by: DeepSeek * [subset] Use CheckSum::CalcTableChecksum directly Drop the trivial _table_checksum() wrapper and call CheckSum::CalcTableChecksum() from the table-ID builder. Assisted-by: DeepSeek * [subset] Release the sanitized name table hb_blob_ptr_t does not destroy its blob in its destructor, so add a scope guard to release it on every return path. Assisted-by: DeepSeek * [subset] Limit cache enum scope * [subset] Use dagger iteration for hint lists Replace the family-name and font-ID membership loops with hb_iter/hb_map/hb_any, and name the family-name capacity used by the table and its iterator. Assisted-by: DeepSeek --- perf/benchmark-subset.cc | 34 +-- src/hb-open-type.hh | 13 +- src/hb-subset-hinting.hh | 456 +++++++++++++++++++++++++++++++++++++++ src/hb-subset-plan.cc | 8 + src/hb-subset.h | 3 +- src/meson.build | 2 + src/test-checksum.cc | 167 ++++++++++++++ test/api/test-subset.c | 269 +++++++++++++++++++++++ 8 files changed, 935 insertions(+), 17 deletions(-) create mode 100644 src/hb-subset-hinting.hh create mode 100644 src/test-checksum.cc diff --git a/perf/benchmark-subset.cc b/perf/benchmark-subset.cc index b86150a37..e1cae862a 100644 --- a/perf/benchmark-subset.cc +++ b/perf/benchmark-subset.cc @@ -55,21 +55,22 @@ struct test_input_t unsigned max_subset_size; const axis_location_t *instance_opts; unsigned num_instance_opts; + bool no_hinting; } default_tests[] = { - {SUBSET_FONT_BASE_PATH "Roboto-Regular.ttf", 1000, nullptr, 0}, - {SUBSET_FONT_BASE_PATH "Amiri-Regular.ttf", 4096, nullptr, 0}, - {SUBSET_FONT_BASE_PATH "NotoNastaliqUrdu-Regular.ttf", 1400, nullptr, 0}, - {SUBSET_FONT_BASE_PATH "NotoSansDevanagari-Regular.ttf", 1000, nullptr, 0}, - {SUBSET_FONT_BASE_PATH "Mplus1p-Regular.ttf", 10000, nullptr, 0}, - {SUBSET_FONT_BASE_PATH "SourceHanSans-Regular_subset.otf", 10000, nullptr, 0}, - {SUBSET_FONT_BASE_PATH "SourceSansPro-Regular.otf", 2000, nullptr, 0}, - {SUBSET_FONT_BASE_PATH "AdobeVFPrototype.otf", 300, nullptr, 0}, - {SUBSET_FONT_BASE_PATH "MPLUS1-Variable.ttf", 6000, _mplus_instance_opts, ARRAY_LEN (_mplus_instance_opts)}, - {SUBSET_FONT_BASE_PATH "RobotoFlex-Variable.ttf", 900, _roboto_flex_instance_opts, ARRAY_LEN (_roboto_flex_instance_opts)}, - {SUBSET_FONT_BASE_PATH "Fraunces.ttf", 900, _fraunces_partial_instance_opts, ARRAY_LEN (_fraunces_partial_instance_opts)}, + {SUBSET_FONT_BASE_PATH "Roboto-Regular.ttf", 1000, nullptr, 0, true}, + {SUBSET_FONT_BASE_PATH "Amiri-Regular.ttf", 4096, nullptr, 0, true}, + {SUBSET_FONT_BASE_PATH "NotoNastaliqUrdu-Regular.ttf", 1400, nullptr, 0, true}, + {SUBSET_FONT_BASE_PATH "NotoSansDevanagari-Regular.ttf", 1000, nullptr, 0, true}, + {SUBSET_FONT_BASE_PATH "Mplus1p-Regular.ttf", 10000, nullptr, 0, false}, + {SUBSET_FONT_BASE_PATH "SourceHanSans-Regular_subset.otf", 10000, nullptr, 0, false}, + {SUBSET_FONT_BASE_PATH "SourceSansPro-Regular.otf", 2000, nullptr, 0, false}, + {SUBSET_FONT_BASE_PATH "AdobeVFPrototype.otf", 300, nullptr, 0, false}, + {SUBSET_FONT_BASE_PATH "MPLUS1-Variable.ttf", 6000, _mplus_instance_opts, ARRAY_LEN (_mplus_instance_opts), false}, + {SUBSET_FONT_BASE_PATH "RobotoFlex-Variable.ttf", 900, _roboto_flex_instance_opts, ARRAY_LEN (_roboto_flex_instance_opts), false}, + {SUBSET_FONT_BASE_PATH "Fraunces.ttf", 900, _fraunces_partial_instance_opts, ARRAY_LEN (_fraunces_partial_instance_opts), false}, #if 0 - {"perf/fonts/NotoSansCJKsc-VF.ttf", 100000}, + {"perf/fonts/NotoSansCJKsc-VF.ttf", 100000, nullptr, 0, false}, #endif }; @@ -156,8 +157,13 @@ static void BM_subset (benchmark::State &state, hb_subset_input_t* input = hb_subset_input_create_or_fail (); assert (input); + unsigned flags = 0; + if (test_input.no_hinting) + flags |= HB_SUBSET_FLAGS_NO_HINTING; if (retain_gids) - hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS); + flags |= HB_SUBSET_FLAGS_RETAIN_GIDS; + if (flags) + hb_subset_input_set_flags (input, flags); switch (operation) { @@ -219,6 +225,8 @@ static void test_subset (operation_t op, strcat (name, "/"); const char *p = strrchr (test_input.font_path, '/'); strcat (name, p ? p + 1 : test_input.font_path); + if (test_input.no_hinting) + strcat (name, "/nohinting"); if (retain_gids) strcat (name, "/retaingids"); diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index eab02852c..d802c9c2c 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -346,19 +346,26 @@ struct CheckSum : HBUINT32 { CheckSum& operator = (uint32_t i) { HBUINT32::operator= (i); return *this; } - /* This is reference implementation from the spec. */ + /* This is reference implementation from the spec, extended to handle a + * trailing partial word. */ static uint32_t CalcTableChecksum (const HBUINT32 *Table, uint32_t Length) { uint32_t Sum = 0L; - assert (0 == (Length & 3)); const HBUINT32 *EndPtr = Table + Length / HBUINT32::static_size; while (Table < EndPtr) Sum += *Table++; + + uint32_t remainder = Length & (HBUINT32::static_size - 1); + if (remainder) + { + const uint8_t *p = (const uint8_t *) EndPtr; + for (uint32_t i = 0; i < remainder; i++) + Sum += (uint32_t) p[i] << (24 - 8 * i); + } return Sum; } - /* Note: data should be 4byte aligned and have 4byte padding at the end. */ void set_for_data (const void *data, unsigned int length) { *this = CalcTableChecksum ((const HBUINT32 *) data, length); } diff --git a/src/hb-subset-hinting.hh b/src/hb-subset-hinting.hh new file mode 100644 index 000000000..bd66d068c --- /dev/null +++ b/src/hb-subset-hinting.hh @@ -0,0 +1,456 @@ +/* + * Copyright © 2026 Ebrahim Byagowi + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + */ + +#ifndef HB_SUBSET_HINTING_HH +#define HB_SUBSET_HINTING_HH + +#include "hb.hh" +#include "hb-open-type.hh" +#include "hb-ot-face.hh" +#include "hb-ot-glyf-table.hh" +#include "hb-ot-name-table.hh" +#include "hb-ot-os2-table.hh" +#include "hb-utf.hh" + +#ifndef HB_NO_NAME +/* Some legacy fonts have hinting programs that are required for correct + * rendering; dropping them changes glyph advances and outlines. FreeType + * likewise refuses to load these fonts without hinting. The family names are + * from src/truetype/ttobjs.c in FreeType. */ +/* Longest family name in the table, including NUL. */ +static constexpr unsigned HINT_DEPENDENT_FAMILY_NAME_SIZE = 19; + +static const char hint_dependent_font_families[][HINT_DEPENDENT_FAMILY_NAME_SIZE] = { + "cpop", "DFGirl-W6-WIN-BF", "DFGothic-EB", "DFGyoSho-Lt", + "DFHei", "DFHSGothic-W5", "DFHSMincho-W3", "DFHSMincho-W7", + "DFKaiSho-SB", "DFKaiShu", "DFKai-SB", "DFMing", + "DLC", "HuaTianKaiTi?", "HuaTianSongTi?", "Ming(for ISO10646)", + "MingLiU", "MingMedium", "PMingLiU", "MingLi43", +}; + +/* Choose the name record FreeType would use for @name_id: + * Windows English, then Macintosh English/Roman, then Unicode. */ +static inline const OT::NameRecord * +_find_hint_dependent_name_record (const OT::name &name, + hb_ot_name_id_t name_id, + bool *utf16) +{ + const OT::NameRecord *windows = nullptr; + const OT::NameRecord *apple_english = nullptr; + const OT::NameRecord *apple_roman = nullptr; + const OT::NameRecord *unicode = nullptr; + bool windows_is_english = false; + + for (unsigned i = 0; i < (unsigned) name.count; i++) + { + const OT::NameRecord &record = name.nameRecordZ[i]; + if (record.nameID != name_id || !record.length) continue; + + switch ((unsigned) record.platformID) + { + case 0: + case 2: unicode = &record; break; + + case 1: + if (record.languageID == 0) apple_english = &record; + if (record.encodingID == 0) apple_roman = &record; + break; + + case 3: { + bool english = (record.languageID & 0x3ff) == 0x009; + if ((!windows || english) && + (record.encodingID == 0 || record.encodingID == 1 || + record.encodingID == 10)) + { + windows = &record; + windows_is_english = english; + } + break; + } + } + } + + const OT::NameRecord *apple = apple_english ? apple_english : apple_roman; + if (windows && (!apple || windows_is_english)) + { + *utf16 = true; + return windows; + } + if (apple) + { + *utf16 = false; + return apple; + } + if (unicode) + { + *utf16 = true; + return unicode; + } + + return nullptr; +} + +static inline bool +_name_matches_hint_dependent_family (hb_face_t *face, + hb_ot_name_id_t name_id, + bool *found) +{ + *found = false; + hb_blob_ptr_t name_table = + hb_sanitize_context_t ().reference_table (face); + HB_SCOPE_GUARD (name_table.destroy ()); + + unsigned table_length = name_table.get_length (); + if (unlikely (!table_length)) return false; + + const OT::name &table = *name_table; + bool utf16 = false; + const OT::NameRecord *record = + _find_hint_dependent_name_record (table, name_id, &utf16); + if (unlikely (!record)) return false; + + *found = true; + + unsigned string_offset = table.stringOffset; + if (unlikely (string_offset >= table_length)) return false; + + unsigned pool_length = table_length - string_offset; + unsigned record_offset = record->offset; + if (unlikely (record_offset >= pool_length)) return false; + + unsigned record_length = + hb_min ((unsigned) record->length, pool_length - record_offset); + const char *string_data = + (const char *) &table + string_offset + record_offset; + unsigned max_chars = utf16 ? record_length / 2 : record_length; + + char stack_name[128]; + hb_vector_t name; + if (max_chars + 1 <= sizeof (stack_name)) + { + name.set_storage (stack_name); + name.shrink (max_chars + 1); + } + else if (unlikely (!name.resize (max_chars + 1))) + return false; + + char *name_string = &name[0]; + char *out = name_string; + if (utf16) + { + for (unsigned i = 0; i + 1 < record_length; i += 2) + { + uint32_t cp = + ((uint8_t) string_data[i] << 8) | (uint8_t) string_data[i + 1]; + if (!cp) break; + *out++ = (cp >= 32 && cp <= 127) ? (char) cp : '?'; + } + } + else + { + for (unsigned i = 0; i < record_length; i++) + { + uint8_t cp = string_data[i]; + if (!cp) break; + *out++ = (cp >= 32 && cp <= 127) ? (char) cp : '?'; + } + } + *out = '\0'; + + /* PDF subset tags are exactly six uppercase ASCII letters followed by + * `+`; FreeType checks the same with ft_isupper(), so don't accept + * lowercase or digits here. */ + const char *family = name_string; + bool tagged = + (uint8_t *) out - (uint8_t *) name_string >= 8 && family[6] == '+'; + if (tagged) + for (unsigned i = 0; i < 6; i++) + if (!ISALPHA ((unsigned char) family[i]) || + TOUPPER ((unsigned char) family[i]) != (unsigned char) family[i]) + { + tagged = false; + break; + } + if (tagged) family += 7; + + return + + hb_iter (hint_dependent_font_families) + | hb_map ([&] (const char (&candidate)[HINT_DEPENDENT_FAMILY_NAME_SIZE]) + { return strstr (family, candidate) != nullptr; }) + | hb_any + ; +} +#endif + +struct hint_dependent_table_id_t +{ + bool operator== (const hint_dependent_table_id_t &o) const + { return checksum == o.checksum && length == o.length; } + + uint32_t checksum; + uint32_t length; +}; + +struct hint_dependent_font_id_t +{ + bool operator== (const hint_dependent_font_id_t &o) const + { return cvt == o.cvt && fpgm == o.fpgm && prep == o.prep; } + + hint_dependent_table_id_t cvt; + hint_dependent_table_id_t fpgm; + hint_dependent_table_id_t prep; +}; + +/* cvt/fpgm/prep identities for fonts that FreeType identifies even without a + * usable name table, from src/truetype/ttobjs.c in FreeType. */ +static const hint_dependent_font_id_t hint_dependent_font_ids[] = { + /* MingLiU 1995 */ + {{0x05BCF058, 0x000002E4}, + {0x28233BF1, 0x000087C4}, + {0xA344A1EA, 0x000001E1}}, + /* MingLiU 1996- */ + {{0x05BCF058, 0x000002E4}, + {0x28233BF1, 0x000087C4}, + {0xA344A1EB, 0x000001E1}}, + /* DFGothic-EB */ + {{0x12C3EBB2, 0x00000350}, + {0xB680EE64, 0x000087A7}, + {0xCE939563, 0x00000758}}, + /* DFGyoSho-Lt */ + {{0x11E5EAD4, 0x00000350}, + {0xCE5956E9, 0x0000BC85}, + {0x8272F416, 0x00000045}}, + /* DFHei-Md-HK-BF */ + {{0x1257EB46, 0x00000350}, + {0xF699D160, 0x0000715F}, + {0xD222F568, 0x000003BC}}, + /* DFHSGothic-W5 */ + {{0x1262EB4E, 0x00000350}, + {0xE86A5D64, 0x00007940}, + {0x7850F729, 0x000005FF}}, + /* DFHSMincho-W3 */ + {{0x122DEB0A, 0x00000350}, + {0x3D16328A, 0x0000859B}, + {0xA93FC33B, 0x000002CB}}, + /* DFHSMincho-W7 */ + {{0x125FEB26, 0x00000350}, + {0xA5ACC982, 0x00007EE1}, + {0x90999196, 0x0000041F}}, + /* DFKaiShu */ + {{0x11E5EAD4, 0x00000350}, + {0x5A30CA3B, 0x00009063}, + {0x13A42602, 0x0000007E}}, + /* DFKaiShu, variant */ + {{0x11E5EAD4, 0x00000350}, + {0xA6E78C01, 0x00008998}, + {0x13A42602, 0x0000007E}}, + /* DFKaiShu-Md-HK-BF */ + {{0x11E5EAD4, 0x00000360}, + {0x9DB282B2, 0x0000C06E}, + {0x53E6D7CA, 0x00000082}}, + /* DFMing-Bd-HK-BF */ + {{0x1243EB18, 0x00000350}, + {0xBA0A8C30, 0x000074AD}, + {0xF3D83409, 0x0000037B}}, + /* DLCLiShu */ + {{0x07DCF546, 0x00000308}, + {0x40FE7C90, 0x00008E2A}, + {0x608174B5, 0x0000007A}}, + /* DLCHayBold */ + {{0xEB891238, 0x00000308}, + {0xD2E4DCD4, 0x0000676F}, + {0x8EA5F293, 0x000003B8}}, + /* HuaTianKaiTi */ + {{0xFFFBFFFC, 0x00000008}, + {0x9C9E48B8, 0x0000BEA2}, + {0x70020112, 0x00000008}}, + /* HuaTianSongTi */ + {{0xFFFBFFFC, 0x00000008}, + {0x0A5A0483, 0x00017C39}, + {0x70020112, 0x00000008}}, + /* NEC fadpop7.ttf */ + {{0x00000000, 0x00000000}, + {0x40C92555, 0x000000E5}, + {0xA39B58E3, 0x0000117C}}, + /* NEC fadrei5.ttf */ + {{0x00000000, 0x00000000}, + {0x33C41652, 0x000000E5}, + {0x26D6C52A, 0x00000F6A}}, + /* NEC fangot7.ttf */ + {{0x00000000, 0x00000000}, + {0x6DB1651D, 0x0000019D}, + {0x6C6E4B03, 0x00002492}}, + /* NEC fangyo5.ttf */ + {{0x00000000, 0x00000000}, + {0x40C92555, 0x000000E5}, + {0xDE51FAD0, 0x0000117C}}, + /* NEC fankyo5.ttf */ + {{0x00000000, 0x00000000}, + {0x85E47664, 0x000000E5}, + {0xA6C62831, 0x00001CAA}}, + /* NEC fanrgo5.ttf */ + {{0x00000000, 0x00000000}, + {0x2D891CFD, 0x0000019D}, + {0xA0604633, 0x00001DE8}}, + /* NEC fangot5.ttc */ + {{0x00000000, 0x00000000}, + {0x40AA774C, 0x000001CB}, + {0x9B5CAA96, 0x00001F9A}}, + /* NEC fanmin3.ttc */ + {{0x00000000, 0x00000000}, + {0x0D3DE9CB, 0x00000141}, + {0xD4127766, 0x00002280}}, + /* NEC FA-Gothic, 1996 */ + {{0x00000000, 0x00000000}, + {0x4A692698, 0x000001F0}, + {0x340D4346, 0x00001FCA}}, + /* NEC FA-Minchou, 1996 */ + {{0x00000000, 0x00000000}, + {0xCD34C604, 0x00000166}, + {0x6CF31046, 0x000022B0}}, + /* NEC FA-RoundGothicB, 1996 */ + {{0x00000000, 0x00000000}, + {0x5DA75315, 0x0000019D}, + {0x40745A5F, 0x000022E0}}, + /* NEC FA-RoundGothicM, 1996 */ + {{0x00000000, 0x00000000}, + {0xF055FC48, 0x000001C2}, + {0x3900DED3, 0x00001E18}}, + /* MINGLI.TTF, 1992 */ + {{0x00170003, 0x00000060}, + {0xDBB4306E, 0x000058AA}, + {0xD643482A, 0x00000035}}, + /* DFHei-Bd-WIN-HK-BF */ + {{0x1269EB58, 0x00000350}, + {0x5CD5957A, 0x00006A4E}, + {0xF758323A, 0x00000380}}, + /* DFMing-Md-WIN-HK-BF */ + {{0x122FEB0B, 0x00000350}, + {0x7F10919A, 0x000070A9}, + {0x7CD7E7B7, 0x0000025C}}, +}; + +static inline hint_dependent_table_id_t +_table_id (hb_face_t *face, hb_tag_t tag) +{ + hint_dependent_table_id_t id = {0, 0}; + + hb_blob_t *blob = hb_face_reference_table (face, tag); + unsigned length = hb_blob_get_length (blob); + if (length) + { + unsigned data_length; + const char *data = hb_blob_get_data (blob, &data_length); + id.checksum = OT::CheckSum::CalcTableChecksum ( + (const OT::HBUINT32 *) data, data_length); + id.length = data_length; + } + hb_blob_destroy (blob); + + return id; +} + +static inline bool +_matches_hint_dependent_ids (hb_face_t *face) +{ + hint_dependent_font_id_t id; + id.cvt = _table_id (face, HB_TAG ('c', 'v', 't', ' ')); + id.fpgm = _table_id (face, HB_TAG ('f', 'p', 'g', 'm')); + id.prep = _table_id (face, HB_TAG ('p', 'r', 'e', 'p')); + + return + + hb_iter (hint_dependent_font_ids) + | hb_map ([&] (const hint_dependent_font_id_t &candidate) { return id == candidate; }) + | hb_any + ; +} + +static hb_user_data_key_t _hb_subset_hint_dependent_user_data_key = {0}; + +static inline bool +_hb_subset_face_requires_hinting_uncached (hb_face_t *face) +{ + if (!face->table.glyf->has_data ()) return false; + +#ifndef HB_NO_NAME + /* Match FreeType's choice: with the OS/2 WWS bit set the typographic + * family is preferred; otherwise the WWS family wins over it. */ + hb_ot_name_id_t name_ids[3]; + unsigned name_count; + if (face->table.OS2->fsSelection & OT::OS2::WWS) + { + name_ids[0] = HB_OT_NAME_ID_TYPOGRAPHIC_FAMILY; + name_ids[1] = HB_OT_NAME_ID_FONT_FAMILY; + name_count = 2; + } + else + { + name_ids[0] = HB_OT_NAME_ID_WWS_FAMILY; + name_ids[1] = HB_OT_NAME_ID_TYPOGRAPHIC_FAMILY; + name_ids[2] = HB_OT_NAME_ID_FONT_FAMILY; + name_count = 3; + } + for (unsigned i = 0; i < name_count; i++) + { + bool found = false; + if (_name_matches_hint_dependent_family (face, name_ids[i], &found)) + return true; + /* Do not fall through to a lower-priority family name if the + * preferred one exists but does not match. */ + if (found) break; + } +#endif + + return _matches_hint_dependent_ids (face); +} + +static inline bool +_hb_subset_face_requires_hinting (hb_face_t *face) +{ + enum class hint_dependent_cache_t : uintptr_t + { + UNCACHED, + CACHED_FALSE, + CACHED_TRUE, + }; + /* The user-data pointer is the enum value; UNCACHED is zero. */ + hint_dependent_cache_t cached = static_cast ( + (uintptr_t) hb_face_get_user_data (face, + &_hb_subset_hint_dependent_user_data_key)); + if (cached != hint_dependent_cache_t::UNCACHED) + return cached == hint_dependent_cache_t::CACHED_TRUE; + + bool result = _hb_subset_face_requires_hinting_uncached (face); + + hint_dependent_cache_t cache = result ? hint_dependent_cache_t::CACHED_TRUE + : hint_dependent_cache_t::CACHED_FALSE; + hb_face_set_user_data (face, &_hb_subset_hint_dependent_user_data_key, + (void *) static_cast (cache), + nullptr, false); + + return result; +} + +#endif /* HB_SUBSET_HINTING_HH */ diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index bc0238ae5..8f661cb18 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -31,6 +31,7 @@ #include "hb-set.hh" #include "hb-subset.h" #include "hb-unicode.h" +#include "hb-subset-hinting.hh" #include "hb-ot-cmap-table.hh" #include "hb-ot-glyf-table.hh" @@ -761,6 +762,13 @@ hb_subset_plan_t::hb_subset_plan_t (hb_face_t *face, successful = true; flags = input->flags; + if ((flags & HB_SUBSET_FLAGS_NO_HINTING) && _hb_subset_face_requires_hinting (face)) + { + DEBUG_MSG (SUBSET, nullptr, + "Keeping hinting because the font requires it."); + flags &= ~HB_SUBSET_FLAGS_NO_HINTING; + } + unicode_to_new_gid_list.init (); name_ids = *input->sets.name_ids; diff --git a/src/hb-subset.h b/src/hb-subset.h index ec3171873..27e94eb67 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -59,7 +59,8 @@ typedef struct hb_subset_plan_t hb_subset_plan_t; * hb_subset_flags_t: * @HB_SUBSET_FLAGS_DEFAULT: all flags at their default value of false. * @HB_SUBSET_FLAGS_NO_HINTING: If set hinting instructions will be dropped in - * the produced subset. Otherwise hinting instructions will be retained. + * the produced subset. Otherwise hinting instructions will be retained. This + * flag is ignored for fonts whose hinting is required for correct rendering. * @HB_SUBSET_FLAGS_RETAIN_GIDS: If set glyph indices will not be modified in * the produced subset. If glyphs are dropped their indices will be retained * as an empty glyph. This is implied when the subset retains a table that diff --git a/src/meson.build b/src/meson.build index 93f5d4765..d6ccf2e23 100644 --- a/src/meson.build +++ b/src/meson.build @@ -401,6 +401,7 @@ hb_subset_sources = files( 'hb-subset-cff2.cc', 'hb-subset-cff2-round.hh', 'hb-subset-cff2-to-cff1.hh', + 'hb-subset-hinting.hh', 'hb-subset-input.cc', 'hb-subset-input.hh', 'hb-subset-instancer-iup.hh', @@ -997,6 +998,7 @@ if get_option('tests').enabled() 'test-bimap': ['test-bimap.cc', 'hb-static.cc'], 'test-cache': ['test-cache.cc'], 'test-cff': ['test-cff.cc', 'hb-static.cc'], + 'test-checksum': ['test-checksum.cc', 'hb-static.cc'], 'test-colr': ['test-colr.cc', 'hb-static.cc'], 'test-classdef-graph': ['graph/test-classdef-graph.cc', 'hb-static.cc', 'graph/gsubgpos-context.cc'], 'test-result': ['test-result.cc', 'hb-static.cc'], diff --git a/src/test-checksum.cc b/src/test-checksum.cc new file mode 100644 index 000000000..6b70c75f7 --- /dev/null +++ b/src/test-checksum.cc @@ -0,0 +1,167 @@ +/* + * Copyright © 2026 Ebrahim Byagowi + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ + +#include "hb.hh" +#include "hb-open-type.hh" + +static void +test_calc_table_checksum () +{ + static const uint8_t data[] = {'a', 'b', 'c', 'd', 'e'}; + const OT::HBUINT32 *words = (const OT::HBUINT32 *) data; + + hb_always_assert (OT::CheckSum::CalcTableChecksum (words, 0) == 0u); + hb_always_assert (OT::CheckSum::CalcTableChecksum (words, 1) == 0x61000000u); + hb_always_assert (OT::CheckSum::CalcTableChecksum (words, 2) == 0x61620000u); + hb_always_assert (OT::CheckSum::CalcTableChecksum (words, 3) == 0x61626300u); + hb_always_assert (OT::CheckSum::CalcTableChecksum (words, 4) == 0x61626364u); + hb_always_assert (OT::CheckSum::CalcTableChecksum (words, 5) == 0xC6626364u); + + /* The data pointer is deliberately unaligned. */ + hb_always_assert (OT::CheckSum::CalcTableChecksum ( + (const OT::HBUINT32 *) (data + 1), 4) == 0x62636465u); + hb_always_assert (OT::CheckSum::CalcTableChecksum ( + (const OT::HBUINT32 *) (data + 1), 3) == 0x62636400u); + + OT::CheckSum checksum; + for (unsigned length = 0; length <= 5; length++) + { + checksum.set_for_data (data, length); + hb_always_assert ((uint32_t) checksum == + OT::CheckSum::CalcTableChecksum (words, length)); + } + + checksum.set_for_data (data + 1, 4); + hb_always_assert ((uint32_t) checksum == 0x62636465u); +} + +/* The following vectors were generated once with Python's int.from_bytes(). + * They are embedded here rather than regenerated by a checked-in script. */ +static void +test_python_generated_checksums () +{ + static const uint8_t data[] = { + 0x94, 0x26, 0x60, 0xCD, 0xAD, 0x32, 0xF7, 0x18, 0xEF, 0xE1, + 0xC3, 0x9B, 0xC1, 0xE9, 0x65, 0xA4, 0x27, 0xE8, 0x28, 0x4E, + 0x5E, 0x87, 0x80, 0xF2, 0x20, 0x43, 0x86, 0xCC, 0x7D, 0x99, + 0x37, 0x2F, 0xA0, 0xC5, 0xCB, 0x47, 0x22, 0x44, 0x9C, 0x36, + }; + static const struct + { + unsigned offset; + unsigned length; + uint32_t checksum; + } cases[] = { + {0, 0, 0x00000000u}, + {0, 1, 0x94000000u}, + {0, 2, 0x94260000u}, + {0, 3, 0x94266000u}, + {0, 4, 0x942660CDu}, + {0, 5, 0x412660CDu}, + {0, 6, 0x415860CDu}, + {0, 7, 0x415957CDu}, + {0, 8, 0x415957E5u}, + {0, 9, 0x305957E5u}, + {0, 11, 0x313B1AE5u}, + {0, 13, 0xF23B1B80u}, + {0, 16, 0xF3248124u}, + {0, 19, 0x1B0CA924u}, + {0, 23, 0x79942972u}, + {0, 27, 0x99D7B064u}, + {0, 31, 0x1770E830u}, + {0, 32, 0x1770E85Fu}, + {1, 0, 0x00000000u}, + {1, 1, 0x26000000u}, + {1, 2, 0x26600000u}, + {1, 3, 0x2660CD00u}, + {1, 4, 0x2660CDADu}, + {1, 5, 0x5860CDADu}, + {1, 6, 0x5957CDADu}, + {1, 7, 0x5957E5ADu}, + {1, 8, 0x5957E69Cu}, + {1, 9, 0x3A57E69Cu}, + {1, 11, 0x3B1B819Cu}, + {1, 13, 0x241B825Du}, + {1, 16, 0x24812684u}, + {1, 19, 0x0CA97484u}, + {1, 23, 0x942A66E2u}, + {1, 27, 0xD7B13302u}, + {1, 31, 0x70E8627Fu}, + {1, 32, 0x70E8631Fu}, + {2, 0, 0x00000000u}, + {2, 1, 0x60000000u}, + {2, 2, 0x60CD0000u}, + {2, 3, 0x60CDAD00u}, + {2, 4, 0x60CDAD32u}, + {2, 5, 0x57CDAD32u}, + {2, 6, 0x57E5AD32u}, + {2, 7, 0x57E69C32u}, + {2, 8, 0x57E69D13u}, + {2, 9, 0x1AE69D13u}, + {2, 11, 0x1B825E13u}, + {2, 13, 0x80825EFCu}, + {2, 16, 0x812686E4u}, + {2, 19, 0xA974E4E4u}, + {2, 23, 0x2A67056Bu}, + {2, 27, 0xB13382AEu}, + {2, 31, 0xE8632347u}, + {2, 32, 0xE863240Cu}, + {3, 0, 0x00000000u}, + {3, 1, 0xCD000000u}, + {3, 2, 0xCDAD0000u}, + {3, 3, 0xCDAD3200u}, + {3, 4, 0xCDAD32F7u}, + {3, 5, 0xE5AD32F7u}, + {3, 6, 0xE69C32F7u}, + {3, 7, 0xE69D13F7u}, + {3, 8, 0xE69D14BAu}, + {3, 9, 0x819D14BAu}, + {3, 11, 0x825EFDBAu}, + {3, 13, 0x265EFE1Fu}, + {3, 16, 0x2686E647u}, + {3, 19, 0x74E56D47u}, + {3, 23, 0x6705B0C7u}, + {3, 27, 0x33834A4Du}, + {3, 31, 0x63240F84u}, + {3, 32, 0x6324104Fu}, + }; + + for (const auto &c : cases) + { + const uint8_t *p = data + c.offset; + hb_always_assert (OT::CheckSum::CalcTableChecksum ((const OT::HBUINT32 *) p, + c.length) == c.checksum); + OT::CheckSum checksum; + checksum.set_for_data (p, c.length); + hb_always_assert ((uint32_t) checksum == c.checksum); + } +} + +int +main () +{ + test_calc_table_checksum (); + test_python_generated_checksums (); + return 0; +} diff --git a/test/api/test-subset.c b/test/api/test-subset.c index 82d4b8bf5..eaa0826a5 100644 --- a/test/api/test-subset.c +++ b/test/api/test-subset.c @@ -820,6 +820,272 @@ test_subset_custom_glyph_mapping (void) hb_face_destroy (source); } +static hb_face_t * +_face_copy_tables (hb_face_t *source) +{ + hb_face_t *face = hb_face_builder_create (); + + hb_tag_t tags[32]; + unsigned offset = 0; + while (true) + { + unsigned count = G_N_ELEMENTS (tags); + hb_face_get_table_tags (source, offset, &count, tags); + if (!count) break; + + for (unsigned i = 0; i < count; i++) + { + hb_blob_t *blob = hb_face_reference_table (source, tags[i]); + hb_face_builder_add_table (face, tags[i], blob); + hb_blob_destroy (blob); + } + offset += count; + } + + return face; +} + +static hb_face_t * +_face_with_table (hb_face_t *source, hb_tag_t tag, const void *data, unsigned length) +{ + hb_face_t *face = _face_copy_tables (source); + hb_blob_t *blob = hb_blob_create_or_fail ((const char *) data, length, + HB_MEMORY_MODE_READONLY, NULL, NULL); + hb_face_builder_add_table (face, tag, blob); + hb_blob_destroy (blob); + + return face; +} + +static hb_face_t * +_face_with_name_table_and_wws (hb_face_t *source, + const void *name_data, unsigned name_length, + bool wws) +{ + hb_face_t *face = _face_copy_tables (source); + + hb_blob_t *name_blob = hb_blob_create_or_fail ((const char *) name_data, + name_length, + HB_MEMORY_MODE_READONLY, + NULL, NULL); + g_assert_nonnull (name_blob); + hb_face_builder_add_table (face, HB_TAG ('n','a','m','e'), name_blob); + hb_blob_destroy (name_blob); + + hb_blob_t *os2 = hb_face_reference_table (source, HB_TAG ('O','S','/','2')); + hb_blob_t *os2_copy = hb_blob_copy_writable_or_fail (os2); + hb_blob_destroy (os2); + g_assert_nonnull (os2_copy); + + unsigned length; + char *data = (char *) hb_blob_get_data_writable (os2_copy, &length); + g_assert_cmpuint (length, >=, 64); + /* fsSelection is at offset 62 in OS/2 version 0 and later. */ + uint16_t fs_selection = ((uint8_t) data[62] << 8) | (uint8_t) data[63]; + if (wws) + fs_selection |= 1u << 8; + else + fs_selection &= ~(1u << 8); + data[62] = fs_selection >> 8; + data[63] = fs_selection; + + hb_face_builder_add_table (face, HB_TAG ('O','S','/','2'), os2_copy); + hb_blob_destroy (os2_copy); + + return face; +} + +static hb_blob_t * +_blob_with_checksum (uint32_t checksum, unsigned length) +{ + char *data = (char *) g_malloc0 (length ? length : 1); + if (length >= 4) + { + data[0] = checksum >> 24; + data[1] = checksum >> 16; + data[2] = checksum >> 8; + data[3] = checksum; + } + return hb_blob_create_or_fail (data, length, HB_MEMORY_MODE_WRITABLE, + data, g_free); +} + +static void +test_subset_no_hinting_ignored_for_hint_dependent_font (void) +{ +#ifndef HB_NO_NAME + /* Minimal name table with Font Family = "MingLiU". */ + static const unsigned char name_table[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x12, + 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, 0x00, 0x01, 0x00, 0x0E, 0x00, 0x00, + 0x00, 0x4D, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x67, + 0x00, 0x4C, 0x00, 0x69, 0x00, 0x55, + }; + /* "HuaTianKaiTi" followed by U+4F53. FreeType reads the non-ASCII + * character as `?`, matching the list entry "HuaTianKaiTi?". */ + static const unsigned char name_table_question[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x12, + 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, 0x00, 0x01, 0x00, 0x1A, 0x00, 0x00, + 0x00, 0x48, 0x00, 0x75, 0x00, 0x61, 0x00, 0x54, + 0x00, 0x69, 0x00, 0x61, 0x00, 0x6E, 0x00, 0x4B, + 0x00, 0x61, 0x00, 0x69, 0x00, 0x54, 0x00, 0x69, + 0x4F, 0x53, + }; + static const hb_tag_t hint_tags[] = { + HB_TAG ('c','v','t',' '), + HB_TAG ('f','p','g','m'), + HB_TAG ('p','r','e','p'), + }; + + hb_face_t *source = hb_test_open_font_file ("fonts/Roboto-Regular.abc.ttf"); + hb_face_t *face = _face_with_table (source, HB_TAG ('n','a','m','e'), + name_table, sizeof (name_table)); + hb_face_t *face_question = _face_with_table (source, HB_TAG ('n','a','m','e'), + name_table_question, + sizeof (name_table_question)); + + hb_set_t *codepoints = hb_set_create (); + hb_set_add (codepoints, 'a'); + + for (unsigned i = 0; i < 3; i++) + { + bool hint_dependent = i != 0; + hb_face_t *target = i == 0 ? source : i == 1 ? face : face_question; + + hb_subset_input_t *input = hb_subset_test_create_input (codepoints); + hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING); + hb_face_t *subset = hb_subset_or_fail (target, input); + g_assert_nonnull (subset); + + for (unsigned j = 0; j < G_N_ELEMENTS (hint_tags); j++) + { + hb_blob_t *blob = hb_face_reference_table (subset, hint_tags[j]); + g_assert_true (!!hb_blob_get_length (blob) == hint_dependent); + hb_blob_destroy (blob); + } + + hb_face_destroy (subset); + hb_subset_input_destroy (input); + } + + hb_set_destroy (codepoints); + hb_face_destroy (face_question); + hb_face_destroy (face); + hb_face_destroy (source); +#endif +} + +static void +test_subset_no_hinting_hint_dependent_wws_family (void) +{ +#ifndef HB_NO_NAME + /* Font Family = "NotTricky", Typographic Family = "MingLiU", and + * WWS Family = "NotTricky". With the OS/2 WWS bit set FreeType + * picks the typographic family and keeps hints; with it clear it + * picks the WWS family and must not fall through to the typographic + * one. */ + static const unsigned char name_table[] = { + 0x00, 0x00, 0x00, 0x03, 0x00, 0x2A, + 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, 0x00, 0x01, 0x00, 0x12, 0x00, 0x00, + 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, 0x00, 0x10, 0x00, 0x0E, 0x00, 0x12, + 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, 0x00, 0x15, 0x00, 0x12, 0x00, 0x20, + 0x00, 0x4E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x54, 0x00, 0x72, 0x00, 0x69, + 0x00, 0x63, 0x00, 0x6B, 0x00, 0x79, 0x00, 0x4D, 0x00, 0x69, 0x00, 0x6E, + 0x00, 0x67, 0x00, 0x4C, 0x00, 0x69, 0x00, 0x55, 0x00, 0x4E, 0x00, 0x6F, + 0x00, 0x74, 0x00, 0x54, 0x00, 0x72, 0x00, 0x69, 0x00, 0x63, 0x00, 0x6B, + 0x00, 0x79, + }; + static const hb_tag_t hint_tags[] = { + HB_TAG ('c','v','t',' '), + HB_TAG ('f','p','g','m'), + HB_TAG ('p','r','e','p'), + }; + + hb_face_t *source = hb_test_open_font_file ("fonts/Roboto-Regular.abc.ttf"); + hb_face_t *wws = _face_with_name_table_and_wws (source, name_table, + sizeof (name_table), true); + hb_face_t *no_wws = _face_with_name_table_and_wws (source, name_table, + sizeof (name_table), false); + + hb_set_t *codepoints = hb_set_create (); + hb_set_add (codepoints, 'a'); + + for (unsigned i = 0; i < 2; i++) + { + bool hint_dependent = i == 0; + hb_face_t *target = i == 0 ? wws : no_wws; + + hb_subset_input_t *input = hb_subset_test_create_input (codepoints); + hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING); + hb_face_t *subset = hb_subset_or_fail (target, input); + g_assert_nonnull (subset); + + for (unsigned j = 0; j < G_N_ELEMENTS (hint_tags); j++) + { + hb_blob_t *blob = hb_face_reference_table (subset, hint_tags[j]); + g_assert_true (!!hb_blob_get_length (blob) == hint_dependent); + hb_blob_destroy (blob); + } + + hb_face_destroy (subset); + hb_subset_input_destroy (input); + } + + hb_set_destroy (codepoints); + hb_face_destroy (no_wws); + hb_face_destroy (wws); + hb_face_destroy (source); +#endif +} + +static void +test_subset_no_hinting_ignored_for_hint_dependent_ids (void) +{ + static const struct { + hb_tag_t tag; + uint32_t checksum; + unsigned length; + } ids[] = { + {HB_TAG ('c','v','t',' '), 0x05BCF058, 0x000002E4}, + {HB_TAG ('f','p','g','m'), 0x28233BF1, 0x000087C4}, + {HB_TAG ('p','r','e','p'), 0xA344A1EA, 0x000001E1}, + }; + static const hb_tag_t hint_tags[] = { + HB_TAG ('c','v','t',' '), + HB_TAG ('f','p','g','m'), + HB_TAG ('p','r','e','p'), + }; + + hb_face_t *source = hb_test_open_font_file ("fonts/Roboto-Regular.abc.ttf"); + hb_face_t *face = _face_copy_tables (source); + for (unsigned i = 0; i < G_N_ELEMENTS (ids); i++) + { + hb_blob_t *blob = _blob_with_checksum (ids[i].checksum, ids[i].length); + hb_face_builder_add_table (face, ids[i].tag, blob); + hb_blob_destroy (blob); + } + + hb_set_t *codepoints = hb_set_create (); + hb_set_add (codepoints, 'a'); + hb_subset_input_t *input = hb_subset_test_create_input (codepoints); + hb_set_destroy (codepoints); + hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_NO_HINTING); + + hb_face_t *subset = hb_subset_or_fail (face, input); + g_assert_nonnull (subset); + for (unsigned i = 0; i < G_N_ELEMENTS (hint_tags); i++) + { + hb_blob_t *blob = hb_face_reference_table (subset, hint_tags[i]); + g_assert_cmpuint (hb_blob_get_length (blob), >, 0); + hb_blob_destroy (blob); + } + + hb_face_destroy (subset); + hb_subset_input_destroy (input); + hb_face_destroy (face); + hb_face_destroy (source); +} + static hb_blob_t* _copy_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) { @@ -1457,6 +1723,9 @@ main (int argc, char **argv) hb_test_add (test_subset_non_glyph_layout_table_does_not_retain_gids); #endif hb_test_add (test_subset_custom_glyph_mapping); + hb_test_add (test_subset_no_hinting_ignored_for_hint_dependent_font); + hb_test_add (test_subset_no_hinting_hint_dependent_wws_family); + hb_test_add (test_subset_no_hinting_ignored_for_hint_dependent_ids); hb_test_add (test_subset_sanitized_table_cache); #if !defined(HB_NO_OT_LAYOUT) && !defined(HB_NO_OT_LAYOUT_BLOCKLIST) hb_test_add (test_subset_gdef_blocklist); From f2390b0a2ecddba2431b4b119016ceb6c2eb2047 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Nov 2026 16:08:49 -0600 Subject: [PATCH 05/18] [subset] Merge CFF charstring commands in place, not by erasing (#6619) Passes 2 and 3 of CFF::specialize_commands() called hb_vector_t::remove_ordered() once per merged command, and each call shifts every command behind it, so a charstring of A mergeable line segments followed by T unmergeable commands cost A*T element moves, bounded only by HB_CFF_MAX_OPS: 32 s of CPU for one glyph of a 1.6 KB font with --downgrade-cff2, paid again on every serializer-buffer retry. Replace both loops with one helper, combine_commands(), that walks backwards exactly as before (each command absorbs its already-merged successor chunk while the predicate allows, matching fontTools order) but keeps finished commands packed at the tail and compacts the vector once at the end, so the work is linear. The two merge conditions (operator pair, args-length parity, combined args < maxstack) become the predicates verbatim and the merge order is unchanged. Adds test_specialized_many_commands() to src/test-cff.cc (100,000 unit rlineto followed by 100,000 empty hhcurveto must come back as 2,128 line commands plus the untouched hhcurveto commands); it takes 0.08 s with this change versus tens of seconds before. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-7TEMF5SE. Co-authored-by: Claude Opus 4.8 --- src/hb-cff-specializer.hh | 87 +++++++++++++++++++++------------------ src/test-cff.cc | 34 +++++++++++++++ 2 files changed, 80 insertions(+), 41 deletions(-) diff --git a/src/hb-cff-specializer.hh b/src/hb-cff-specializer.hh index 12bf3dc56..fdcf3bd2b 100644 --- a/src/hb-cff-specializer.hh +++ b/src/hb-cff-specializer.hh @@ -139,6 +139,37 @@ generalize_commands (hb_vector_t &commands) commands.push (result[i]); } +/* Merge each command into the one before it wherever can_combine allows, + * from the last command to the first. Finished commands are kept packed + * at the end of the vector and moved to the front once at the end, such + * that dropping a merged command does not shift everything behind it. */ +template +static void +combine_commands (hb_vector_t &commands, Pred can_combine) +{ + unsigned count = commands.length; + unsigned done = count; /* Finished commands are in [done, count). */ + for (unsigned i = count; i-- > 0;) + { + auto &prev = commands.arrayZ[i]; + while (done < count && can_combine (prev, commands.arrayZ[done])) + { + /* Merge into first command, keep its operator */ + for (const auto &arg : commands.arrayZ[done].args) + prev.args.push (arg); + done++; + } + done--; + if (done != i) + commands.arrayZ[done] = std::move (prev); + } + + if (!done) return; + for (unsigned i = done; i < count; i++) + commands.arrayZ[i - done] = std::move (commands.arrayZ[i]); + commands.shrink (count - done); +} + /* Specialize CharString commands to optimize bytecode size * * Follows fontTools approach: @@ -190,55 +221,29 @@ specialize_commands (hb_vector_t &commands, /* Pass 2: Combine adjacent hlineto/vlineto operators * hlineto can take multiple args alternating with vlineto * This saves operator bytes */ - for (int i = (int)commands.length - 1; i > 0; i--) + combine_commands (commands, [maxstack] (const cs_command_t &prev, const cs_command_t &cmd) { - auto &cmd = commands[i]; - auto &prev = commands[i-1]; - /* Different starting directions can combine only after an odd number * of alternating arguments in the preceding command. */ - if (((prev.op == OpCode_hlineto && cmd.op == OpCode_vlineto) || - (prev.op == OpCode_vlineto && cmd.op == OpCode_hlineto)) && - (prev.args.length & 1)) - { - /* Check stack depth */ - unsigned combined_args = prev.args.length + cmd.args.length; - if (combined_args < maxstack) - { - /* Merge into first command, keep its operator */ - for (unsigned j = 0; j < cmd.args.length; j++) - prev.args.push (cmd.args[j]); - commands.remove_ordered (i); - i++; /* Adjust for removed element */ - } - } - } + return ((prev.op == OpCode_hlineto && cmd.op == OpCode_vlineto) || + (prev.op == OpCode_vlineto && cmd.op == OpCode_hlineto)) && + (prev.args.length & 1) && + /* Check stack depth */ + prev.args.length + cmd.args.length < maxstack; + }); /* Pass 3: Combine adjacent identical operators */ - for (int i = (int)commands.length - 1; i > 0; i--) + combine_commands (commands, [maxstack] (const cs_command_t &prev, const cs_command_t &cmd) { - auto &cmd = commands[i]; - auto &prev = commands[i-1]; - /* Same-direction h/v commands can combine only after an even number * of alternating arguments. Other repeatable operators concatenate. */ - if (prev.op == cmd.op && - (cmd.op == OpCode_rlineto || cmd.op == OpCode_rrcurveto || - ((cmd.op == OpCode_hlineto || cmd.op == OpCode_vlineto) && - !(prev.args.length & 1)))) - { - /* Check stack depth */ - unsigned combined_args = prev.args.length + cmd.args.length; - if (combined_args < maxstack) - { - /* Merge args */ - for (unsigned j = 0; j < cmd.args.length; j++) - prev.args.push (cmd.args[j]); - commands.remove_ordered (i); - i++; /* Adjust for removed element */ - } - } - } + return prev.op == cmd.op && + (cmd.op == OpCode_rlineto || cmd.op == OpCode_rrcurveto || + ((cmd.op == OpCode_hlineto || cmd.op == OpCode_vlineto) && + !(prev.args.length & 1))) && + /* Check stack depth */ + prev.args.length + cmd.args.length < maxstack; + }); } /* Encode commands back to binary CharString */ diff --git a/src/test-cff.cc b/src/test-cff.cc index 95089e3ec..2153a0c48 100644 --- a/src/test-cff.cc +++ b/src/test-cff.cc @@ -103,6 +103,39 @@ test_specialized_fractional_geometry () } } +static void +test_specialized_many_commands () +{ + /* Combining lines must not get slower with the number of commands that + * follow them, and must leave those commands alone. */ + const unsigned n = 100000; + hb_vector_t commands; + for (unsigned i = 0; i < n; i++) + { + CFF::cs_command_t cmd (OpCode_rlineto); + CFF::number_t dx, dy; + dx.set_int ((i & 1) ? 0 : 1); + dy.set_int ((i & 1) ? 1 : 0); + cmd.args.push (dx); + cmd.args.push (dy); + commands.push (std::move (cmd)); + } + for (unsigned i = 0; i < n; i++) + commands.push (CFF::cs_command_t (OpCode_hhcurveto)); + CFF::specialize_commands (commands); + unsigned num_lines = (n + 46) / 47; + hb_always_assert (commands.length == num_lines + n); + unsigned num_args = 0; + for (unsigned i = 0; i < num_lines; i++) + { + hb_always_assert (commands[i].op == ((num_args & 1) ? OpCode_vlineto : OpCode_hlineto)); + num_args += commands[i].args.length; + } + hb_always_assert (num_args == n); + for (unsigned i = num_lines; i < commands.length; i++) + hb_always_assert (commands[i].op == OpCode_hhcurveto && !commands[i].args.length); +} + static void test_charset1_splits_long_ranges () { @@ -319,6 +352,7 @@ main (int argc, char **argv) test_index_count_limits (); test_specialized_line_geometry (); test_specialized_fractional_geometry (); + test_specialized_many_commands (); test_charset1_splits_long_ranges (); test_fd_select_sentinel (); test_fd_select_sentinel (); From c569b7fedea7d8ba4b1aec07f43f9987029d7c01 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Nov 2026 16:10:13 -0600 Subject: [PATCH 06/18] [gsubgpos] Read contextual rule input glyphs through glyph_data_t in closure/depend (#6620) context_closure_recurse_lookups() and context_depend_recurse_lookups() already hold the rule's input sequence as a width-erased glyph_data_t view, but for glyph-based rules (ContextFormat::SimpleContext) they unwrapped the raw pointer and let intersected_glyph() index it as HBUINT16. That is wrong for the HBUINT24 arrays of SequenceContextFormat4 / ChainedSequenceContextFormat4: every input position after the first was read at the wrong bytes, so the nested lookup was closed over the wrong glyph and its real output never entered the closure (other glyph ids keep glyphs that can never appear). Only experimental / beyond-64k builds are affected. Resolve the glyph via input[seqIndex - 1] for every format and make intersected_glyph() a plain insert of the value, mirroring its sibling intersects_glyph() which already takes the resolved glyph and ignores data. These two call sites were the only users of the pointer-plus-index convention; 16-bit formats are unchanged, and there is no API/ABI change. Adds a regression test under HB_NO_BEYOND_64K: a SequenceContextFormat4 rule "1 2" invoking a SingleSubst 2->3 must close {1, 2} to {1, 2, 3}. It fails on the unpatched library and passes with the fix. Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-IU58QGNT. Co-authored-by: Claude Opus 4.8 --- src/hb-ot-layout-gsubgpos.hh | 35 +++++++--------------- test/api/test-ot-layout.c | 56 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 25 deletions(-) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index d1b94ca91..a03dfbb99 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -1678,10 +1678,9 @@ static inline bool intersects_coverage (const hb_set_t *glyphs, unsigned value, } -static inline void intersected_glyph (const hb_set_t *glyphs HB_UNUSED, const void *data, unsigned value, hb_set_t *intersected_glyphs, HB_UNUSED void *cache) +static inline void intersected_glyph (const hb_set_t *glyphs HB_UNUSED, const void *data HB_UNUSED, unsigned value, hb_set_t *intersected_glyphs, HB_UNUSED void *cache) { - unsigned g = reinterpret_cast(data)[value]; - intersected_glyphs->add (g); + intersected_glyphs->add (value); } using intersected_class_cache_t = hb_hashmap_t; @@ -2396,17 +2395,10 @@ static inline void context_closure_recurse_lookups (hb_closure_context_t *c, } } else - { - const void *input_data = input.data; - unsigned input_value = seqIndex - 1; - if (context_format != ContextFormat::SimpleContext) - { - input_data = data; - input_value = input[seqIndex - 1]; - } - - intersected_glyphs_func (c->glyphs, input_data, input_value, &pos_glyphs, cache); - } + /* input is a width-erased glyph_data_t view, so input[seqIndex - 1] + * resolves the value at the right width for every format (glyph id + * for glyph-based rules, class/coverage index otherwise). */ + intersected_glyphs_func (c->glyphs, data, input[seqIndex - 1], &pos_glyphs, cache); } covered_seq_indicies.add (seqIndex); @@ -2664,17 +2656,10 @@ static inline void context_depend_recurse_lookups (hb_depend_context_t *c, } } else - { - const void *input_data = input.data; - unsigned input_value = seqIndex - 1; - if (context_format != ContextFormat::SimpleContext) - { - input_data = data; - input_value = input[seqIndex - 1]; - } - - intersected_glyphs_func (c->glyphs, input_data, input_value, &pos_glyphs, cache); - } + /* input is a width-erased glyph_data_t view, so input[seqIndex - 1] + * resolves the value at the right width for every format (glyph id + * for glyph-based rules, class/coverage index otherwise). */ + intersected_glyphs_func (c->glyphs, data, input[seqIndex - 1], &pos_glyphs, cache); } covered_seq_indices.add (seqIndex); diff --git a/test/api/test-ot-layout.c b/test/api/test-ot-layout.c index 69cbf22ba..298233ba0 100644 --- a/test/api/test-ot-layout.c +++ b/test/api/test-ot-layout.c @@ -105,6 +105,61 @@ test_ot_layout_gdef_1_4_offset2 (void) hb_face_destroy (face); } + +static void +test_ot_layout_lookups_substitute_closure_context_format4 (void) +{ + /* Lookup 0 is a SequenceContextFormat4 (24-bit glyph ids) with the + * single rule "1 2", applying lookup 1 at position 1. Lookup 1 is a + * SingleSubst 2 -> 3. Closing over {1, 2} must add glyph 3. */ + const char gsub[] = { + 0x00, 0x01, 0x00, 0x00, /* version 1.0 */ + 0x00, 0x0A, /* scriptListOffset */ + 0x00, 0x0C, /* featureListOffset */ + 0x00, 0x0E, /* lookupListOffset */ + 0x00, 0x00, /* ScriptList: no scripts */ + 0x00, 0x00, /* FeatureList: no features */ + 0x00, 0x02, 0x00, 0x06, 0x00, 0x2F, /* LookupList: two lookups */ + 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, /* Lookup 0: type 5, one subtable */ + 0x00, 0x04, /* SequenceContextFormat4 */ + 0x00, 0x00, 0x00, 0x0C, /* coverageOffset */ + 0x00, 0x00, 0x01, /* ruleSetCount */ + 0x00, 0x00, 0x12, /* ruleSetOffsets[0] */ + 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, /* Coverage format 1, glyph 1 */ + 0x00, 0x01, 0x00, 0x04, /* RuleSet: one rule */ + 0x00, 0x02, 0x00, 0x01, /* Rule: inputCount 2, lookupCount 1 */ + 0x00, 0x00, 0x02, /* input[1] = glyph 2 */ + 0x00, 0x01, 0x00, 0x01, /* LookupRecord: sequenceIndex 1, lookup 1 */ + 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, /* Lookup 1: type 1, one subtable */ + 0x00, 0x01, 0x00, 0x06, 0x00, 0x01, /* SingleSubstFormat1, delta +1 */ + 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, /* Coverage format 1, glyph 2 */ + }; + const char maxp[] = {0x00, 0x00, 0x50, 0x00, 0x00, 0x04}; /* version 0.5, 4 glyphs */ + hb_face_t *face = hb_face_builder_create (); + hb_blob_t *blob = hb_blob_create (gsub, sizeof (gsub), + HB_MEMORY_MODE_READONLY, NULL, NULL); + hb_set_t *lookups = hb_set_create (); + hb_set_t *glyphs = hb_set_create (); + + g_assert_true (hb_face_builder_add_table (face, HB_OT_TAG_GSUB, blob)); + hb_blob_destroy (blob); + blob = hb_blob_create (maxp, sizeof (maxp), + HB_MEMORY_MODE_READONLY, NULL, NULL); + g_assert_true (hb_face_builder_add_table (face, HB_TAG ('m','a','x','p'), blob)); + hb_blob_destroy (blob); + + hb_set_add (lookups, 0); + hb_set_add (glyphs, 1); + hb_set_add (glyphs, 2); + hb_ot_layout_lookups_substitute_closure (face, lookups, glyphs); + + g_assert_true (hb_set_has (glyphs, 3)); + g_assert_cmpuint (hb_set_get_population (glyphs), ==, 3); + + hb_set_destroy (glyphs); + hb_set_destroy (lookups); + hb_face_destroy (face); +} #endif static void @@ -334,6 +389,7 @@ main (int argc, char **argv) #endif #ifndef HB_NO_BEYOND_64K hb_test_add (test_ot_layout_gdef_1_4_offset2); + hb_test_add (test_ot_layout_lookups_substitute_closure_context_format4); #endif hb_test_add (test_ot_layout_table_get_script_tags); hb_test_add (test_ot_layout_table_find_script); From 40d215957af1f824fc28c46ae2b21c91bab9fc73 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Nov 2026 16:11:44 -0600 Subject: [PATCH 07/18] [depend] Collect GSUB feature tags, substitutes and lookup variations in one pass (#6621) GSUB_accelerator_t::depend() resolved each feature tag separately: it ran hb_ot_layout_collect_features() once per tag and, for every tag, walked the whole FeatureVariations table looking for substitute features. Tables with many features and many FeatureVariations records were therefore quadratic, work that sanitize() bounds only for a single pass. Query all tags at once, then visit each feature once and each FeatureVariations substitute once (via new visit_substitutes() helpers), mapping every lookup to the tag of the feature it belongs to. The emitted dependency graphs are unchanged. Adds a regression test building a FeatureVariations GSUB whose features have no direct lookups. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-5C2QXX5N. Co-authored-by: Claude Opus 4.8 --- src/hb-ot-layout-common.hh | 22 +++++++ src/hb-ot-layout-gsub-table.hh | 66 +++++++++---------- test/api/test-ot-depend.c | 112 +++++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+), 35 deletions(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index ba274a7f3..ba38cf51c 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -5502,6 +5502,18 @@ struct FeatureTableSubstitution return nullptr; } + /* Calls visit (feature_index, substitute) until it returns false. */ + template + bool visit_substitutes (const hb_set_t *feature_indexes, + Visitor &visit) const + { + for (const FeatureTableSubstitutionRecord &record : substitutions) + if (feature_indexes->has (record.featureIndex) && + !visit (record.featureIndex, this+record.feature)) + return false; + return true; + } + void collect_lookups (const hb_set_t *feature_indexes, hb_set_t *lookup_indexes /* OUT */) const { @@ -6025,6 +6037,16 @@ struct FeatureVariations return (this+record.substitutions).find_substitute (feature_index); } + template + bool visit_substitutes (const hb_set_t *feature_indexes, + Visitor &visit) const + { + for (const FeatureVariationRecord &record : varRecords) + if (!(this+record.substitutions).visit_substitutes (feature_indexes, visit)) + return false; + return true; + } + bool collect_lookup_conditions (const int *coords, unsigned int coord_len, ItemVarStoreInstancer *instancer, diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 0030a3c88..3eb8c5a1d 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -131,53 +131,49 @@ GSUB_accelerator_t::depend (hb_depend_data_builder_t *builder, hb_face_t *face) if (!builder->init_lookup_features (num_lookups)) return; + /* Query all tags at once, and then visit each feature, substitute and + * lookup variation once. Repeating any of that per tag or per feature + * multiplies work that sanitize() bounds only for a single pass. */ hb_vector_t feature_query_v; - feature_query_v.resize (2); - feature_query_v[1] = 0; - - hb_set_t seen_features; - hb_set_t feature_indexes, lookup_indexes; - + if (!builder->check_success (feature_query_v.alloc (num_features + 1))) + return; for (auto ft : feature_tags) + if (ft) /* Zero terminates the query. */ + feature_query_v.push (ft); + feature_query_v.push (0); + + hb_set_t feature_indexes, lookup_indexes; + hb_ot_layout_collect_features (face, HB_OT_TAG_GSUB, nullptr, nullptr, + feature_query_v.arrayZ, &feature_indexes); + + auto add_feature_lookups = [&] (unsigned feature_index, const Feature &feature) { - if (seen_features.has (ft)) continue; - seen_features.add (ft); - feature_query_v[0] = ft; - feature_indexes.reset (); - hb_ot_layout_collect_features (face, HB_OT_TAG_GSUB, nullptr, nullptr, - feature_query_v.arrayZ, &feature_indexes); lookup_indexes.reset (); - for (auto feature_index : feature_indexes) - this->table->get_feature (feature_index).add_lookup_indexes_to (&lookup_indexes); - + feature.add_lookup_indexes_to (&lookup_indexes); for (auto lookup_index : lookup_indexes) - if (unlikely (!builder->add_lookup_feature (lookup_index, ft))) - return; + if (unlikely (!builder->add_lookup_feature (lookup_index, feature_tags[feature_index]))) + return false; + return true; + }; - auto &fv = this->table->get_feature_variations (); - auto fi_count = fv.record_count (); - for (unsigned i = 0; i < fi_count; i++) - { - lookup_indexes.reset (); - for (auto feature_index : feature_indexes) - { - auto feature_ptr = fv.find_substitute (i, feature_index); - if (feature_ptr != nullptr) - feature_ptr->add_lookup_indexes_to (&lookup_indexes); - } - for (auto lookup_index : lookup_indexes) - if (unlikely (!builder->add_lookup_feature (lookup_index, ft))) - return; - } + for (auto feature_index : feature_indexes) + if (unlikely (!add_feature_lookups (feature_index, this->table->get_feature (feature_index)))) + return; + + auto &fv = this->table->get_feature_variations (); + if (unlikely (!fv.visit_substitutes (&feature_indexes, add_feature_lookups))) + return; #ifndef HB_NO_VAR + for (const auto &record : fv.get_lookup_variation_records ()) + { lookup_indexes.reset (); - fv.collect_lookup_variation_lookups (&feature_indexes, &lookup_indexes); + record.collect_lookups (&fv, &feature_indexes, &lookup_indexes); for (auto lookup_index : lookup_indexes) - if (unlikely (!builder->add_lookup_feature (lookup_index, ft))) + if (unlikely (!builder->add_lookup_feature (lookup_index, feature_tags[record.get_feature_index ()]))) return; -#endif } +#endif if (unlikely (!builder->finish_lookup_features ())) return; diff --git a/test/api/test-ot-depend.c b/test/api/test-ot-depend.c index 5ef9ae03d..6530a80a9 100644 --- a/test/api/test-ot-depend.c +++ b/test/api/test-ot-depend.c @@ -684,6 +684,117 @@ test_depend_varc (void) hb_face_destroy (face); } +/* A GSUB face whose features have no lookups of their own. Feature 0 is 'aaaa', + * the others are 'bbbb', and the default LangSys lists all but the last. Every + * FeatureVariations record uses the same FeatureTableSubstitution, which gives + * lookup 0 (glyph 1 -> 2) to feature 0 and lookup 1 (glyph 3 -> 4) to the last + * feature; its other records are for a feature that does not exist. */ +static hb_face_t * +create_feature_variations_face (unsigned num_features, + unsigned num_records, + unsigned num_substitutions) +{ + unsigned lookup_list_offset = 14; + unsigned script_list_offset = lookup_list_offset + 6 + 2 * 20; + unsigned feature_list_offset = script_list_offset + 18 + (num_features - 1) * 2; + unsigned variations_offset = feature_list_offset + 2 + num_features * 6 + 4; + unsigned substitutions_size = 6 + num_substitutions * 6; + unsigned gsub_size = variations_offset + 8 + num_records * 8 + substitutions_size + 2 * 6; + unsigned char *gsub = (unsigned char *) g_malloc0 (gsub_size); + unsigned char *p = gsub; + unsigned char maxp[6] = {0x00, 0x00, 0x50, 0x00, 0x00, 0x05}; + hb_face_t *face = hb_face_builder_create (); + hb_blob_t *blob; + +#define PUT16(v) (*p++ = (unsigned char) ((v) >> 8), *p++ = (unsigned char) (v)) +#define PUT32(v) (PUT16 ((v) >> 16), PUT16 (v)) + PUT16 (1); PUT16 (1); /* version */ + PUT16 (script_list_offset); + PUT16 (feature_list_offset); + PUT16 (lookup_list_offset); + PUT32 (variations_offset); + + PUT16 (2); PUT16 (6); PUT16 (6 + 20); /* lookupCount, lookupOffsets */ + for (unsigned i = 0; i < 2; i++) + { + PUT16 (1); PUT16 (0); PUT16 (1); PUT16 (8); /* type, flag, subTableCount, offset */ + PUT16 (1); PUT16 (6); PUT16 (1); /* SingleSubst format, coverage, deltaGlyphID */ + PUT16 (1); PUT16 (1); PUT16 (1 + 2 * i); /* Coverage format, glyphCount, glyph */ + } + + PUT16 (1); PUT32 (HB_TAG ('D','F','L','T')); PUT16 (8); /* scriptCount, record */ + PUT16 (4); PUT16 (0); /* defaultLangSys, langSysCount */ + PUT16 (0); PUT16 (0xFFFF); PUT16 (num_features - 1); /* lookupOrder, required, count */ + for (unsigned i = 0; i < num_features - 1; i++) + PUT16 (i); + + PUT16 (num_features); + for (unsigned i = 0; i < num_features; i++) + { + PUT32 (i ? HB_TAG ('b','b','b','b') : HB_TAG ('a','a','a','a')); + PUT16 (2 + num_features * 6); + } + PUT16 (0); PUT16 (0); /* featureParams, lookupIndexCount */ + + PUT16 (1); PUT16 (0); /* version */ + PUT32 (num_records); + for (unsigned i = 0; i < num_records; i++) + { + PUT32 (0); /* conditionSet */ + PUT32 (8 + num_records * 8); /* featureTableSubstitution */ + } + + PUT16 (1); PUT16 (0); /* version */ + PUT16 (num_substitutions); + PUT16 (0); PUT32 (substitutions_size); + PUT16 (num_features - 1); PUT32 (substitutions_size + 6); + for (unsigned i = 2; i < num_substitutions; i++) + { + PUT16 (0xFFFF); PUT32 (0); + } + for (unsigned i = 0; i < 2; i++) + { + PUT16 (0); PUT16 (1); PUT16 (i); /* featureParams, lookupIndexCount, lookup */ + } + g_assert_true (p == gsub + gsub_size); +#undef PUT32 +#undef PUT16 + + blob = hb_blob_create ((const char *) gsub, gsub_size, + HB_MEMORY_MODE_READONLY, gsub, g_free); + g_assert_true (hb_face_builder_add_table (face, HB_TAG ('G','S','U','B'), blob)); + hb_blob_destroy (blob); + + blob = hb_blob_create ((const char *) maxp, sizeof (maxp), + HB_MEMORY_MODE_DUPLICATE, NULL, NULL); + g_assert_true (hb_face_builder_add_table (face, HB_TAG ('m','a','x','p'), blob)); + hb_blob_destroy (blob); + + return face; +} + +/* Lookups of substitute features get the tag of the feature they replace, in + * one pass over the FeatureVariations table. */ +static void +test_depend_feature_variations (void) +{ + /* 8,000 x 40,000 x 90 steps if every record is searched for every feature. */ + hb_face_t *face = create_feature_variations_face (8000, 40000, 90); + hb_subset_depend_t *depend = hb_subset_depend_from_face_or_fail (face); + hb_tag_t tag; + g_assert_nonnull (depend); + + tag = HB_TAG ('a','a','a','a'); + g_assert_true (find_dependency (depend, 1, 2, HB_OT_TAG_GSUB, &tag, NULL)); + tag = HB_TAG ('b','b','b','b'); + g_assert_false (find_dependency (depend, 1, 2, HB_OT_TAG_GSUB, &tag, NULL)); + /* No script reaches the last feature. */ + g_assert_false (find_dependency (depend, 3, 4, HB_OT_TAG_GSUB, NULL, NULL)); + + hb_subset_depend_destroy (depend); + hb_face_destroy (face); +} + #ifndef HB_NO_BEYOND_64K /* ContextSubst format 6 (beyond-64k) uses 24-bit Coverage offsets. * Lookup 0 matches glyphs 1 2 and calls lookup 1 (SingleSubst 2 -> 3) @@ -715,6 +826,7 @@ main (int argc, char **argv) hb_test_add (test_depend_math); hb_test_add (test_depend_varc); hb_test_add (test_depend_gsub_formats); + hb_test_add (test_depend_feature_variations); #ifndef HB_NO_BEYOND_64K hb_test_add (test_depend_context_format6); #endif From 7f1440eac1ef64c8126eb7e81e8cb60fb0297463 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Nov 2026 16:15:17 -0600 Subject: [PATCH 08/18] [GDEF] Fill the mark-glyph-set cache straight from each Coverage (#6622) The GDEF accelerator built its per-mark-set bit-page/digest cache by materializing an hb_set_t for every mark glyph set and walking it glyph by glyph. A mark set's Coverage can name an enormous glyph range in a few bytes, and several sets can alias one all-glyphs Coverage, so a 256 KiB font with 65535 such sets cost about 1 GiB and billions of iterations in the accelerator constructor. Fill each entry directly from its Coverage table via collect_coverage() into lightweight sinks (gid extents, then a biased bit-page or a digest), so the work is proportional to the coverage records the sanitizer already budgeted for, not to the glyphs they span. Replace MarkGlyphSets::collect_coverage() with get_count() / get_coverage() accessors. Answers are identical. Adds a fuzzer regression font. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-OM3ZVHGK. Co-authored-by: Claude Opus 4.8 --- src/OT/Layout/GDEF/GDEF.hh | 104 ++++++++++++------ ...def-mark-glyph-sets-aliased-all-glyphs.ttf | Bin 0 -> 262276 bytes 2 files changed, 69 insertions(+), 35 deletions(-) create mode 100644 test/fuzzing/fonts/gdef-mark-glyph-sets-aliased-all-glyphs.ttf diff --git a/src/OT/Layout/GDEF/GDEF.hh b/src/OT/Layout/GDEF/GDEF.hh index fe38fe326..f7f304c92 100644 --- a/src/OT/Layout/GDEF/GDEF.hh +++ b/src/OT/Layout/GDEF/GDEF.hh @@ -453,6 +453,10 @@ struct MarkGlyphSetsFormat1 bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; } + unsigned get_count () const { return coverage.len; } + const Coverage &get_coverage (unsigned int set_index) const + { return this+coverage[set_index]; } + void collect_used_mark_sets (const hb_set_t& glyph_set, hb_set_t& used_mark_sets /* OUT */) const { @@ -467,18 +471,6 @@ struct MarkGlyphSetsFormat1 } } - template - void collect_coverage (hb_vector_t &sets) const - { - for (const auto &offset : coverage) - { - if (unlikely (!sets.resize (sets.length + 1))) - return; - const auto &cov = this+offset; - cov.collect_coverage (&sets.tail ()); - } - } - bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); @@ -539,12 +531,19 @@ struct MarkGlyphSets } } - template - void collect_coverage (hb_vector_t &sets) const + unsigned get_count () const { switch (u.format.v) { - case 1: hb_barrier (); u.format1.collect_coverage (sets); return; - default:return; + case 1: hb_barrier (); return u.format1.get_count (); + default:return 0; + } + } + + const Coverage &get_coverage (unsigned int set_index) const + { + switch (u.format.v) { + case 1: hb_barrier (); return u.format1.get_coverage (set_index); + default:return Null (Coverage); } } @@ -991,34 +990,35 @@ struct GDEF /* Flatten each mark set whose glyphs span fewer than PAGE_BITS * gids into a single bit-page biased at its first glyph, for * O(1) exact answers. Wider sets, or on allocation failure, - * fall back to the table. */ + * fall back to the table. + * + * Fill each entry straight from its Coverage table, so the work + * is proportional to the coverage records the sanitizer budgeted + * for, not to the glyphs they span: materializing an hb_set_t per + * set and walking it glyph by glyph let a 256kb font with 65535 + * all-glyph sets cost ~1GB and billions of iterations here. */ { - hb_vector_t sets; - table->get_mark_glyph_sets ().collect_coverage (sets); - if (!sets.in_error () && - mark_glyph_set_bitmaps.resize (sets.length)) - for (unsigned i = 0; i < sets.length; i++) + const auto &mark_sets = table->get_mark_glyph_sets (); + unsigned count = mark_sets.get_count (); + if (mark_glyph_set_bitmaps.resize (count)) + for (unsigned i = 0; i < count; i++) { auto &bitmap = mark_glyph_set_bitmaps.arrayZ[i]; bitmap.bias = HB_SET_VALUE_INVALID; - const auto &set = sets.arrayZ[i]; - if (unlikely (set.in_error ())) continue; - hb_codepoint_t min_gid = HB_SET_VALUE_INVALID; - hb_codepoint_t max_gid = HB_SET_VALUE_INVALID; - hb_set_next (&set, &min_gid); - hb_set_previous (&set, &max_gid); - if (max_gid == HB_SET_VALUE_INVALID) + const Coverage &cov = mark_sets.get_coverage (i); + mark_glyph_set_extents_t extents; + cov.collect_coverage (&extents); + if (extents.min_gid == HB_SET_VALUE_INVALID) continue; - if (max_gid - min_gid >= hb_bit_page_t::PAGE_BITS) + if (extents.max_gid - extents.min_gid >= hb_bit_page_t::PAGE_BITS) { /* Too wide for one page; a digest pre-filter instead. */ - for (hb_codepoint_t gid : set) - bitmap.u.digest.add (gid); + cov.collect_coverage (&bitmap.u.digest); continue; } - bitmap.bias = min_gid; - for (hb_codepoint_t gid : set) - bitmap.u.page.add (gid - min_gid); + bitmap.bias = extents.min_gid; + mark_glyph_set_page_t page {bitmap.u.page, extents.min_gid}; + cov.collect_coverage (&page); } } #endif @@ -1027,6 +1027,40 @@ struct GDEF hb_blob_ptr_t borrow_sanitized_table () const { return sanitized_table; } +#ifndef HB_NO_GDEF_CACHE + /* Sinks for Coverage::collect_coverage(): the gid extents of a + * coverage, and a bit-page filled with gids relative to a bias + * (which must be the coverage's min gid, with max - min < PAGE_BITS). */ + struct mark_glyph_set_extents_t + { + void add (hb_codepoint_t g) + { + min_gid = hb_min (min_gid, g); + max_gid = hb_max (max_gid, g); + } + bool add_range (hb_codepoint_t a, hb_codepoint_t b) + { if (a <= b) { add (a); add (b); } return true; } + template + bool add_sorted_array (const hb_sorted_array_t& arr) + { for (const auto &g : arr) add (g); return true; } + + hb_codepoint_t min_gid = HB_SET_VALUE_INVALID; + hb_codepoint_t max_gid = 0; + }; + struct mark_glyph_set_page_t + { + void add (hb_codepoint_t g) { page.add (g - bias); } + bool add_range (hb_codepoint_t a, hb_codepoint_t b) + { if (a <= b) page.add_range (a - bias, b - bias); return true; } + template + bool add_sorted_array (const hb_sorted_array_t& arr) + { for (const auto &g : arr) add (g); return true; } + + hb_bit_page_t &page; + hb_codepoint_t bias; + }; +#endif + unsigned int get_glyph_props (hb_codepoint_t glyph) const { unsigned v; diff --git a/test/fuzzing/fonts/gdef-mark-glyph-sets-aliased-all-glyphs.ttf b/test/fuzzing/fonts/gdef-mark-glyph-sets-aliased-all-glyphs.ttf new file mode 100644 index 0000000000000000000000000000000000000000..61d7f4be73b3b0c252f4e103960d625b0e62ae27 GIT binary patch literal 262276 zcmeIwI}XAy3PrnSldv2o?~Jm4ORX%#|1!xO*|rQ+$aW+mW+GUz#LsMXl5R zaQsx+q|5R;^tX54 Date: Tue, 10 Nov 2026 16:21:48 -0600 Subject: [PATCH 09/18] Merge pull request #6624 from harfbuzz/split/gsubgpos-header [layout] Write GSUB/GPOS subsets with a header that matches their layout --- src/hb-ot-layout-gsubgpos.hh | 15 ++++- test/api/test-be-subset-tables.c | 111 +++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index a03dfbb99..d9f1a3428 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -6383,7 +6383,10 @@ struct GSUBGPOS subset_lookup_list2_offset (), this, c); else - serialize_subset_offset (c->subset_context, out->lookupList2, + /* LookupList2 entries are 32-bit; a 16-bit source list stays + * behind the 16-bit lookupList, which readers fall back to when + * lookupList2 is null. */ + serialize_subset_offset (c->subset_context, out->lookupList, subset_lookup_list_offset (), this, c); @@ -6404,6 +6407,12 @@ struct GSUBGPOS else #endif { + /* Written with the v1.0/v1.1 layout, whose header has none of the + * 32-bit v1.2 offsets; a v1.2 source must be recorded as v1.1 so + * the header matches what is actually serialized. */ + if (version.to_int () >= 0x00010002u) + out->version.minor = 1; + out->subset_lookup_list_offset () .serialize_subset (c->subset_context, subset_lookup_list_offset (), @@ -6426,7 +6435,7 @@ struct GSUBGPOS if (version.to_int () >= 0x00010001u) { auto snapshot = c->subset_context->serializer->snapshot (); - if (version.to_int () < 0x00010002u && + if (out->version.to_int () < 0x00010002u && !c->subset_context->serializer->extend_min (&out->featureVars)) return_trace (false); @@ -6436,7 +6445,7 @@ struct GSUBGPOS if (!ret) { out->featureVars = 0; - if (version.to_int () < 0x00010002u) + if (out->version.to_int () < 0x00010002u) { c->subset_context->serializer->revert (snapshot); out->version.major = 1; diff --git a/test/api/test-be-subset-tables.c b/test/api/test-be-subset-tables.c index 6bd1fa898..f520da777 100644 --- a/test/api/test-be-subset-tables.c +++ b/test/api/test-be-subset-tables.c @@ -182,6 +182,116 @@ test_vorg_versions (void) #endif +static hb_face_t * +create_gsub_v1_2_face (void) +{ + /* A version 1.2 GSUB that keeps its lists behind the 16-bit offsets + * and has a FeatureVariations table. */ + static const char GSUB_data[] = { + 0, 1, 0, 2, /* version 1.2 */ + 0, 26, /* scriptList */ + 0, 46, /* featureList */ + 0, 62, /* lookupList */ + 0, 0, 0, 108, /* featureVars */ + 0, 0, 0, 0, /* scriptList2 */ + 0, 0, 0, 0, /* featureList2 */ + 0, 0, 0, 0, /* lookupList2 */ + /* ScriptList */ + 0, 1, 'D', 'F', 'L', 'T', 0, 8, /* one script at 8 */ + 0, 4, 0, 0, /* defaultLangSys at 4, no LangSys records */ + 0, 0, 0xFF, 0xFF, 0, 1, 0, 0, /* no required feature, feature 0 */ + /* FeatureList */ + 0, 1, 'c', 'c', 'm', 'p', 0, 8, /* one feature at 8 */ + 0, 0, 0, 2, 0, 0, 0, 1, /* lookups 0 and 1 */ + /* LookupList */ + 0, 2, 0, 6, 0, 26, /* two 16-bit lookup offsets */ + 0, 1, 0, 0, 0, 1, 0, 8, /* SingleSubst, one subtable at 8 */ + 0, 1, 0, 6, 0, 1, /* format 1, coverage at 6, delta +1 */ + 0, 1, 0, 1, 0, 1, /* coverage: glyph 1 */ + 0, 1, 0, 0, 0, 1, 0, 8, /* SingleSubst, one subtable at 8 */ + 0, 1, 0, 6, 0, 2, /* format 1, coverage at 6, delta +2 */ + 0, 1, 0, 1, 0, 2, /* coverage: glyph 2 */ + /* FeatureVariations */ + 0, 1, 0, 0, /* version 1.0 */ + 0, 0, 0, 1, /* one record */ + 0, 0, 0, 16, 0, 0, 0, 30, /* conditionSet at 16, substitutions at 30 */ + 0, 1, 0, 0, 0, 6, /* one condition at 6 */ + 0, 1, 0, 0, 0x20, 0, 0x40, 0, /* axis 0 in [0.5, 1.0] */ + 0, 1, 0, 0, 0, 1, /* one substitution record */ + 0, 0, 0, 0, 0, 12, /* feature 0, alternate Feature at 12 */ + 0, 0, 0, 1, 0, 0, /* lookup 0 only */ + }; + static const char FVAR_data[] = { + 0, 1, 0, 0, /* version 1.0 */ + 0, 16, 0, 2, 0, 1, 0, 20, /* one axis at 16, axisSize 20 */ + 0, 0, 0, 8, /* no instances */ + 'w', 'g', 'h', 't', + 0, 100, 0, 0, /* minValue 100 */ + 1, 0x90, 0, 0, /* defaultValue 400 */ + 3, 0x84, 0, 0, /* maxValue 900 */ + 0, 0, 1, 0, /* flags, axisNameID */ + }; + static const char MAXP_data[] = { + 0, 0, 0x50, 0, /* version 0.5 */ + 0, 5, /* numGlyphs */ + }; + hb_face_t *face = hb_face_builder_create (); + HB_FACE_ADD_TABLE (face, "GSUB", GSUB_data); + HB_FACE_ADD_TABLE (face, "fvar", FVAR_data); + HB_FACE_ADD_TABLE (face, "maxp", MAXP_data); + return face; +} + +static void +check_gsub_v1_2_lookup (hb_face_t *face, unsigned lookup_index, + hb_codepoint_t glyph, hb_codepoint_t expected) +{ + unsigned count = 1; + hb_codepoint_t alternate = HB_CODEPOINT_INVALID; + g_assert_cmpuint (hb_ot_layout_lookup_get_glyph_alternates (face, lookup_index, glyph, + 0, &count, &alternate), + ==, 1); + g_assert_cmpuint (alternate, ==, expected); +} + +static void +check_gsub_v1_2 (hb_face_t *face, hb_codepoint_t last_glyph, hb_bool_t has_feature_variations) +{ + int coords[] = {0x4000}; /* wght 900 */ + unsigned index; + g_assert_cmpuint (hb_ot_layout_table_get_lookup_count (face, HB_OT_TAG_GSUB), ==, 2); + check_gsub_v1_2_lookup (face, 0, 1, 2); + check_gsub_v1_2_lookup (face, 1, 2, last_glyph); + g_assert_cmpint (hb_ot_layout_table_find_feature_variations (face, HB_OT_TAG_GSUB, + coords, 1, &index), + ==, has_feature_variations); +} + +static void +test_gsub_v1_2_subset (void) +{ + hb_face_t *face = create_gsub_v1_2_face (); + check_gsub_v1_2 (face, 4, TRUE); + + /* Glyph 1 closes over 2 and 4; 4 is renumbered to 3. */ + hb_set_t *glyphs = hb_set_create (); + hb_set_add (glyphs, 1); + hb_face_t *subset = hb_subset_test_create_subset ( + face, hb_subset_test_create_input_from_glyphs (glyphs)); + check_gsub_v1_2 (subset, 3, TRUE); + hb_face_destroy (subset); + + /* Pinning the only axis drops the FeatureVariations. */ + hb_subset_input_t *input = hb_subset_test_create_input_from_glyphs (glyphs); + g_assert_true (hb_subset_input_pin_axis_to_default (input, face, HB_TAG ('w','g','h','t'))); + subset = hb_subset_test_create_subset (face, input); + check_gsub_v1_2 (subset, 3, FALSE); + hb_face_destroy (subset); + + hb_set_destroy (glyphs); + hb_face_destroy (face); +} + int main (int argc, char **argv) { @@ -191,6 +301,7 @@ main (int argc, char **argv) hb_test_add (test_colr_paint_glyph2); hb_test_add (test_vorg_versions); #endif + hb_test_add (test_gsub_v1_2_subset); return hb_test_run (); } From 26a6729680d9e1c9eb023e1cd76f8e041f79f6c8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Nov 2026 16:24:19 -0600 Subject: [PATCH 10/18] [instancer] Merge repeated VarData region indices into one tuple (#6625) create_from_item_var_data() deep-copied a region's axis hash map once per entry of VarData.regionIndexes, so memory grew with regionIndexCount x axisCount while the font pays only their sum, and region indices may repeat freely. A 100 KB font (2000 axes, one region, 16000 copies of region index 0) made one hb-subset call allocate about 2 GB. A region a VarData names again now adds its delta column to the tuple it already owns, exactly what merge_tuple_variations() computes later, so the instanced output is byte-identical. To also bound the sibling case of many dataSets offsets each pointing at one VarData, the region axes copied while converting one ItemVariationStore are summed across its VarData subtables and capped at a new HB_VARSTORE_MAX_TUPLE_AXES (1<<20); stores in the test fonts stay far below the cap. Exceeding the cap fails instancing of that store, the same path a failed allocation already takes. Adds a unit test (test_repeated_region_index) covering the merge and the cap. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-1CGIYCMY. Co-authored-by: Claude Opus 4.8 --- src/hb-limits.hh | 8 +++++++ src/hb-ot-var-common.hh | 31 ++++++++++++++++++++++--- src/test-item-varstore.cc | 48 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/src/hb-limits.hh b/src/hb-limits.hh index b18e4e64c..27858b8ba 100644 --- a/src/hb-limits.hh +++ b/src/hb-limits.hh @@ -107,6 +107,14 @@ #define HB_VAR_COMPOSITE_MAX_AXES 4096 #endif +/* Region axes copied into tuples when one ItemVariationStore is converted + * for instancing, summed over its VarData subtables. Every region a + * VarData references gets its own copy of that region's axes, and the + * font pays a few bytes per reference however many axes the region has. */ +#ifndef HB_VARSTORE_MAX_TUPLE_AXES +#define HB_VARSTORE_MAX_TUPLE_AXES (1u << 20) +#endif + #ifndef HB_GLYF_MAX_POINTS #define HB_GLYF_MAX_POINTS 200000 #endif diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index 92d582841..a97430d48 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -1088,6 +1088,7 @@ struct TupleVariationData const hb_vector_t>& regions, const hb_map_t& axes_old_index_tag_map, unsigned& item_count, + unsigned& num_tuple_axes, const hb_inc_bimap_t* inner_map = nullptr) { /* NULL offset, to keep original varidx valid, just return */ @@ -1102,8 +1103,31 @@ struct TupleVariationData unsigned row_size = var_data.get_row_size (); const HBUINT8 *delta_bytes = var_data.get_delta_bytes (); + /* region index -> index of its tuple in tuple_vars */ + hb_map_t region_tuple_map; for (unsigned r = 0; r < num_regions; r++) { + unsigned region_index = var_data.get_region_index (r); + if (region_index >= regions.length) return false; + + /* A region the VarData references again adds its deltas to the + * tuple it already has, as merge_tuple_variations () would do, + * instead of getting another copy of the region's axes. */ + hb_codepoint_t *tuple_index; + if (region_tuple_map.has (region_index, &tuple_index)) + { + tuple_delta_t& tuple = tuple_vars.arrayZ[*tuple_index]; + for (unsigned i = 0; i < item_count; i++) + tuple.deltas_x.arrayZ[i] += var_data.get_item_delta_fast (inner_map ? inner_map->backward (i) : i, + r, delta_bytes, row_size); + continue; + } + + /* Each tuple copies its region's axes; charge them before copying. */ + const hb_hashmap_t& region = regions.arrayZ[region_index]; + num_tuple_axes += region.get_population (); + if (unlikely (num_tuple_axes > HB_VARSTORE_MAX_TUPLE_AXES)) return false; + /* In VarData, deltas are organized in rows, convert them into * column(region) based tuples, resize deltas_x first */ tuple_delta_t tuple; @@ -1118,10 +1142,9 @@ struct TupleVariationData r, delta_bytes, row_size); } - unsigned region_index = var_data.get_region_index (r); - if (region_index >= regions.length) return false; - tuple.axis_tuples = regions.arrayZ[region_index]; + tuple.axis_tuples = region; + if (unlikely (!region_tuple_map.set (region_index, tuple_vars.length))) return false; tuple_vars.push (std::move (tuple)); } return !tuple_vars.in_error (); @@ -2005,6 +2028,7 @@ struct item_variations_t if (!vars.alloc (num_var_data) || !var_data_num_rows.alloc (num_var_data)) return false; + unsigned num_tuple_axes = 0; for (unsigned i = 0; i < num_var_data; i++) { if (inner_maps && !inner_maps.arrayZ[i].get_population ()) @@ -2015,6 +2039,7 @@ struct item_variations_t orig_region_list, axes_old_index_tag_map, item_count, + num_tuple_axes, inner_maps ? &(inner_maps.arrayZ[i]) : nullptr)) return false; diff --git a/src/test-item-varstore.cc b/src/test-item-varstore.cc index 7e0ca2eed..80497ef4a 100644 --- a/src/test-item-varstore.cc +++ b/src/test-item-varstore.cc @@ -457,6 +457,53 @@ test_condition_budget () hb_always_assert (budget < 0); } +static void +test_repeated_region_index () +{ + /* One axis, two regions, and a VarData whose region indices are {0, 1, 0}: + * the repeated region's two delta columns must be summed into one tuple. */ + const char store_data[] = + "\x00\x01\x00\x00\x00\x0c\x00\x01\x00\x00\x00\x1c" // ItemVariationStore + "\x00\x01\x00\x02" // VarRegionList: 1 axis, 2 regions + "\x00\x00\x40\x00\x40\x00" // region 0: (0, 1, 1) + "\xc0\x00\xc0\x00\x00\x00" // region 1: (-1, -1, 0) + "\x00\x02\x00\x00\x00\x03\x00\x00\x00\x01\x00\x00" // VarData: 2 items, regions {0, 1, 0} + "\x01\x02\x03" // item 0 + "\x0a\x14\x1e"; // item 1 + const auto &store = *reinterpret_cast (store_data); + hb_map_t axis_map; + axis_map.set (0, HB_TAG ('T','E','S','T')); + + hb_vector_t> regions; + hb_always_assert (store.get_region_list ().get_var_regions (axis_map, regions)); + OT::tuple_variations_t tuples; + unsigned item_count = 0, num_tuple_axes = 0; + hb_always_assert (tuples.create_from_item_var_data (store.get_sub_table (0), regions, axis_map, + item_count, num_tuple_axes)); + hb_always_assert (item_count == 2 && num_tuple_axes == 2); + hb_always_assert (tuples.tuple_vars.length == 2); + hb_always_assert (tuples.tuple_vars[0].deltas_x[0] == 4.f && tuples.tuple_vars[0].deltas_x[1] == 40.f); + hb_always_assert (tuples.tuple_vars[1].deltas_x[0] == 2.f && tuples.tuple_vars[1].deltas_x[1] == 20.f); + + /* The region axes copied for one store are capped. */ + OT::tuple_variations_t capped; + num_tuple_axes = HB_VARSTORE_MAX_TUPLE_AXES - 1; + hb_always_assert (!capped.create_from_item_var_data (store.get_sub_table (0), regions, axis_map, + item_count, num_tuple_axes)); + + OT::item_variations_t item_vars; + hb_always_assert (item_vars.create_from_item_varstore (store, axis_map)); + hb_hashmap_t locations; + hb_hashmap_t distances; + hb_always_assert (item_vars.instantiate_tuple_vars (locations, distances)); + hb_always_assert (item_vars.as_item_varstore (false)); + hb_always_assert (item_vars.get_region_list ().length == 2); + const auto &items = item_vars.get_vardata_encodings ()[0].items; + hb_always_assert (items.length == 2); + hb_always_assert ((*items[0])[0] == 4 && (*items[0])[1] == 2); + hb_always_assert ((*items[1])[0] == 40 && (*items[1])[1] == 20); +} + static void test_failed_encoding () { @@ -530,4 +577,5 @@ main (int argc, char **argv) test_condition_delta_precision (); test_multi_instancer_budget (); test_condition_budget (); + test_repeated_region_index (); } From 7f65c5d8204f7730bcbb508d508121aae6de177d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Nov 2026 16:29:56 -0600 Subject: [PATCH 11/18] [ot-map] Resolve a feature once in add_lookups() instead of once per 32 lookups (#6626) hb_ot_map_builder_t::add_lookups() paged through a feature's lookup indices 32 at a time with hb_ot_layout_feature_with_variations_get_lookups(), which re-resolves the feature on every call. Under a FeatureVariations record that resolution is a linear search of the substitution records, so a feature with many lookups and many variation records cost time quadratic in the number of lookups, stalling hb_shape()'s plan build. Add _hb_ot_layout_feature_with_variations_get_lookups(), which resolves the feature once and returns its whole lookup-index array, and have add_lookups() iterate that array directly. The public API is unchanged; the resulting map is identical. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-M3XZD80O. Co-authored-by: Claude Opus 4.8 --- src/hb-ot-layout.cc | 17 ++++++++++++++++ src/hb-ot-layout.hh | 6 ++++++ src/hb-ot-map.cc | 48 +++++++++++++++++++-------------------------- 3 files changed, 43 insertions(+), 28 deletions(-) diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 2eefdf77d..156c6c293 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1519,6 +1519,23 @@ hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, return f.get_lookup_indexes (start_offset, lookup_count, lookup_indexes); } +/* Like hb_ot_layout_feature_with_variations_get_lookups(), but resolves the + * feature only once and returns all of its lookup indices. Resolving a feature + * under a FeatureVariations record is a linear search of the record's + * FeatureTableSubstitution, so callers must not page through the lookups. */ +hb_array_t +_hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, + hb_tag_t table_tag, + unsigned int feature_index, + unsigned int variations_index) +{ + const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); + + const OT::Feature &f = g.get_feature_variation (feature_index, variations_index); + + return f.lookupIndex.as_array (); +} + /* * OT::GSUB diff --git a/src/hb-ot-layout.hh b/src/hb-ot-layout.hh index 38ad88b3e..b72b629ba 100644 --- a/src/hb-ot-layout.hh +++ b/src/hb-ot-layout.hh @@ -76,6 +76,12 @@ hb_ot_layout_lookup_would_substitute_with_buffer (hb_face_t *face, bool zero_context, hb_buffer_t *buffer); +HB_INTERNAL hb_array_t +_hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, + hb_tag_t table_tag, + unsigned int feature_index, + unsigned int variations_index); + /* * GDEF diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index a1f5c9e5a..c0f518cab 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -136,8 +136,6 @@ hb_ot_map_builder_t::add_lookups (hb_ot_map_t &m, bool per_syllable, hb_tag_t feature_tag) { - unsigned int lookup_indices[32]; - unsigned int offset, len; unsigned int table_lookup_count; table_lookup_count = hb_ot_layout_table_get_lookup_count (face, table_tags[table_index]); @@ -166,32 +164,26 @@ hb_ot_map_builder_t::add_lookups (hb_ot_map_t &m, return; } - offset = 0; - do { - len = ARRAY_LENGTH (lookup_indices); - hb_ot_layout_feature_with_variations_get_lookups (face, - table_tags[table_index], - feature_index, - key.variations_index[table_index], - offset, &len, - lookup_indices); - - for (unsigned int i = 0; i < len; i++) - { - if (lookup_indices[i] >= table_lookup_count) - continue; - hb_ot_map_t::lookup_map_t *lookup = m.lookups[table_index].push (); - lookup->mask = mask; - lookup->index = lookup_indices[i]; - lookup->auto_zwnj = auto_zwnj; - lookup->auto_zwj = auto_zwj; - lookup->random = random; - lookup->per_syllable = per_syllable; - lookup->feature_tag = feature_tag; - } - - offset += len; - } while (len == ARRAY_LENGTH (lookup_indices)); + /* Resolve the feature once: under a FeatureVariations record that is a + * linear search of the substitution records, so don't repeat it per batch + * of lookup indices. */ + auto lookup_indices = _hb_ot_layout_feature_with_variations_get_lookups (face, + table_tags[table_index], + feature_index, + key.variations_index[table_index]); + for (unsigned int lookup_index : lookup_indices) + { + if (lookup_index >= table_lookup_count) + continue; + hb_ot_map_t::lookup_map_t *lookup = m.lookups[table_index].push (); + lookup->mask = mask; + lookup->index = lookup_index; + lookup->auto_zwnj = auto_zwnj; + lookup->auto_zwj = auto_zwj; + lookup->random = random; + lookup->per_syllable = per_syllable; + lookup->feature_tag = feature_tag; + } } From df02261ecaca0f7d3747266b32c8a7e2401efffa Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Nov 2026 16:50:50 -0600 Subject: [PATCH 12/18] [subset] Charge Coverage and ClassDef glyph walks to a work budget (#6628) * [subset] Charge Coverage and ClassDef glyph walks to a work budget Coverage::subset() expands a format 2 Coverage glyph by glyph, up to numGlyphs, every time an offset to it is subset, and nothing bounded that work. A 10-byte range Coverage referenced by 30,000 two-byte offsets in a subtable listed 8 times costs 1.6e10 iterator steps, while the sanitizer only bounds work by table bytes; a 60 KB font keeps hb-subset busy ~50 s. GDEF's MarkGlyphSets reaches the same walk with no feature or lookup needing to survive planning. Give hb_subset_context_t a per-table work budget (HB_BUDGET_SUBSET_TABLE, in the hb_budget_spend() idiom of hb-limits.hh) with a check_ops() helper that fails the serializer once exhausted, and charge Coverage::subset() its capped population before the walk. Charging inside Coverage::subset() covers every caller (ReverseChainSingleSubst, (Chain)ContextFormat3, GDEF MarkGlyphSets, ...) without touching them. The same unbounded per-reference pattern in ClassDefFormat1_3 / ClassDefFormat2_4::subset() (the range or glyphset walk and the glyph_filter count) is charged the same way. A hostile table that exceeds the budget now fails the subset cleanly (hb_subset_or_fail returns NULL) in a fraction of a second instead of succeeding slowly; valid-font output is byte-identical and the heaviest local table spends a small fraction of the budget. test_subset_shared_coverage_budget builds the reverse-chaining GSUB in memory and asserts 256 shared references subset while 2048 fail. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-LLIWV9UK. Co-Authored-By: Claude Opus 4.8 * [subset] Charge layout glyph walks to the existing subset budget Drop the separate HB_BUDGET_SUBSET_TABLE budget and the second hb_subset_context_t field it needed; check_ops() now charges budget_remaining (HB_BUDGET_SUBSET_GLYF, 1 << 28), the per-table budget glyf instancing already uses. Both are per-table and shared across buffer-size retries, and no table spends both. The larger budget still bounds the attack (fails after 2^28 glyph steps, ~3 s), so test_subset_shared_coverage_budget now expects the failure at 8192 shared offsets instead of 2048. Subsetting all glyphs with --layout-features='*' of Gulzar, NotoSansKR-VF and GoogleSansFlex-VF keeps GSUB/GPOS/GDEF with output byte-identical to before; the heaviest table (Gulzar GPOS) spends ~98K units, under 0.04% of the budget. Full meson test: 278 OK. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 4.8 --- src/OT/Layout/Common/Coverage.hh | 5 ++ src/hb-limits.hh | 5 +- src/hb-ot-layout-common.hh | 13 ++++- src/hb-subset.hh | 10 +++- test/api/test-subset.c | 97 ++++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 5 deletions(-) diff --git a/src/OT/Layout/Common/Coverage.hh b/src/OT/Layout/Common/Coverage.hh index 4b12a9e8f..49b0bac96 100644 --- a/src/OT/Layout/Common/Coverage.hh +++ b/src/OT/Layout/Common/Coverage.hh @@ -190,6 +190,11 @@ struct Coverage { TRACE_SUBSET (this); const hb_subset_plan_t *plan = c->plan; + + /* Ranges are walked glyph by glyph, once per offset that points at us. */ + if (unlikely (!c->check_ops (hb_min (get_population (), plan->source->get_num_glyphs ())))) + return_trace (false); + auto it = + iter () | hb_take (plan->source->get_num_glyphs ()) diff --git a/src/hb-limits.hh b/src/hb-limits.hh index 27858b8ba..5bffa574f 100644 --- a/src/hb-limits.hh +++ b/src/hb-limits.hh @@ -251,7 +251,10 @@ hb_budget_spend (int64_t &budget, unsigned int cost, unsigned int mult = 1) * variable fonts spend -- the largest glyf variable font under test/ * (MPLUS1-Variable, 6,434 glyphs retained) uses ~1.2M units, and even a * font at the 65,535-glyph maximum stays far below -- while keeping the - * adversarial worst case bounded. */ + * adversarial worst case bounded. Layout tables charge their Coverage + * and ClassDef glyph walks to the same budget: a glyph range costs a few + * bytes and any number of offsets can share it, so neither the table size + * nor the sanitizer's budget bounds that work. */ #ifndef HB_BUDGET_SUBSET_GLYF #define HB_BUDGET_SUBSET_GLYF ((int64_t) 1 << 28) #endif diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index ba38cf51c..f7a52bb5a 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1614,6 +1614,8 @@ struct ClassDefFormat1_3 if (use_class_zero) { const hb_set_t& glyphset = *c->plan->glyphset_gsub (); + if (glyph_filter && unlikely (!c->check_ops (glyphset.get_population ()))) + return_trace (false); unsigned glyph_count = glyph_filter ? hb_len (hb_iter (glyphset) | hb_filter (glyph_filter)) : glyphset.get_population (); @@ -1866,8 +1868,13 @@ struct ClassDefFormat2_4 hb_sorted_vector_t glyph_and_klass; hb_set_t orig_klasses; - if (glyph_set.get_population () * hb_bit_storage ((unsigned) rangeRecord.len) - < get_population ()) + /* Either walk is repeated for every offset that points at us. */ + unsigned glyph_set_cost = glyph_set.get_population () * hb_bit_storage ((unsigned) rangeRecord.len); + unsigned population = get_population (); + if (unlikely (!c->check_ops (hb_min (glyph_set_cost, population)))) + return_trace (false); + + if (glyph_set_cost < population) { for (hb_codepoint_t g : glyph_set) { @@ -1902,6 +1909,8 @@ struct ClassDefFormat2_4 } const hb_set_t& glyphset = *c->plan->glyphset_gsub (); + if (glyph_filter && unlikely (!c->check_ops (glyphset.get_population ()))) + return_trace (false); unsigned glyph_count = glyph_filter ? hb_len (hb_iter (glyphset) | hb_filter (glyph_filter)) : glyphset.get_population (); diff --git a/src/hb-subset.hh b/src/hb-subset.hh index a44eb7b94..3ab7baac3 100644 --- a/src/hb-subset.hh +++ b/src/hb-subset.hh @@ -55,12 +55,18 @@ struct hb_subset_context_t : dispatch (const T &obj, Ts&&... ds) HB_AUTO_RETURN ( _dispatch (obj, hb_prioritize, std::forward (ds)...) ) + /* Charge COUNT units of work that the size of the source table does + * not bound. Fails the table once its budget is exhausted. */ + bool check_ops (unsigned count) + { return serializer->check_success (hb_budget_spend (budget_remaining, count)); } + hb_blob_t *source_blob; hb_subset_plan_t *plan; hb_serialize_context_t *serializer; hb_tag_t table_tag; - /* Outline work left for instancing this table. Lives here rather than in - * the table's subset() so retries with a larger buffer share it. */ + /* Work left for subsetting this table: outline work for glyf instancing, + * Coverage and ClassDef glyph walks for layout tables. Lives here rather + * than in the table's subset() so retries with a larger buffer share it. */ int64_t budget_remaining = HB_BUDGET_SUBSET_GLYF; hb_subset_context_t (hb_blob_t *source_blob_, diff --git a/test/api/test-subset.c b/test/api/test-subset.c index eaa0826a5..04af95b8b 100644 --- a/test/api/test-subset.c +++ b/test/api/test-subset.c @@ -94,6 +94,102 @@ test_subset_crash (void) hb_face_destroy (face); } +static char * +_put16 (char *p, unsigned v) +{ + *p++ = (char) (v >> 8); + *p++ = (char) (v & 0xFF); + return p; +} + +/* A GSUB with one reverse-chaining lookup whose backtrack_count backtrack + * offsets all point at one Coverage holding the single range 0..range_last, + * in a face declaring 65535 glyphs. Each offset costs two bytes but makes + * the subsetter walk the whole range. */ +static hb_face_t * +_create_shared_coverage_face (unsigned backtrack_count, unsigned range_last) +{ + static const char cmap_data[] = { + 0, 0, 0, 1, 0, 3, 0, 1, 0, 0, 0, 12, + 0, 6, 0, 12, 0, 0, 0, 'a', 0, 1, 0, 1, /* format 6: 'a' -> glyph 1 */ + }; + static const char maxp_data[] = { 0, 0, 0x50, 0, (char) 0xFF, (char) 0xFF }; + + unsigned subtable_length = 12 + 2 * backtrack_count + 6 + 10; + unsigned gsub_length = 10 + 20 + 14 + 4 + 8 + subtable_length; + char *gsub = g_malloc (gsub_length); + char *p = gsub; + + p = _put16 (p, 1); p = _put16 (p, 0); + p = _put16 (p, 10); p = _put16 (p, 30); p = _put16 (p, 44); + /* ScriptList: DFLT, default LangSys using feature 0. */ + p = _put16 (p, 1); memcpy (p, "DFLT", 4); p += 4; p = _put16 (p, 8); + p = _put16 (p, 4); p = _put16 (p, 0); + p = _put16 (p, 0); p = _put16 (p, 0xFFFF); p = _put16 (p, 1); p = _put16 (p, 0); + /* FeatureList: calt, using lookup 0. */ + p = _put16 (p, 1); memcpy (p, "calt", 4); p += 4; p = _put16 (p, 8); + p = _put16 (p, 0); p = _put16 (p, 1); p = _put16 (p, 0); + /* LookupList: one type 8 lookup with one subtable. */ + p = _put16 (p, 1); p = _put16 (p, 4); + p = _put16 (p, 8); p = _put16 (p, 0); p = _put16 (p, 1); p = _put16 (p, 8); + /* ReverseChainSingleSubstFormat1 substituting glyph 1 by itself. */ + p = _put16 (p, 1); p = _put16 (p, 12 + 2 * backtrack_count); + p = _put16 (p, backtrack_count); + for (unsigned i = 0; i < backtrack_count; i++) + p = _put16 (p, 12 + 2 * backtrack_count + 6); + p = _put16 (p, 0); + p = _put16 (p, 1); p = _put16 (p, 1); + p = _put16 (p, 1); p = _put16 (p, 1); p = _put16 (p, 1); + p = _put16 (p, 2); p = _put16 (p, 1); p = _put16 (p, 0); p = _put16 (p, range_last); p = _put16 (p, 0); + g_assert_cmpuint (p - gsub, ==, gsub_length); + + hb_face_t *builder = hb_face_builder_create (); + hb_blob_t *blob = hb_blob_create (gsub, gsub_length, HB_MEMORY_MODE_WRITABLE, gsub, g_free); + hb_face_builder_add_table (builder, HB_TAG ('G','S','U','B'), blob); + hb_blob_destroy (blob); + HB_FACE_ADD_TABLE (builder, "cmap", cmap_data); + HB_FACE_ADD_TABLE (builder, "maxp", maxp_data); + + blob = hb_face_reference_blob (builder); + hb_face_t *face = hb_face_create (blob, 0); + hb_blob_destroy (blob); + hb_face_destroy (builder); + return face; +} + +static void +test_subset_shared_coverage_budget (void) +{ + /* Walking 65535 glyphs per offset must run out of the per-table work + * budget (HB_BUDGET_SUBSET_GLYF) at 8192 offsets, but not at 256. */ + static const struct { unsigned backtrack_count, range_last; hb_bool_t expected; } cases[] = { + { 8192, 1, TRUE }, + { 256, 65534, TRUE }, + { 8192, 65534, FALSE }, + }; + + for (unsigned i = 0; i < G_N_ELEMENTS (cases); i++) + { + hb_face_t *face = _create_shared_coverage_face (cases[i].backtrack_count, cases[i].range_last); + + hb_subset_input_t *input = hb_subset_input_create_or_fail (); + hb_set_add (hb_subset_input_unicode_set (input), 'a'); + + hb_face_t *subset = hb_subset_or_fail (face, input); + g_assert_true (!subset == !cases[i].expected); + if (subset) + { + hb_blob_t *gsub = hb_face_reference_table (subset, HB_TAG ('G','S','U','B')); + g_assert_cmpuint (hb_blob_get_length (gsub), >, 0); + hb_blob_destroy (gsub); + } + + hb_subset_input_destroy (input); + hb_face_destroy (subset); + hb_face_destroy (face); + } +} + #ifndef HB_NO_VAR static void assert_lookup_variations_shape (hb_face_t *face, @@ -1706,6 +1802,7 @@ main (int argc, char **argv) hb_test_add (test_subset_32_tables); hb_test_add (test_subset_no_inf_loop); hb_test_add (test_subset_crash); + hb_test_add (test_subset_shared_coverage_budget); #ifndef HB_NO_VAR hb_test_add (test_subset_lookup_variations); hb_test_add (test_subset_lookup_variation_fractional_value); From edca03eadb7aca72b847d80220d7c4466a66508c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Nov 2026 17:12:12 -0600 Subject: [PATCH 13/18] [bit-vector] Use bounded bitvectors in GDEF and the repacker (#6630) Use hb_bit_vector_t and hb_min_max_t as Coverage sinks for the GDEF mark-set cache. Preserve the exact-cache span limit and fall back to the digest and table when allocation fails. Pack the repacker's Dijkstra visited flags into one bit per vertex. Fix singleton ranges and compute bit masks relative to the vector's minimum. Avoid overflow when sizing inclusive ranges, expose allocation failure, and add the Coverage sink methods needed by GDEF. Add regression tests for biased ranges, singleton and allocation boundaries, failing allocation, moves, and GDEF cache/table parity. Testing: full meson test suite (303 passed, 1 skipped); bitvector tests with AddressSanitizer and UndefinedBehaviorSanitizer; HB_TINY amalgamation syntax check. Assisted-by: OpenAI Codex --- src/OT/Layout/GDEF/GDEF.hh | 78 ++++++------------------ src/graph/graph.hh | 6 +- src/hb-bit-vector.hh | 40 +++++++++---- src/meson.build | 2 + src/test-bit-vector.cc | 119 +++++++++++++++++++++++++++++++++++++ src/test-gdef-cache.cc | 67 +++++++++++++++++++++ 6 files changed, 237 insertions(+), 75 deletions(-) create mode 100644 src/test-bit-vector.cc create mode 100644 src/test-gdef-cache.cc diff --git a/src/OT/Layout/GDEF/GDEF.hh b/src/OT/Layout/GDEF/GDEF.hh index f7f304c92..591aa7879 100644 --- a/src/OT/Layout/GDEF/GDEF.hh +++ b/src/OT/Layout/GDEF/GDEF.hh @@ -988,7 +988,7 @@ struct GDEF #ifndef HB_NO_GDEF_CACHE /* Flatten each mark set whose glyphs span fewer than PAGE_BITS - * gids into a single bit-page biased at its first glyph, for + * gids into a bit-vector biased at its first glyph, for * O(1) exact answers. Wider sets, or on allocation failure, * fall back to the table. * @@ -1004,21 +1004,22 @@ struct GDEF for (unsigned i = 0; i < count; i++) { auto &bitmap = mark_glyph_set_bitmaps.arrayZ[i]; - bitmap.bias = HB_SET_VALUE_INVALID; const Coverage &cov = mark_sets.get_coverage (i); - mark_glyph_set_extents_t extents; + hb_min_max_t extents; cov.collect_coverage (&extents); - if (extents.min_gid == HB_SET_VALUE_INVALID) + if (extents.get_min () == HB_SET_VALUE_INVALID) continue; - if (extents.max_gid - extents.min_gid >= hb_bit_page_t::PAGE_BITS) + if (extents.get_max () - extents.get_min () < hb_bit_page_t::PAGE_BITS) { - /* Too wide for one page; a digest pre-filter instead. */ - cov.collect_coverage (&bitmap.u.digest); - continue; + bitmap.glyphs = hb_bit_vector_t<> (extents.get_min (), extents.get_max ()); + if (likely (!bitmap.glyphs.in_error ())) + { + cov.collect_coverage (&bitmap.glyphs); + continue; + } } - bitmap.bias = extents.min_gid; - mark_glyph_set_page_t page {bitmap.u.page, extents.min_gid}; - cov.collect_coverage (&page); + /* Too wide, or allocation failed; a digest pre-filter instead. */ + cov.collect_coverage (&bitmap.digest); } } #endif @@ -1027,40 +1028,6 @@ struct GDEF hb_blob_ptr_t borrow_sanitized_table () const { return sanitized_table; } -#ifndef HB_NO_GDEF_CACHE - /* Sinks for Coverage::collect_coverage(): the gid extents of a - * coverage, and a bit-page filled with gids relative to a bias - * (which must be the coverage's min gid, with max - min < PAGE_BITS). */ - struct mark_glyph_set_extents_t - { - void add (hb_codepoint_t g) - { - min_gid = hb_min (min_gid, g); - max_gid = hb_max (max_gid, g); - } - bool add_range (hb_codepoint_t a, hb_codepoint_t b) - { if (a <= b) { add (a); add (b); } return true; } - template - bool add_sorted_array (const hb_sorted_array_t& arr) - { for (const auto &g : arr) add (g); return true; } - - hb_codepoint_t min_gid = HB_SET_VALUE_INVALID; - hb_codepoint_t max_gid = 0; - }; - struct mark_glyph_set_page_t - { - void add (hb_codepoint_t g) { page.add (g - bias); } - bool add_range (hb_codepoint_t a, hb_codepoint_t b) - { if (a <= b) page.add_range (a - bias, b - bias); return true; } - template - bool add_sorted_array (const hb_sorted_array_t& arr) - { for (const auto &g : arr) add (g); return true; } - - hb_bit_page_t &page; - hb_codepoint_t bias; - }; -#endif - unsigned int get_glyph_props (hb_codepoint_t glyph) const { unsigned v; @@ -1087,12 +1054,8 @@ struct GDEF #ifndef HB_NO_GDEF_CACHE // We can access arrayZ directly because of sanitize_lookup_props() guarantee. const auto &bitmap = mark_glyph_set_bitmaps.arrayZ[set_index]; - if (likely (bitmap.bias != HB_SET_VALUE_INVALID)) - { - hb_codepoint_t biased = glyph_id - bitmap.bias; - return biased < hb_bit_page_t::PAGE_BITS && - bitmap.u.page.get (biased); - } + if (likely (!bitmap.glyphs.in_error ())) + return bitmap.glyphs.has (glyph_id); return mark_set_covers_slow (set_index, glyph_id); #else return table->mark_set_covers (set_index, glyph_id); @@ -1104,7 +1067,7 @@ struct GDEF bool mark_set_covers_slow (unsigned int set_index, hb_codepoint_t glyph_id) const { const auto &bitmap = mark_glyph_set_bitmaps.arrayZ[set_index]; - if (!bitmap.u.digest.may_have (glyph_id)) + if (!bitmap.digest.may_have (glyph_id)) return false; return table->mark_set_covers (set_index, glyph_id); } @@ -1129,15 +1092,8 @@ struct GDEF #ifndef HB_NO_GDEF_CACHE struct mark_glyph_set_bitmap_t { - /* Gid of the first bit (not page-aligned) for an exact one-page - * set, or HB_SET_VALUE_INVALID; then digest is a pre-filter for - * the table. The all-zeros state is valid for both members. */ - hb_codepoint_t bias = HB_SET_VALUE_INVALID; - union u_t { - u_t () : page () {} - hb_bit_page_t page; - hb_set_digest_t digest; - } u; + hb_bit_vector_t<> glyphs {1, 0}; + hb_set_digest_t digest; }; hb_vector_t mark_glyph_set_bitmaps; diff --git a/src/graph/graph.hh b/src/graph/graph.hh index 0be13c1bb..0e720dd92 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -1886,8 +1886,8 @@ public: queue.insert (0, root_idx ()); TRY (graph_result_t::from (queue, ALLOCATION_FAILURE)); - hb_vector_t visited; - if (unlikely (!visited.resize (vertices_.length))) + hb_bit_vector_t<> visited (0, count - 1); + if (unlikely (visited.in_error ())) return Err(ALLOCATION_FAILURE); while (!queue.in_error () && !queue.is_empty ()) @@ -1896,7 +1896,7 @@ public: if (visited[next_idx]) continue; const auto& next = vertices_[next_idx]; int64_t next_distance = next.distance; - visited[next_idx] = true; + visited.add (next_idx); for (const auto& link : next.obj().all_links ()) { diff --git a/src/hb-bit-vector.hh b/src/hb-bit-vector.hh index 58084e59a..2aaef821c 100644 --- a/src/hb-bit-vector.hh +++ b/src/hb-bit-vector.hh @@ -27,17 +27,26 @@ #include "hb.hh" +#include "hb-array.hh" #include "hb-atomic.hh" struct hb_min_max_t { void add (hb_codepoint_t v) { min_v = hb_min (min_v, v); max_v = hb_max (max_v, v); } - void add_range (hb_codepoint_t a, hb_codepoint_t b) + bool add_range (hb_codepoint_t a, hb_codepoint_t b) { - min_v = hb_min (min_v, a); - max_v = hb_max (max_v, b); + if (a <= b) + { + min_v = hb_min (min_v, a); + max_v = hb_max (max_v, b); + } + return true; } + template + bool add_sorted_array (const hb_sorted_array_t& arr) + { for (const auto &v : arr) add (v); return true; } + template void union_ (const set_t &set) { @@ -86,17 +95,17 @@ struct hb_bit_vector_t hb_bit_vector_t (unsigned min_v, unsigned max_v) : min_v (min_v), max_v (max_v) { - if (unlikely (min_v >= max_v)) + if (unlikely (min_v > max_v || max_v - min_v == UINT_MAX)) { - min_v = max_v = count = 0; + this->min_v = this->max_v = count = 0; return; } - unsigned num = (max_v - min_v + sizeof (int_t) * 8) / (sizeof (int_t) * 8); + unsigned num = (max_v - min_v) / ELT_BITS + 1; elts = (elt_t *) hb_calloc (num, sizeof (int_t)); if (unlikely (!elts)) { - min_v = max_v = count = 0; + this->min_v = this->max_v = count = 0; return; } @@ -107,6 +116,9 @@ struct hb_bit_vector_t hb_free (elts); } + /* Invalid ranges and allocation failure leave the vector in error. */ + bool in_error () const { return !elts; } + void add (hb_codepoint_t g) { elt (g) |= mask (g); } void del (hb_codepoint_t g) { elt (g) &= ~mask (g); } void set (hb_codepoint_t g, bool value) { if (value) add (g); else del (g); } @@ -117,10 +129,11 @@ struct hb_bit_vector_t bool operator [] (hb_codepoint_t g) const { return get (g); } bool operator () (hb_codepoint_t g) const { return get (g); } - void add_range (hb_codepoint_t a, hb_codepoint_t b) + bool add_range (hb_codepoint_t a, hb_codepoint_t b) { - if (unlikely (!count || a > b || a < min_v || b > max_v)) - return; + if (unlikely (a > b)) return true; + if (unlikely (!count || a < min_v || b > max_v)) + return false; elt_t *la = &elt (a); elt_t *lb = &elt (b); @@ -135,7 +148,12 @@ struct hb_bit_vector_t *lb |= ((mask (b) << 1) - 1llu); } + return true; } + + template + bool add_sorted_array (const hb_sorted_array_t& arr) + { for (const auto &g : arr) add (g); return !in_error (); } void del_range (hb_codepoint_t a, hb_codepoint_t b) { if (unlikely (!count || a > b || a < min_v || b > max_v)) @@ -185,7 +203,7 @@ struct hb_bit_vector_t return elts[g / ELT_BITS]; } - static constexpr int_t mask (hb_codepoint_t g) { return elt_t (1) << (g & ELT_MASK); } + int_t mask (hb_codepoint_t g) const { return int_t (1) << ((g - min_v) & ELT_MASK); } hb_codepoint_t min_v = 0, max_v = 0, count = 0; elt_t *elts = nullptr; diff --git a/src/meson.build b/src/meson.build index d6ccf2e23..0f05e005d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -996,6 +996,8 @@ if get_option('tests').enabled() 'test-algs': ['test-algs.cc', 'hb-static.cc'], 'test-array': ['test-array.cc'], 'test-bimap': ['test-bimap.cc', 'hb-static.cc'], + 'test-bit-vector': ['test-bit-vector.cc', 'hb-static.cc'], + 'test-gdef-cache': ['test-gdef-cache.cc', 'hb-static.cc'], 'test-cache': ['test-cache.cc'], 'test-cff': ['test-cff.cc', 'hb-static.cc'], 'test-checksum': ['test-checksum.cc', 'hb-static.cc'], diff --git a/src/test-bit-vector.cc b/src/test-bit-vector.cc new file mode 100644 index 000000000..fd0aa918b --- /dev/null +++ b/src/test-bit-vector.cc @@ -0,0 +1,119 @@ +/* + * Copyright © 2026 Behdad Esfahbod + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author(s): Behdad Esfahbod + */ + +#define hb_calloc bit_vector_test_calloc + +#include "hb-bit-vector.hh" + +static bool fail_allocation; +static size_t last_allocation; + +extern "C" void * +bit_vector_test_calloc (size_t count, size_t size) +{ + last_allocation = count * size; + return fail_allocation ? nullptr : calloc (count, size); +} + +int +main () +{ + /* Check every bit offset, including ranges that wrap within a word + * or cross a word boundary relative to an unaligned minimum. */ + for (unsigned bias = 0; bias < 64; bias++) + for (unsigned first = 0; first < 130; first++) + for (unsigned last = first; last < 130; last++) + { + hb_bit_vector_t<> bits (bias, bias + 129); + hb_always_assert (!bits.in_error ()); + hb_always_assert (bits.add_range (bias + first, bias + last)); + for (unsigned i = 0; i < 130; i++) + hb_always_assert (bits.has (bias + i) == (first <= i && i <= last)); + bits.del_range (bias + first, bias + last); + for (unsigned i = 0; i < 130; i++) + hb_always_assert (!bits.has (bias + i)); + bits.add_range (bias, bias + 129); + bits.del_range (bias + first, bias + last); + for (unsigned i = 0; i < 130; i++) + hb_always_assert (bits.has (bias + i) == (i < first || i > last)); + } + + for (unsigned value : {0u, 37u, UINT_MAX}) + { + hb_bit_vector_t<> bits (value, value); + hb_always_assert (!bits.in_error ()); + hb_always_assert (bits.count == 1 && last_allocation == 8); + hb_always_assert (!bits.has (value)); + bits.add (value); + hb_always_assert (bits.has (value)); + bits.del (value); + hb_always_assert (!bits.has (value)); + } + + for (unsigned size : {1u, 64u, 65u, 512u}) + { + hb_bit_vector_t<> bits (37, 37 + size - 1); + hb_always_assert (last_allocation == (size + 63) / 64 * 8); + bits.add_range (37, 37 + size - 1); + hb_always_assert (!bits.has (36) && !bits.has (37 + size)); + hb_always_assert (!bits.has (UINT_MAX)); + bits.add (36); + bits.del (37 + size); + hb_always_assert (bits.has (37) && bits.has (37 + size - 1)); + hb_bit_vector_t<> moved (std::move (bits)); + hb_always_assert (bits.in_error () && moved.has (37)); + bits = std::move (moved); + hb_always_assert (bits.has (37) && moved.in_error ()); + } + + /* Empty/reversed and unrepresentable inclusive ranges must not allocate. */ + last_allocation = 0; + hb_bit_vector_t<> empty (1, 0); + hb_bit_vector_t<> overflow (0, UINT_MAX); + hb_always_assert (empty.in_error () && overflow.in_error ()); + hb_always_assert (!last_allocation); + + fail_allocation = true; + hb_bit_vector_t<> failed (37, 102); + hb_always_assert (failed.in_error () && !failed.count); + hb_always_assert (!failed.has (37)); + failed.add (37); + hb_always_assert (!failed.has (37)); + hb_always_assert (!failed.add_range (37, 102)); + fail_allocation = false; + + const unsigned values[] = {37, 63, 64, 65, 100}; + auto array = hb_sorted_array (values); + hb_min_max_t extents; + hb_always_assert (extents.add_range (100, 37)); + hb_always_assert (extents.get_min () == HB_CODEPOINT_INVALID); + hb_always_assert (extents.add_sorted_array (array)); + hb_always_assert (extents.get_min () == 37 && extents.get_max () == 100); + hb_bit_vector_t<> bits (extents.get_min (), extents.get_max ()); + hb_always_assert (bits.add_sorted_array (array)); + for (unsigned i = 0; i < 110; i++) + hb_always_assert (bits.has (i) == (i == 37 || i == 63 || i == 64 || i == 65 || i == 100)); +} diff --git a/src/test-gdef-cache.cc b/src/test-gdef-cache.cc new file mode 100644 index 000000000..d3b884cf0 --- /dev/null +++ b/src/test-gdef-cache.cc @@ -0,0 +1,67 @@ +/* + * Copyright © 2026 Behdad Esfahbod + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author(s): Behdad Esfahbod + */ + +#include "hb-ot-layout-gdef-table.hh" + +int +main () +{ +#if !defined(HB_NO_GDEF_CACHE) && !defined(HB_NO_OT_LAYOUT) + /* Empty, singleton, sparse, unaligned ranges, all glyphs, and spans + * immediately below and above the exact-cache limit. */ + static const unsigned char data[] = { + 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, + 0, 1, 0, 7, + 0, 0, 0, 32, 0, 0, 0, 36, 0, 0, 0, 42, 0, 0, 0, 56, + 0, 0, 0, 72, 0, 0, 0, 82, 0, 0, 0, 92, + 0, 1, 0, 0, + 0, 1, 0, 1, 0, 37, + 0, 1, 0, 5, 0, 37, 0, 63, 0, 64, 0, 65, 0, 100, + 0, 2, 0, 2, 0, 37, 0, 102, 0, 0, 0, 150, 0, 159, 0, 66, + 0, 2, 0, 1, 0, 0, 255, 255, 0, 0, + 0, 2, 0, 1, 0, 37, 2, 36, 0, 0, + 0, 2, 0, 1, 0, 37, 2, 37, 0, 0, + }; + hb_face_t *face = hb_face_builder_create (); + hb_blob_t *blob = hb_blob_create ((const char *) data, sizeof (data), + HB_MEMORY_MODE_READONLY, nullptr, nullptr); + hb_always_assert (hb_face_builder_add_table (face, HB_OT_TAG_GDEF, blob)); + hb_blob_destroy (blob); + hb_ot_layout_has_glyph_classes (face); + const auto *accel = face->table.GDEF.get_relaxed (); + hb_always_assert (accel && accel->mark_glyph_set_bitmaps.length == 7); + for (unsigned set = 0; set < 7; set++) + { + bool exact = set == 1 || set == 2 || set == 3 || set == 5; + hb_always_assert (accel->mark_glyph_set_bitmaps[set].glyphs.in_error () == !exact); + for (unsigned glyph = 0; glyph <= 65536; glyph++) + hb_always_assert (accel->mark_set_covers (set, glyph) == + accel->table->mark_set_covers (set, glyph)); + hb_always_assert (!accel->mark_set_covers (set, UINT_MAX)); + } + hb_face_destroy (face); +#endif +} From fd57025171ff9ba3c77525d02f558a780cb0f32c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Nov 2026 19:15:38 -0600 Subject: [PATCH 14/18] [syllabic] Record HB_MAX_SYLLABLE_LENGTH cuts so every pass sees the same pieces (#6558) Since 12b686dad, _hb_next_syllable() cuts syllables longer than HB_MAX_SYLLABLE_LENGTH at whatever glyph index the walk reaches, and nothing records that cut. The Indic shaper's initial and final reordering (with GSUB features shortening the buffer in between) then walk different pieces, the deferred pre-base-matra cluster merge never happens, and hb_shape() returns non-monotone clusters at the default MONOTONE_GRAPHEMES level for an over-long Indic syllable. Add hb_syllabic_record_cut(), next to the other shared syllabic helpers, and call it on each piece from the foreach_syllable() loops that already exist where syllables are set up in all four syllabic shapers (Indic, Khmer, Myanmar, USE), and once more in Indic initial reordering since dotted-circle insertion can push a piece back over the limit. Its inline fast path is a single length compare, so it costs nothing unless a piece reaches the limit. Only a piece of HB_MAX_SYLLABLE_LENGTH glyphs that is followed by more of the same syllable takes the slow path: it cuts the rest of the syllable into the pieces foreach_syllable() would make, gives every piece but the last one of two serials that differ from the preceding syllable and from the last piece (which keeps the ragel serial), so substituted glyphs inherit it and all later walks see identical pieces, and merges the whole oversized syllable into one cluster (merge_clusters at monotone cluster levels, unsafe-to-break otherwise) so the cut cannot become a line-break opportunity mid-syllable. Serials of all other syllables are untouched, so numbering and wraparound are exactly what the ragel machines produce. The cut in _hb_next_syllable() stays as the backstop. Behaviour change: syllables longer than HB_MAX_SYLLABLE_LENGTH become a single cluster, where previously each piece got its own clusters. A regression test with a 68-codepoint Devanagari input is added to indic-syllable.tests; it fails (non-monotone clusters) on the unpatched tree. Tested: meson test (all pass). hb-shape on hi-words / a 175KB Devanagari paragraph shows no measurable slowdown. Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-W15T9EXZ. Co-authored-by: Claude Opus 4.8 --- src/hb-ot-shaper-indic.cc | 8 +++ src/hb-ot-shaper-khmer.cc | 3 ++ src/hb-ot-shaper-myanmar.cc | 3 ++ src/hb-ot-shaper-syllabic.cc | 49 +++++++++++++++++++ src/hb-ot-shaper-syllabic.hh | 18 +++++++ src/hb-ot-shaper-use.cc | 3 ++ .../data/in-house/tests/indic-syllable.tests | 1 + 7 files changed, 85 insertions(+) diff --git a/src/hb-ot-shaper-indic.cc b/src/hb-ot-shaper-indic.cc index b935ced6e..60328ea00 100644 --- a/src/hb-ot-shaper-indic.cc +++ b/src/hb-ot-shaper-indic.cc @@ -418,7 +418,10 @@ setup_syllables_indic (const hb_ot_shape_plan_t *plan HB_UNUSED, HB_BUFFER_ALLOCATE_VAR (buffer, syllable); find_syllables_indic (buffer); foreach_syllable (buffer, start, end) + { + hb_syllabic_record_cut (buffer, start, end); buffer->unsafe_to_break (start, end); + } return false; } @@ -988,7 +991,12 @@ initial_reordering_indic (const hb_ot_shape_plan_t *plan, ret = true; foreach_syllable (buffer, start, end) + { + /* locl, ccmp, or inserted dotted-circles may have pushed a piece over + * the limit again; final reordering needs to see the same pieces. */ + hb_syllabic_record_cut (buffer, start, end); initial_reordering_syllable_indic (plan, font->face, buffer, start, end); + } (void) buffer->message (font, "end reordering indic initial"); diff --git a/src/hb-ot-shaper-khmer.cc b/src/hb-ot-shaper-khmer.cc index eb3b585e8..3e5b93eb0 100644 --- a/src/hb-ot-shaper-khmer.cc +++ b/src/hb-ot-shaper-khmer.cc @@ -194,7 +194,10 @@ setup_syllables_khmer (const hb_ot_shape_plan_t *plan HB_UNUSED, HB_BUFFER_ALLOCATE_VAR (buffer, syllable); find_syllables_khmer (buffer); foreach_syllable (buffer, start, end) + { + hb_syllabic_record_cut (buffer, start, end); buffer->unsafe_to_break (start, end); + } return false; } diff --git a/src/hb-ot-shaper-myanmar.cc b/src/hb-ot-shaper-myanmar.cc index 1b2a085a8..c4a6316cd 100644 --- a/src/hb-ot-shaper-myanmar.cc +++ b/src/hb-ot-shaper-myanmar.cc @@ -158,7 +158,10 @@ setup_syllables_myanmar (const hb_ot_shape_plan_t *plan HB_UNUSED, HB_BUFFER_ALLOCATE_VAR (buffer, syllable); find_syllables_myanmar (buffer); foreach_syllable (buffer, start, end) + { + hb_syllabic_record_cut (buffer, start, end); buffer->unsafe_to_break (start, end); + } return false; } diff --git a/src/hb-ot-shaper-syllabic.cc b/src/hb-ot-shaper-syllabic.cc index 97f62035c..e7631df95 100644 --- a/src/hb-ot-shaper-syllabic.cc +++ b/src/hb-ot-shaper-syllabic.cc @@ -99,6 +99,55 @@ hb_syllabic_insert_dotted_circles (hb_font_t *font, return true; } +/* foreach_syllable() cuts syllables longer than HB_MAX_SYLLABLE_LENGTH, + * but the cut is computed from the current glyph positions and is not + * recorded, so walks before and after substitutions would see different + * pieces. Record the cuts in syllable(), which substituted glyphs inherit: + * cut the whole syllable starting at start into the same pieces + * foreach_syllable() would, and give every piece but the last a serial + * different from its neighbours. The rest of the walk then sees pieces + * that are not cut further. The pieces are not syllables on their own and + * text must not be broken between them, so also keep them in one cluster. */ +void +hb_syllabic_record_cut_slow (hb_buffer_t *buffer, + unsigned int start, + unsigned int end) +{ + hb_glyph_info_t *info = buffer->info; + unsigned int count = buffer->len; + unsigned int syllable = info[start].syllable(); + if (end == count || info[end].syllable() != syllable) + return; /* Not cut. */ + + unsigned int syllable_end = end; + while (syllable_end < count && info[syllable_end].syllable() == syllable) + syllable_end++; + + buffer->merge_clusters (start, syllable_end); + + /* Alternate between two serials different from both the one before + * start and the one the last piece keeps. */ + unsigned int prev_serial = start ? info[start - 1].syllable() >> 4 : 0; + unsigned int last_serial = syllable >> 4; + unsigned int serials[2]; + unsigned int serial = 1; + for (unsigned int j = 0; j < 2; j++) + { + while (serial == prev_serial || serial == last_serial) + serial++; + serials[j] = serial++; + } + + unsigned int j = 0; + for (; syllable_end - start > HB_MAX_SYLLABLE_LENGTH; start = end, j ^= 1) + { + end = start + HB_MAX_SYLLABLE_LENGTH; + unsigned int v = (serials[j] << 4) | (syllable & 0x0F); + for (unsigned int i = start; i < end; i++) + info[i].syllable() = v; + } +} + HB_INTERNAL bool hb_syllabic_clear_var (const hb_ot_shape_plan_t *plan, hb_font_t *font, diff --git a/src/hb-ot-shaper-syllabic.hh b/src/hb-ot-shaper-syllabic.hh index f240ad1c2..bc2dd3215 100644 --- a/src/hb-ot-shaper-syllabic.hh +++ b/src/hb-ot-shaper-syllabic.hh @@ -38,6 +38,24 @@ hb_syllabic_insert_dotted_circles (hb_font_t *font, int repha_category = -1, int dottedcircle_position = -1); +HB_INTERNAL void +hb_syllabic_record_cut_slow (hb_buffer_t *buffer, + unsigned int start, + unsigned int end); + +/* Call for each piece [start, end) that foreach_syllable() yields. + * foreach_syllable() cuts syllables longer than HB_MAX_SYLLABLE_LENGTH; + * this records such cuts so later walks see the same pieces. Only does + * work for pieces of HB_MAX_SYLLABLE_LENGTH glyphs. */ +static inline void +hb_syllabic_record_cut (hb_buffer_t *buffer, + unsigned int start, + unsigned int end) +{ + if (unlikely (end - start >= HB_MAX_SYLLABLE_LENGTH)) + hb_syllabic_record_cut_slow (buffer, start, end); +} + HB_INTERNAL bool hb_syllabic_clear_var (const hb_ot_shape_plan_t *plan, hb_font_t *font, diff --git a/src/hb-ot-shaper-use.cc b/src/hb-ot-shaper-use.cc index c35765af9..84153c7d7 100644 --- a/src/hb-ot-shaper-use.cc +++ b/src/hb-ot-shaper-use.cc @@ -301,7 +301,10 @@ setup_syllables_use (const hb_ot_shape_plan_t *plan, HB_BUFFER_ALLOCATE_VAR (buffer, syllable); find_syllables_use (buffer); foreach_syllable (buffer, start, end) + { + hb_syllabic_record_cut (buffer, start, end); buffer->unsafe_to_break (start, end); + } setup_rphf_mask (plan, buffer); setup_topographical_masks (plan, buffer); return false; diff --git a/test/shape/data/in-house/tests/indic-syllable.tests b/test/shape/data/in-house/tests/indic-syllable.tests index 84526d9cd..62c03d9a1 100644 --- a/test/shape/data/in-house/tests/indic-syllable.tests +++ b/test/shape/data/in-house/tests/indic-syllable.tests @@ -13,3 +13,4 @@ ../fonts/e2b17207c4b7ad78d843e1b0c4d00b09398a1137.ttf;;U+0BAA,U+0BAA,U+0BCD;[pa-tamil=0+778|pa-tamil.001=1+778|pulli-tamil=1@-385,0+0] ../fonts/41071178fbce4956d151f50967af458dbf555f7b.ttf;;U+0926,U+093F,U+0938,U+0902,U+092C,U+0930;[isigndeva=0+266|dadeva=0+541|sadeva=2+709|anusvaradeva=2@0,-1+0|badeva=4+537|radeva=5+436] ../fonts/65d1b9099cfb3191931d8d6112d7a03d979d579f.ttf;;U+00B2,U+0B95;[uni00B2=0+500|uni0B95=1+500] +../fonts/8116e5d8fedfbec74e45dc350d2416d810bed8c4.ttf;--no-positions;U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+094D,U+091F,U+093F;[uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni091F094D091F=0|uni094D=0|uni093F.630=0|uni091F094D091F=0] From fb350edda9f6ce2f4b5f645f7a0535bb9ec74ab2 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 30 Oct 2026 14:53:06 -0600 Subject: [PATCH 15/18] [ot] Collect class-based contextual rule classes once per ClassDef in collect_glyphs Rule::collect_second_glyphs() resolved the second input glyph of a class-based contextual rule by scanning the whole input ClassDef once per rule, so a RuleSet with many rules sharing one large ClassDef was quadratic in collect_glyphs() (and thus in subsetting). Collect the needed classes into a set and walk each ClassDef once for all of them: add ClassDef::collect_classes(), and have collect_second_glyphs() accumulate the classes and resolve them in a single pass. The collected sets are identical; only the work is reduced. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-5FCXNOQF. Co-Authored-By: Claude Opus 4.8 --- src/hb-ot-layout-common.hh | 36 +++++++++++ src/hb-ot-layout-gsubgpos.hh | 103 +++++++++++++++++++++--------- test/api/test-ot-collect-glyphs.c | 102 +++++++++++++++++++++++++++++ 3 files changed, 210 insertions(+), 31 deletions(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index f7a52bb5a..0fa0d2803 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1670,6 +1670,15 @@ struct ClassDefFormat1_3 return true; } + template + bool collect_classes (set_t *glyphs, const hb_set_t &klasses) const + { + unsigned int count = classValue.len; + for (unsigned int i = 0; i < count; i++) + if (klasses.has (classValue[i])) glyphs->add (startGlyph + i); + return true; + } + bool intersects (const hb_set_t *glyphs) const { hb_codepoint_t start = startGlyph; @@ -1954,6 +1963,18 @@ struct ClassDefFormat2_4 return true; } + template + bool collect_classes (set_t *glyphs, const hb_set_t &klasses) const + { + for (auto &range : rangeRecord) + { + if (klasses.has (range.value)) + if (unlikely (!range.collect_coverage (glyphs))) + return false; + } + return true; + } + bool intersects (const hb_set_t *glyphs) const { if (rangeRecord.len > glyphs->get_population () * hb_bit_storage ((unsigned) rangeRecord.len)) @@ -2296,6 +2317,21 @@ struct ClassDef } } + /* Like collect_class(), for all of klasses in one walk of the table. */ + template + bool collect_classes (set_t *glyphs, const hb_set_t &klasses) const + { + switch (u.format.v) { + case 1: hb_barrier (); return u.format1.collect_classes (glyphs, klasses); + case 2: hb_barrier (); return u.format2.collect_classes (glyphs, klasses); +#ifndef HB_NO_BEYOND_64K + case 3: hb_barrier (); return u.format3.collect_classes (glyphs, klasses); + case 4: hb_barrier (); return u.format4.collect_classes (glyphs, klasses); +#endif + default:return false; + } + } + bool intersects (const hb_set_t *glyphs) const { switch (u.format.v) { diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index d9f1a3428..99febc159 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -1736,6 +1736,12 @@ static inline void collect_class (hb_set_t *glyphs, unsigned value, const void * const ClassDef &class_def = *reinterpret_cast(data); class_def.collect_class (glyphs, value); } +static inline void collect_classes (hb_set_t *glyphs, const hb_set_t &classes, const ClassDef &class_def) +{ + if (unlikely (classes.in_error ())) + glyphs->err (); + class_def.collect_classes (glyphs, classes); +} static inline void collect_coverage (hb_set_t *glyphs, unsigned value, const void *data) { Offset32To coverage; @@ -3137,7 +3143,7 @@ struct Rule } void collect_second_glyphs (hb_set_digest_t *digest, - const ClassDef *class_def = nullptr) const + hb_set_t *classes = nullptr) const { if (inputCount <= 1) { @@ -3146,12 +3152,12 @@ struct Rule } unsigned second = inputZ.arrayZ[0]; - if (!class_def) + if (!classes) digest->add (second); else if (!second) *digest = hb_set_digest_t::full (); else - class_def->collect_class (digest, second); + classes->add (second); } bool would_apply (hb_would_apply_context_t *c, @@ -3307,11 +3313,11 @@ struct RuleSetOf } void collect_second_glyphs (hb_set_digest_t *digest, - const ClassDef *class_def = nullptr) const + hb_set_t *classes = nullptr) const { + hb_iter (rule) | hb_map (hb_add (this)) - | hb_apply ([=] (const RuleType &_) { _.collect_second_glyphs (digest, class_def); }) + | hb_apply ([=] (const RuleType &_) { _.collect_second_glyphs (digest, classes); }) ; } @@ -3847,25 +3853,40 @@ struct ContextFormat2_5 { (this+coverage).collect_coverage (c->input); - const ClassDef &class_def = this+classDef; + /* Rules repeat classes, and can be shared. Collect the class values + * first, such that the ClassDef is walked once instead of per value. */ + hb_set_t input_classes; + hb_set_t *input = c->input; + c->input = &input_classes; + struct ContextCollectGlyphsLookupContext lookup_context = { - {collect_class}, - &class_def + {collect_glyph}, + nullptr }; + hb_iter (ruleSet) | hb_map (hb_add (this)) | hb_apply ([&] (const RuleSet &_) { _.collect_glyphs (c, lookup_context); }) ; + + c->input = input; + + collect_classes (c->input, input_classes, this+classDef); } void collect_second_glyphs (hb_set_digest_t *digest) const { - const ClassDef &class_def = this+classDef; + /* Ditto. */ + hb_set_t classes; + hb_iter (ruleSet) | hb_map (hb_add (this)) - | hb_apply ([=, &class_def] (const RuleSet &_) { _.collect_second_glyphs (digest, &class_def); }) + | hb_apply ([=, &classes] (const RuleSet &_) { _.collect_second_glyphs (digest, &classes); }) ; + + if (unlikely (classes.in_error ())) + *digest = hb_set_digest_t::full (); + else + (this+classDef).collect_classes (digest, classes); } bool would_apply (hb_would_apply_context_t *c) const @@ -4669,23 +4690,23 @@ struct ChainRule } void collect_second_glyphs (hb_set_digest_t *digest, - const ClassDef *input_class_def = nullptr, - const ClassDef *lookahead_class_def = nullptr) const + hb_set_t *input_classes = nullptr, + hb_set_t *lookahead_classes = nullptr) const { const auto &input = StructAfter (backtrack); const auto &lookahead = StructAfter (input); unsigned second; - const ClassDef *class_def; + hb_set_t *classes; if (input.lenP1 > 1) { second = input.arrayZ[0]; - class_def = input_class_def; + classes = input_classes; } else if (lookahead.len) { second = lookahead.arrayZ[0]; - class_def = lookahead_class_def; + classes = lookahead_classes; } else { @@ -4693,12 +4714,12 @@ struct ChainRule return; } - if (!class_def) + if (!classes) digest->add (second); else if (!second) *digest = hb_set_digest_t::full (); else - class_def->collect_class (digest, second); + classes->add (second); } bool would_apply (hb_would_apply_context_t *c, @@ -4909,13 +4930,13 @@ struct ChainRuleSetOf } void collect_second_glyphs (hb_set_digest_t *digest, - const ClassDef *input_class_def = nullptr, - const ClassDef *lookahead_class_def = nullptr) const + hb_set_t *input_classes = nullptr, + hb_set_t *lookahead_classes = nullptr) const { + hb_iter (rule) | hb_map (hb_add (this)) | hb_apply ([=] (const ChainRuleType &_) - { _.collect_second_glyphs (digest, input_class_def, lookahead_class_def); }) + { _.collect_second_glyphs (digest, input_classes, lookahead_classes); }) ; } @@ -5489,32 +5510,52 @@ struct ChainContextFormat2_5 { (this+coverage).collect_coverage (c->input); - const ClassDef &backtrack_class_def = this+backtrackClassDef; - const ClassDef &input_class_def = this+inputClassDef; - const ClassDef &lookahead_class_def = this+lookaheadClassDef; + /* Rules repeat classes, and can be shared. Collect the class values + * first, such that each ClassDef is walked once instead of per value. */ + hb_set_t backtrack_classes, input_classes, lookahead_classes; + hb_set_t *before = c->before; + hb_set_t *input = c->input; + hb_set_t *after = c->after; + c->before = &backtrack_classes; + c->input = &input_classes; + c->after = &lookahead_classes; struct ChainContextCollectGlyphsLookupContext lookup_context = { - {collect_class}, - {&backtrack_class_def, - &input_class_def, - &lookahead_class_def} + {collect_glyph}, + {nullptr, nullptr, nullptr} }; + hb_iter (ruleSet) | hb_map (hb_add (this)) | hb_apply ([&] (const ChainRuleSet &_) { _.collect_glyphs (c, lookup_context); }) ; + + c->before = before; + c->input = input; + c->after = after; + + collect_classes (c->before, backtrack_classes, this+backtrackClassDef); + collect_classes (c->input, input_classes, this+inputClassDef); + collect_classes (c->after, lookahead_classes, this+lookaheadClassDef); } void collect_second_glyphs (hb_set_digest_t *digest) const { - const ClassDef &input_class_def = this+inputClassDef; - const ClassDef &lookahead_class_def = this+lookaheadClassDef; + /* Ditto. */ + hb_set_t input_classes, lookahead_classes; + hb_iter (ruleSet) | hb_map (hb_add (this)) - | hb_apply ([digest, &input_class_def, &lookahead_class_def] (const ChainRuleSet &_) - { _.collect_second_glyphs (digest, &input_class_def, &lookahead_class_def); }) + | hb_apply ([digest, &input_classes, &lookahead_classes] (const ChainRuleSet &_) + { _.collect_second_glyphs (digest, &input_classes, &lookahead_classes); }) ; + + if (unlikely (input_classes.in_error () || lookahead_classes.in_error ())) + { + *digest = hb_set_digest_t::full (); + return; + } + (this+inputClassDef).collect_classes (digest, input_classes); + (this+lookaheadClassDef).collect_classes (digest, lookahead_classes); } bool would_apply (hb_would_apply_context_t *c) const diff --git a/test/api/test-ot-collect-glyphs.c b/test/api/test-ot-collect-glyphs.c index 41f61807b..8b307906e 100644 --- a/test/api/test-ot-collect-glyphs.c +++ b/test/api/test-ot-collect-glyphs.c @@ -481,6 +481,107 @@ test_ot_layout_lookup_collect_glyphs_qahiri (void) hb_set_destroy (output); } +static uint8_t * +put16 (uint8_t *p, unsigned v) +{ + *p++ = (uint8_t) (v >> 8); + *p++ = (uint8_t) v; + return p; +} + +static void +test_ot_layout_lookup_collect_glyphs_shared_class_rules (void) +{ + /* A ContextSubstFormat2 whose RuleSet offsets all point at one RuleSet, + * whose Rule offsets all point at one Rule with 64 class values, over a + * 65535-entry ClassDef. The ClassDef must be walked once per subtable, + * not once per class value of every Rule visited; the latter takes + * about a minute. */ + enum { RULESETS = 16, RULES = 1000, CLASSES = 64, GLYPHS = 65535 }; + unsigned rule_len = 4 + 2 * CLASSES; + unsigned ruleset_len = 2 + 2 * RULES + rule_len; + unsigned coverage_len = 6; + unsigned classdef_len = 6 + 2 * GLYPHS; + unsigned ruleset_offset = 8 + 2 * RULESETS; + unsigned coverage_offset = ruleset_offset + ruleset_len; + unsigned classdef_offset = coverage_offset + coverage_len; + unsigned gsub_len = 10 + 2 + 2 + 4 + 8 + classdef_offset + classdef_len; + uint8_t *gsub = g_malloc0 (gsub_len); + uint8_t *p = gsub; + + /* GSUB header, empty ScriptList and FeatureList, LookupList with one lookup. */ + p = put16 (p, 1); p = put16 (p, 0); + p = put16 (p, 10); p = put16 (p, 12); p = put16 (p, 14); + p = put16 (p, 0); + p = put16 (p, 0); + p = put16 (p, 1); p = put16 (p, 4); + /* Lookup: type 5 (Context), one subtable right after. */ + p = put16 (p, 5); p = put16 (p, 0); p = put16 (p, 1); p = put16 (p, 8); + /* ContextSubstFormat2 */ + p = put16 (p, 2); p = put16 (p, coverage_offset); p = put16 (p, classdef_offset); + p = put16 (p, RULESETS); + for (unsigned i = 0; i < RULESETS; i++) + p = put16 (p, ruleset_offset); + /* RuleSet */ + p = put16 (p, RULES); + for (unsigned i = 0; i < RULES; i++) + p = put16 (p, 2 + 2 * RULES); + /* Rule: classes 1 and 2, alternating. */ + p = put16 (p, CLASSES + 1); p = put16 (p, 0); + for (unsigned i = 0; i < CLASSES; i++) + p = put16 (p, 1 + (i & 1)); + /* Coverage: glyph 1. */ + p = put16 (p, 1); p = put16 (p, 1); p = put16 (p, 1); + /* ClassDefFormat1: glyph i has class i % 3. */ + p = put16 (p, 1); p = put16 (p, 0); p = put16 (p, GLYPHS); + for (unsigned i = 0; i < GLYPHS; i++) + p = put16 (p, i % 3); + g_assert_cmpuint (p - gsub, ==, gsub_len); + + hb_blob_t *blob = hb_blob_create_or_fail ((const char *) gsub, gsub_len, + HB_MEMORY_MODE_WRITABLE, gsub, g_free); + hb_face_t *builder = hb_face_builder_create (); + hb_face_builder_add_table (builder, HB_OT_TAG_GSUB, blob); + hb_blob_destroy (blob); + blob = hb_face_reference_blob (builder); + hb_face_destroy (builder); + hb_face_t *face = hb_face_create (blob, 0); + hb_blob_destroy (blob); + + hb_set_t *before = hb_set_create(); + hb_set_t *input = hb_set_create(); + hb_set_t *after = hb_set_create(); + hb_set_t *output = hb_set_create(); + hb_codepoint_t g = HB_SET_VALUE_INVALID; + + g_assert_cmpuint (1, ==, hb_ot_layout_table_get_lookup_count (face, HB_OT_TAG_GSUB)); + + BEGIN(HB_OT_TAG_GSUB, 0); + g_assert_cmpuint (0, ==, hb_set_get_population (before)); + + /* Glyph 1 from the coverage, and every glyph of class 1 or 2. */ + g_assert_cmpuint (2 * (GLYPHS / 3), ==, hb_set_get_population (input)); + g = HB_SET_VALUE_INVALID; + g_assert_true (hb_set_next (input, &g)); + g_assert_cmpuint (1, ==, g); + g_assert_true (hb_set_next (input, &g)); + g_assert_cmpuint (2, ==, g); + g_assert_true (hb_set_next (input, &g)); + g_assert_cmpuint (4, ==, g); + g_assert_false (hb_set_has (input, 0)); + g_assert_true (hb_set_has (input, GLYPHS - 1)); + + g_assert_cmpuint (0, ==, hb_set_get_population (after)); + g_assert_cmpuint (0, ==, hb_set_get_population (output)); + END(); + + hb_face_destroy (face); + hb_set_destroy (before); + hb_set_destroy (input); + hb_set_destroy (after); + hb_set_destroy (output); +} + int main (int argc, char **argv) { @@ -488,5 +589,6 @@ main (int argc, char **argv) hb_test_add (test_ot_layout_lookup_collect_glyphs_source_sans); hb_test_add (test_ot_layout_lookup_collect_glyphs_noto_nastaliq); hb_test_add (test_ot_layout_lookup_collect_glyphs_qahiri); + hb_test_add (test_ot_layout_lookup_collect_glyphs_shared_class_rules); return hb_test_run (); } From 0cf5addc3ecd3f6ce99758fa59f30a42f099db6d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 30 Oct 2026 14:54:02 -0600 Subject: [PATCH 16/18] [GSUB] Add small-active-set closure/depend fast path to Coverage-keyed lookups SingleSubstFormat2 already picks, per closure visit, between walking its whole Coverage and iterating the (usually small) active glyph set. The Multiple/Alternate/Ligature/ReverseChain closure and depend paths, the format-1 (Chain)Context closure, and Coverage::intersect_set lacked that choice, so a nested lookup visited many times over a small active set re-walked a large Coverage every time, giving quadratic GSUB closure (and thus subsetting) time. Add the same get_population()-based fast path to those paths and to CoverageFormat1/2::intersect_set. Output is byte-identical; only the per-visit work is bounded. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-KNHDK379. Co-Authored-By: Claude Opus 4.8 --- src/OT/Layout/Common/CoverageFormat1.hh | 8 ++ src/OT/Layout/Common/CoverageFormat2.hh | 8 ++ src/OT/Layout/GSUB/AlternateSubstFormat1.hh | 40 ++++++++- src/OT/Layout/GSUB/LigatureSubstFormat1.hh | 40 ++++++++- src/OT/Layout/GSUB/MultipleSubstFormat1.hh | 40 ++++++++- .../GSUB/ReverseChainSingleSubstFormat1.hh | 44 ++++++++-- src/hb-ot-layout-gsubgpos.hh | 32 +++++++ test/api/test-ot-layout.c | 85 +++++++++++++++++++ 8 files changed, 279 insertions(+), 18 deletions(-) diff --git a/src/OT/Layout/Common/CoverageFormat1.hh b/src/OT/Layout/Common/CoverageFormat1.hh index ee9425ec2..56f38de49 100644 --- a/src/OT/Layout/Common/CoverageFormat1.hh +++ b/src/OT/Layout/Common/CoverageFormat1.hh @@ -97,6 +97,14 @@ struct CoverageFormat1_3 hb_requires (hb_is_sink_of (IterableOut, hb_codepoint_t))> void intersect_set (const hb_set_t &glyphs, IterableOut&& intersect_glyphs) const { + if (glyphArray.len > glyphs.get_population () * hb_bit_storage ((unsigned) glyphArray.len)) + { + for (auto g : glyphs) + if (get_coverage (g) != NOT_COVERED) + intersect_glyphs << g; + return; + } + unsigned count = glyphArray.len; for (unsigned i = 0; i < count; i++) if (glyphs.has (glyphArray[i])) diff --git a/src/OT/Layout/Common/CoverageFormat2.hh b/src/OT/Layout/Common/CoverageFormat2.hh index b22c4d782..db4053766 100644 --- a/src/OT/Layout/Common/CoverageFormat2.hh +++ b/src/OT/Layout/Common/CoverageFormat2.hh @@ -157,6 +157,14 @@ struct CoverageFormat2_4 hb_requires (hb_is_sink_of (IterableOut, hb_codepoint_t))> void intersect_set (const hb_set_t &glyphs, IterableOut&& intersect_glyphs) const { + if (rangeRecord.len > glyphs.get_population () * hb_bit_storage ((unsigned) rangeRecord.len)) + { + for (auto g : glyphs) + if (get_coverage (g) != NOT_COVERED) + intersect_glyphs << g; + return; + } + /* Break out of loop for overlapping, broken, tables, * to avoid fuzzer timouts. */ hb_codepoint_t last = 0; diff --git a/src/OT/Layout/GSUB/AlternateSubstFormat1.hh b/src/OT/Layout/GSUB/AlternateSubstFormat1.hh index b4b279b3a..2fb59ee98 100644 --- a/src/OT/Layout/GSUB/AlternateSubstFormat1.hh +++ b/src/OT/Layout/GSUB/AlternateSubstFormat1.hh @@ -36,9 +36,25 @@ struct AlternateSubstFormat1_2 void depend (hb_depend_context_t *c) const { + auto &cov = this+coverage; + auto &glyph_set = c->parent_active_glyphs (); + // Filter by parent_active_glyphs like closure does - + hb_zip (this+coverage, alternateSet) - | hb_filter (c->parent_active_glyphs (), hb_first) + if (alternateSet.len > glyph_set.get_population () * 4) + { + for (auto g : glyph_set) + { + unsigned i = cov.get_coverage (g); + if (i == NOT_COVERED || i >= alternateSet.len) + continue; + (this+alternateSet.arrayZ[i]).depend (c, g); + } + + return; + } + + + hb_zip (cov, alternateSet) + | hb_filter (glyph_set, hb_first) | hb_apply ([&] (const hb_pair_t>&> &_) { const AlternateSet& as = this+_.second; @@ -49,8 +65,24 @@ struct AlternateSubstFormat1_2 void closure (hb_closure_context_t *c) const { - + hb_zip (this+coverage, alternateSet) - | hb_filter (c->parent_active_glyphs (), hb_first) + auto &cov = this+coverage; + auto &glyph_set = c->parent_active_glyphs (); + + if (alternateSet.len > glyph_set.get_population () * 4) + { + for (auto g : glyph_set) + { + unsigned i = cov.get_coverage (g); + if (i == NOT_COVERED || i >= alternateSet.len) + continue; + (this+alternateSet.arrayZ[i]).closure (c); + } + + return; + } + + + hb_zip (cov, alternateSet) + | hb_filter (glyph_set, hb_first) | hb_map (hb_second) | hb_map (hb_add (this)) | hb_apply ([c] (const AlternateSet &_) { _.closure (c); }) diff --git a/src/OT/Layout/GSUB/LigatureSubstFormat1.hh b/src/OT/Layout/GSUB/LigatureSubstFormat1.hh index 7295bffd9..9b12f1598 100644 --- a/src/OT/Layout/GSUB/LigatureSubstFormat1.hh +++ b/src/OT/Layout/GSUB/LigatureSubstFormat1.hh @@ -45,8 +45,24 @@ struct LigatureSubstFormat1_2 void depend (hb_depend_context_t *c) const { - + hb_zip (this+coverage, ligatureSet) - | hb_filter (c->parent_active_glyphs (), hb_first) + auto &cov = this+coverage; + auto &glyph_set = c->parent_active_glyphs (); + + if (ligatureSet.len > glyph_set.get_population () * 4) + { + for (auto g : glyph_set) + { + unsigned i = cov.get_coverage (g); + if (i == NOT_COVERED || i >= ligatureSet.len) + continue; + (this+ligatureSet.arrayZ[i]).depend (c, g); + } + + return; + } + + + hb_zip (cov, ligatureSet) + | hb_filter (glyph_set, hb_first) | hb_apply ([&] (const hb_pair_t>&> &_) { const LigatureSet& ls = this+_.second; @@ -57,8 +73,24 @@ struct LigatureSubstFormat1_2 void closure (hb_closure_context_t *c) const { - + hb_zip (this+coverage, ligatureSet) - | hb_filter (c->parent_active_glyphs (), hb_first) + auto &cov = this+coverage; + auto &glyph_set = c->parent_active_glyphs (); + + if (ligatureSet.len > glyph_set.get_population () * 4) + { + for (auto g : glyph_set) + { + unsigned i = cov.get_coverage (g); + if (i == NOT_COVERED || i >= ligatureSet.len) + continue; + (this+ligatureSet.arrayZ[i]).closure (c); + } + + return; + } + + + hb_zip (cov, ligatureSet) + | hb_filter (glyph_set, hb_first) | hb_map (hb_second) | hb_map (hb_add (this)) | hb_apply ([c] (const LigatureSet &_) { _.closure (c); }) diff --git a/src/OT/Layout/GSUB/MultipleSubstFormat1.hh b/src/OT/Layout/GSUB/MultipleSubstFormat1.hh index 1f686c92f..1d8082e30 100644 --- a/src/OT/Layout/GSUB/MultipleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/MultipleSubstFormat1.hh @@ -36,8 +36,24 @@ struct MultipleSubstFormat1_2 void closure (hb_closure_context_t *c) const { - + hb_zip (this+coverage, sequence) - | hb_filter (c->parent_active_glyphs (), hb_first) + auto &cov = this+coverage; + auto &glyph_set = c->parent_active_glyphs (); + + if (sequence.len > glyph_set.get_population () * 4) + { + for (auto g : glyph_set) + { + unsigned i = cov.get_coverage (g); + if (i == NOT_COVERED || i >= sequence.len) + continue; + (this+sequence.arrayZ[i]).closure (c); + } + + return; + } + + + hb_zip (cov, sequence) + | hb_filter (glyph_set, hb_first) | hb_map (hb_second) | hb_map (hb_add (this)) | hb_apply ([c] (const Sequence &_) { _.closure (c); }) @@ -46,9 +62,25 @@ struct MultipleSubstFormat1_2 void depend (hb_depend_context_t *c) const { + auto &cov = this+coverage; + auto &glyph_set = c->parent_active_glyphs (); + // Filter by parent_active_glyphs like closure does - + hb_zip (this+coverage, sequence) - | hb_filter (c->parent_active_glyphs (), hb_first) + if (sequence.len > glyph_set.get_population () * 4) + { + for (auto g : glyph_set) + { + unsigned i = cov.get_coverage (g); + if (i == NOT_COVERED || i >= sequence.len) + continue; + (this+sequence.arrayZ[i]).depend (c, g); + } + + return; + } + + + hb_zip (cov, sequence) + | hb_filter (glyph_set, hb_first) | hb_apply ([&] (const hb_pair_t>&> &_) { const Sequence& s = this+_.second; diff --git a/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh b/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh index acf46d12c..b1f1434ab 100644 --- a/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh @@ -132,10 +132,26 @@ struct ReverseChainSingleSubstFormat1_2 hb_codepoint_t saved_context = c->depend_data->current_context_set_index; c->depend_data->current_context_set_index = context_set_idx; - + hb_zip (this+coverage, substitute) - | hb_filter (c->parent_active_glyphs (), hb_first) - | hb_apply ([&] (const hb_codepoint_pair_t &_) { c->depend_data->add_gsub_lookup (_.first, c->lookup_index, _.second); }) - ; + auto &cov = this+coverage; + auto &glyph_set = c->parent_active_glyphs (); + + if (substitute.len > glyph_set.get_population () * 4) + { + for (auto g : glyph_set) + { + unsigned i = cov.get_coverage (g); + if (i == NOT_COVERED || i >= substitute.len) + continue; + c->depend_data->add_gsub_lookup (g, c->lookup_index, substitute.arrayZ[i]); + } + } + else + { + + hb_zip (cov, substitute) + | hb_filter (glyph_set, hb_first) + | hb_apply ([&] (const hb_codepoint_pair_t &_) { c->depend_data->add_gsub_lookup (_.first, c->lookup_index, _.second); }) + ; + } c->depend_data->current_context_set_index = saved_context; } @@ -147,8 +163,24 @@ struct ReverseChainSingleSubstFormat1_2 const auto &lookahead = StructAfter (backtrack); const auto &substitute = StructAfter (lookahead); - + hb_zip (this+coverage, substitute) - | hb_filter (c->parent_active_glyphs (), hb_first) + auto &cov = this+coverage; + auto &glyph_set = c->parent_active_glyphs (); + + if (substitute.len > glyph_set.get_population () * 4) + { + for (auto g : glyph_set) + { + unsigned i = cov.get_coverage (g); + if (i == NOT_COVERED || i >= substitute.len) + continue; + c->output->add (substitute.arrayZ[i]); + } + + return; + } + + + hb_zip (cov, substitute) + | hb_filter (glyph_set, hb_first) | hb_map (hb_second) | hb_sink (c->output) ; diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 99febc159..1bcfc52c3 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -3587,6 +3587,22 @@ struct ContextFormat1_4 nullptr }; + if (ruleSet.len > c->previous_parent_active_glyphs ().get_population () * 4) + { + /* Recursion can reallocate the stack; fetch the set afresh each time. */ + hb_codepoint_t g = HB_SET_VALUE_INVALID; + while (c->previous_parent_active_glyphs ().next (&g)) + { + unsigned i = get_coverage ().get_coverage (g); + if (i == NOT_COVERED || i >= ruleSet.len) + continue; + (this+ruleSet.arrayZ[i]).closure (c, g, lookup_context); + } + + c->pop_cur_done_glyphs (); + return; + } + + hb_zip (this+coverage, hb_range ((unsigned) ruleSet.len)) | hb_filter ([&] (hb_codepoint_t _) { return c->previous_parent_active_glyphs ().has (_); @@ -5230,6 +5246,22 @@ struct ChainContextFormat1_4 {nullptr, nullptr, nullptr} }; + if (ruleSet.len > c->previous_parent_active_glyphs ().get_population () * 4) + { + /* Recursion can reallocate the stack; fetch the set afresh each time. */ + hb_codepoint_t g = HB_SET_VALUE_INVALID; + while (c->previous_parent_active_glyphs ().next (&g)) + { + unsigned i = get_coverage ().get_coverage (g); + if (i == NOT_COVERED || i >= ruleSet.len) + continue; + (this+ruleSet.arrayZ[i]).closure (c, g, lookup_context); + } + + c->pop_cur_done_glyphs (); + return; + } + + hb_zip (this+coverage, hb_range ((unsigned) ruleSet.len)) | hb_filter ([&] (hb_codepoint_t _) { return c->previous_parent_active_glyphs ().has (_); diff --git a/test/api/test-ot-layout.c b/test/api/test-ot-layout.c index 298233ba0..51e094996 100644 --- a/test/api/test-ot-layout.c +++ b/test/api/test-ot-layout.c @@ -380,6 +380,90 @@ test_ot_layout_collect_lookup_variations (void) } #endif +static char * +write_be16 (char *p, unsigned v) +{ + *p++ = (char) (v >> 8); + *p++ = (char) v; + return p; +} + +static void +test_ot_layout_lookups_substitute_closure_large_coverage_one (unsigned lookup_type) +{ + /* Lookup 0 is a ContextSubst covering NUM_GLYPHS glyphs; every rule recurses + * into lookup 1, a MultipleSubst or AlternateSubst covering the same glyphs + * and mapping each to OUT1 and OUT2. Closure visits lookup 1 once per glyph + * with a single active glyph, so the cost of a visit must not scale with the + * size of lookup 1's coverage. */ + enum { NUM_GLYPHS = 16000, OUT1 = NUM_GLYPHS + 1, OUT2 = NUM_GLYPHS + 2 }; + const unsigned context_len = 6 + 2 * NUM_GLYPHS + 4 + 8 + 10; + const unsigned subst_len = 6 + 2 * NUM_GLYPHS + 6 + 10; + const unsigned gsub_len = 10 + 6 + 16 + context_len + subst_len; + char *gsub = g_malloc0 (gsub_len); + char *p = gsub; + unsigned i; + + p = write_be16 (p, 1); p = write_be16 (p, 0); /* version 1.0 */ + p = write_be16 (p, 0); p = write_be16 (p, 0); /* no ScriptList, no FeatureList */ + p = write_be16 (p, 10); /* LookupList */ + + p = write_be16 (p, 2); /* lookupCount */ + p = write_be16 (p, 6); p = write_be16 (p, 14); /* Lookup offsets */ + p = write_be16 (p, 5); p = write_be16 (p, 0); /* ContextSubst, no flags */ + p = write_be16 (p, 1); p = write_be16 (p, 16); /* one subtable */ + p = write_be16 (p, lookup_type); p = write_be16 (p, 0); + p = write_be16 (p, 1); p = write_be16 (p, 8 + context_len); + + /* ContextSubstFormat1: all rule sets share one rule applying lookup 1 at 0. */ + p = write_be16 (p, 1); p = write_be16 (p, context_len - 10); + p = write_be16 (p, NUM_GLYPHS); + for (i = 0; i < NUM_GLYPHS; i++) + p = write_be16 (p, 6 + 2 * NUM_GLYPHS); + p = write_be16 (p, 1); p = write_be16 (p, 4); /* RuleSet */ + p = write_be16 (p, 1); p = write_be16 (p, 1); /* Rule: glyphCount, lookupCount */ + p = write_be16 (p, 0); p = write_be16 (p, 1); /* SequenceLookupRecord */ + p = write_be16 (p, 2); p = write_be16 (p, 1); /* CoverageFormat2, one range */ + p = write_be16 (p, 1); p = write_be16 (p, NUM_GLYPHS); p = write_be16 (p, 0); + + /* MultipleSubstFormat1 / AlternateSubstFormat1: all glyphs share one + * Sequence / AlternateSet. */ + p = write_be16 (p, 1); p = write_be16 (p, subst_len - 10); + p = write_be16 (p, NUM_GLYPHS); + for (i = 0; i < NUM_GLYPHS; i++) + p = write_be16 (p, 6 + 2 * NUM_GLYPHS); + p = write_be16 (p, 2); p = write_be16 (p, OUT1); p = write_be16 (p, OUT2); + p = write_be16 (p, 2); p = write_be16 (p, 1); /* CoverageFormat2, one range */ + p = write_be16 (p, 1); p = write_be16 (p, NUM_GLYPHS); p = write_be16 (p, 0); + + g_assert_cmpuint (p - gsub, ==, gsub_len); + + hb_face_t *face = hb_face_builder_create (); + hb_blob_t *blob = hb_blob_create (gsub, gsub_len, HB_MEMORY_MODE_READONLY, NULL, NULL); + g_assert_true (hb_face_builder_add_table (face, HB_OT_TAG_GSUB, blob)); + hb_blob_destroy (blob); + hb_face_set_glyph_count (face, OUT2 + 1); + + hb_set_t *glyphs = hb_set_create (); + hb_set_add_range (glyphs, 1, NUM_GLYPHS); + hb_ot_layout_lookups_substitute_closure (face, NULL, glyphs); + + g_assert_cmpuint (hb_set_get_population (glyphs), ==, NUM_GLYPHS + 2); + g_assert_true (hb_set_has (glyphs, OUT1)); + g_assert_true (hb_set_has (glyphs, OUT2)); + + hb_set_destroy (glyphs); + hb_face_destroy (face); + g_free (gsub); +} + +static void +test_ot_layout_lookups_substitute_closure_large_coverage (void) +{ + test_ot_layout_lookups_substitute_closure_large_coverage_one (2); /* MultipleSubst */ + test_ot_layout_lookups_substitute_closure_large_coverage_one (3); /* AlternateSubst */ +} + int main (int argc, char **argv) { @@ -399,5 +483,6 @@ main (int argc, char **argv) #ifndef HB_NO_VAR hb_test_add (test_ot_layout_collect_lookup_variations); #endif + hb_test_add (test_ot_layout_lookups_substitute_closure_large_coverage); return hb_test_run (); } From 8b0e9da51ff50fc9bb632121ac0004f73a6a3eea Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 30 Oct 2026 14:54:24 -0600 Subject: [PATCH 17/18] [layout] Collect intersected ClassDef classes once per ContextFormat2 visit The class-based (Chain)Context closure and depend paths called ClassDef::intersects_class() for every rule-set index / class, and each call walks the whole ClassDef, so a subtable with many classes sharing one large ClassDef was quadratic per closure visit (and thus in subsetting). Collect ClassDef::intersected_classes() of the glyph set into a set once per visit and answer the per-class query from that set. All eight call sites across ContextFormat2 and ChainContextFormat2 (closure and depend) use the precomputed set; results are identical. Adds a fuzzer regression font. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-ZCMLEQFJ. Co-Authored-By: Claude Opus 4.8 --- src/hb-ot-layout-gsubgpos.hh | 88 ++++++++++-------- .../gpos-context2-classdef-rescan-timeout.ttf | Bin 0 -> 68460 bytes 2 files changed, 48 insertions(+), 40 deletions(-) create mode 100644 test/fuzzing/fonts/gpos-context2-classdef-rescan-timeout.ttf diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 1bcfc52c3..645b9ea0e 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -1656,19 +1656,11 @@ static inline bool intersects_glyph (const hb_set_t *glyphs, unsigned value, con { return glyphs->has (value); } -static inline bool intersects_class (const hb_set_t *glyphs, unsigned value, const void *data, void *cache) +static inline bool intersects_class (const hb_set_t *glyphs HB_UNUSED, unsigned value, const void *data HB_UNUSED, void *cache) { - const ClassDef &class_def = *reinterpret_cast(data); - hb_map_t *map = (hb_map_t *) cache; - - hb_codepoint_t *cached_v; - if (map->has (value, &cached_v)) - return *cached_v; - - bool v = class_def.intersects_class (glyphs, value); - map->set (value, v); - - return v; + /* ClassDef::intersects_class() walks the whole ClassDef, so callers collect + * ClassDef::intersected_classes() of glyphs into the cache upfront, once. */ + return reinterpret_cast (cache)->has (value); } static inline bool intersects_coverage (const hb_set_t *glyphs, unsigned value, const void *data, void *cache HB_UNUSED) { @@ -3737,7 +3729,8 @@ struct ContextFormat2_5 const ClassDef &class_def = this+classDef; - hb_map_t cache; + hb_set_t cache; + class_def.intersected_classes (glyphs, &cache); struct ContextClosureLookupContext lookup_context = { {intersects_class, nullptr}, ContextFormat::ClassBasedContext, @@ -3757,8 +3750,7 @@ struct ContextFormat2_5 | hb_map (hb_add (this)) | hb_enumerate | hb_map ([&] (const hb_pair_t p) - { return class_def.intersects_class (glyphs, p.first) && - coverage_glyph_classes.has (p.first) && + { return coverage_glyph_classes.has (p.first) && p.second.intersects (glyphs, lookup_context); }) | hb_any ; @@ -3778,7 +3770,8 @@ struct ContextFormat2_5 const ClassDef &class_def = this+classDef; - hb_map_t cache; + hb_set_t cache; + class_def.intersected_classes (c->glyphs, &cache); intersected_class_cache_t intersected_cache; ContextDependLookupContext lookup_context = { {intersects_class, intersected_class_glyphs}, @@ -3788,10 +3781,11 @@ struct ContextFormat2_5 &intersected_cache }; + hb_set_t active_classes; + class_def.intersected_classes (&c->parent_active_glyphs (), &active_classes); + + hb_enumerate (ruleSet) - | hb_filter ([&] (unsigned _) - { return class_def.intersects_class (&c->parent_active_glyphs (), _); }, - hb_first) + | hb_filter (active_classes, hb_first) | hb_apply ([&] (const hb_pair_t&> _) { const RuleSet& rule_set = this+_.second; @@ -3814,7 +3808,8 @@ struct ContextFormat2_5 const ClassDef &class_def = this+classDef; - hb_map_t cache; + hb_set_t cache; + class_def.intersected_classes (c->glyphs, &cache); intersected_class_cache_t intersected_cache; struct ContextClosureLookupContext lookup_context = { {intersects_class, intersected_class_glyphs}, @@ -3824,10 +3819,11 @@ struct ContextFormat2_5 &intersected_cache }; + hb_set_t active_classes; + class_def.intersected_classes (&c->parent_active_glyphs (), &active_classes); + + hb_enumerate (ruleSet) - | hb_filter ([&] (unsigned _) - { return class_def.intersects_class (&c->parent_active_glyphs (), _); }, - hb_first) + | hb_filter (active_classes, hb_first) | hb_apply ([&] (const hb_pair_t&> _) { const RuleSet& rule_set = this+_.second; @@ -3845,7 +3841,8 @@ struct ContextFormat2_5 const ClassDef &class_def = this+classDef; - hb_map_t cache; + hb_set_t cache; + class_def.intersected_classes (c->glyphs, &cache); struct ContextClosureLookupContext lookup_context = { {intersects_class, nullptr}, ContextFormat::ClassBasedContext, @@ -3856,8 +3853,7 @@ struct ContextFormat2_5 + hb_iter (ruleSet) | hb_map (hb_add (this)) | hb_enumerate - | hb_filter ([&] (const hb_pair_t p) - { return class_def.intersects_class (c->glyphs, p.first); }) + | hb_filter (cache, hb_first) | hb_map (hb_second) | hb_apply ([&] (const RuleSet & _) { _.closure_lookups (c, lookup_context); }); @@ -5396,7 +5392,10 @@ struct ChainContextFormat2_5 const ClassDef &input_class_def = this+inputClassDef; const ClassDef &lookahead_class_def = this+lookaheadClassDef; - hb_map_t caches[3] = {}; + hb_set_t caches[3] = {}; + backtrack_class_def.intersected_classes (glyphs, &caches[0]); + input_class_def.intersected_classes (glyphs, &caches[1]); + lookahead_class_def.intersected_classes (glyphs, &caches[2]); struct ChainContextClosureLookupContext lookup_context = { {intersects_class, nullptr}, ContextFormat::ClassBasedContext, @@ -5417,8 +5416,7 @@ struct ChainContextFormat2_5 | hb_map (hb_add (this)) | hb_enumerate | hb_map ([&] (const hb_pair_t p) - { return input_class_def.intersects_class (glyphs, p.first) && - coverage_glyph_classes.has (p.first) && + { return coverage_glyph_classes.has (p.first) && p.second.intersects (glyphs, lookup_context); }) | hb_any ; @@ -5440,7 +5438,10 @@ struct ChainContextFormat2_5 const ClassDef &input_class_def = this+inputClassDef; const ClassDef &lookahead_class_def = this+lookaheadClassDef; - hb_map_t caches[3] = {}; + hb_set_t caches[3] = {}; + backtrack_class_def.intersected_classes (c->glyphs, &caches[0]); + input_class_def.intersected_classes (c->glyphs, &caches[1]); + lookahead_class_def.intersected_classes (c->glyphs, &caches[2]); intersected_class_cache_t intersected_cache; ChainContextDependLookupContext lookup_context = { {intersects_class, intersected_class_glyphs}, @@ -5452,10 +5453,11 @@ struct ChainContextFormat2_5 &intersected_cache }; + hb_set_t active_classes; + input_class_def.intersected_classes (&c->parent_active_glyphs (), &active_classes); + + hb_enumerate (ruleSet) - | hb_filter ([&] (unsigned _) - { return input_class_def.intersects_class (&c->parent_active_glyphs (), _); }, - hb_first) + | hb_filter (active_classes, hb_first) | hb_apply ([&] (const hb_pair_t&> _) { const ChainRuleSet& chainrule_set = this+_.second; @@ -5480,7 +5482,10 @@ struct ChainContextFormat2_5 const ClassDef &input_class_def = this+inputClassDef; const ClassDef &lookahead_class_def = this+lookaheadClassDef; - hb_map_t caches[3] = {}; + hb_set_t caches[3] = {}; + backtrack_class_def.intersected_classes (c->glyphs, &caches[0]); + input_class_def.intersected_classes (c->glyphs, &caches[1]); + lookahead_class_def.intersected_classes (c->glyphs, &caches[2]); intersected_class_cache_t intersected_cache; struct ChainContextClosureLookupContext lookup_context = { {intersects_class, intersected_class_glyphs}, @@ -5492,10 +5497,11 @@ struct ChainContextFormat2_5 &intersected_cache }; + hb_set_t active_classes; + input_class_def.intersected_classes (&c->parent_active_glyphs (), &active_classes); + + hb_enumerate (ruleSet) - | hb_filter ([&] (unsigned _) - { return input_class_def.intersects_class (&c->parent_active_glyphs (), _); }, - hb_first) + | hb_filter (active_classes, hb_first) | hb_apply ([&] (const hb_pair_t&> _) { const ChainRuleSet& chainrule_set = this+_.second; @@ -5515,7 +5521,10 @@ struct ChainContextFormat2_5 const ClassDef &input_class_def = this+inputClassDef; const ClassDef &lookahead_class_def = this+lookaheadClassDef; - hb_map_t caches[3] = {}; + hb_set_t caches[3] = {}; + backtrack_class_def.intersected_classes (c->glyphs, &caches[0]); + input_class_def.intersected_classes (c->glyphs, &caches[1]); + lookahead_class_def.intersected_classes (c->glyphs, &caches[2]); struct ChainContextClosureLookupContext lookup_context = { {intersects_class, nullptr}, ContextFormat::ClassBasedContext, @@ -5528,8 +5537,7 @@ struct ChainContextFormat2_5 + hb_iter (ruleSet) | hb_map (hb_add (this)) | hb_enumerate - | hb_filter([&] (unsigned klass) - { return input_class_def.intersects_class (c->glyphs, klass); }, hb_first) + | hb_filter (caches[1], hb_first) | hb_map (hb_second) | hb_apply ([&] (const ChainRuleSet &_) { _.closure_lookups (c, lookup_context); }) diff --git a/test/fuzzing/fonts/gpos-context2-classdef-rescan-timeout.ttf b/test/fuzzing/fonts/gpos-context2-classdef-rescan-timeout.ttf new file mode 100644 index 0000000000000000000000000000000000000000..6e48fd930007b894a99fb5ef9b1eccd6802940c5 GIT binary patch literal 68460 zcmeGF`8&MzhtLKdjALCAHKghXXbL=@8@~mkMlULKhJTVB6o?1h=||$-PxSHJbnLf zB*GE7OEM}tF_MeY~BKF_)|Ne_JcO}H|lI|Q6xpRfcog<XZXBC;Y6i^z#QA|fyHsEC5dVO7` zGSjlrqH58!e6$!^VOmVBcrC70hE}dtk(N-aR;yX7Q>#~NKxv=y~g zwAHnBv<**MGdlA+OFFAM8#>!Mdpd_YCpzak zSGpp);<{40vbqYo%DQU01YMFYMb|>tPS;u2Lzk`_q#L2j(&gy#bosgh-4fkO-Fn?t z-EQ4J-9g_;xuuNxJX(u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@ zY|S=o%XVzf4(!NI?949g%5Ln=9_-0p?9D#x%YN+70UXFd9Lymc%3&PN5gf@;9L+Ht z%W)jf37q(8%e)jNKkk7V96^DgKu{nk5EKXs1OR{C=e6~3Iqj$0zrYGKu{nk5EKXs1OR{C=e9*Pk~S&VLpA0{&5qpupucw-ot)8KaER$ z`0yV;>@^PIr;hlGTA_@B}LtA9M0`M4%b$`1uUzTnk=pZxDz{%>8FPc#2} Ng@n}nxF96te*kS_zxe Date: Tue, 10 Nov 2026 19:25:00 -0600 Subject: [PATCH 18/18] [cff1] Cache std_code_to_glyph() for seac component lookups (#6562) std_code_to_glyph() resolves a seac component (bchar/achar) with Charset::get_glyph(), a linear scan of the whole charset, and every load of a seac charstring does it twice. The scan is not charged to the glyph work budget, so a COLRv0 glyph whose layers all name one seac glyph costs seconds of CPU while the budget stays almost untouched (the attacker font: 32 s). Charging the scan is not a good fit here: Charset::get_glyph() does not report how far it scanned, so there is no exact cost to charge, and a flat per-lookup charge against the shared subset budget would make large fonts with many accented seac glyphs fail to subset. Instead remove the redundant work: the key space is the 256 StandardEncoding codes, so on first use build a 256-entry code-to-glyph table in one pass over the charset, recording the first glyph carrying each StandardEncoding SID, as get_glyph() does. This fixes all three callers (path, extents and the subsetter's seac closure) with byte-identical output. The table is allocated lazily and installed with cmpexch, like the accelerator's glyph_names, and freed in _fini(): the accelerator grows by one pointer, HB_NULL_POOL_SIZE is unchanged, and nothing is allocated for fonts without seac. On allocation failure the lookup falls back to the scan. Tested by checking the table against get_glyph() on every lookup across the full test suite (temporary assert), and the existing seac tests (draw, extents, subset). Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-FH71HHTD. Co-authored-by: Claude Opus 5.5 --- src/hb-ot-cff1-table.hh | 51 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-cff1-table.hh b/src/hb-ot-cff1-table.hh index f4399dac0..d6aa3d02c 100644 --- a/src/hb-ot-cff1-table.hh +++ b/src/hb-ot-cff1-table.hh @@ -1241,6 +1241,8 @@ struct cff1 topDict.fini (); fontDicts.fini (); privateDicts.fini (); + hb_free (std_code_to_glyph_table.get_relaxed ()); + std_code_to_glyph_table.set_relaxed (nullptr); hb_blob_destroy (blob); blob = nullptr; } @@ -1259,12 +1261,56 @@ struct cff1 return 0; if (charset != &Null (Charset)) - return charset->get_glyph (sid, num_glyphs); + { + /* Charset::get_glyph() is a linear scan of the charset, and seac + * charstrings look their components up on every load. Build a + * code-to-glyph table for the 256 StandardEncoding codes in one + * pass over the charset on first use instead. */ + const uint16_t *table = get_std_code_to_glyph_table (); + if (unlikely (!table)) + return charset->get_glyph (sid, num_glyphs); + return table[code]; + } else if ((topDict.CharsetOffset == ISOAdobeCharset) && (code <= 228 /*zcaron*/)) return sid; return 0; } + private: + const uint16_t *get_std_code_to_glyph_table () const + { + retry: + uint16_t *table = std_code_to_glyph_table.get_acquire (); + if (likely (table)) + return table; + + table = (uint16_t *) hb_calloc (256, sizeof (uint16_t)); + if (unlikely (!table)) + return nullptr; + + /* Record the first glyph carrying each StandardEncoding SID, + * matching Charset::get_glyph(). */ + code_pair_t glyph_to_sid_cache {0, HB_CODEPOINT_INVALID}; + for (hb_codepoint_t glyph = 1; glyph < num_glyphs; glyph++) + { + hb_codepoint_t sid = charset->get_sid (glyph, num_glyphs, &glyph_to_sid_cache); + if (!sid) continue; + hb_codepoint_t code = lookup_standard_encoding_for_code (sid); + if (code && code < 256 && + lookup_standard_encoding_for_sid (code) == sid && + !table[code]) + table[code] = glyph; + } + + if (unlikely (!std_code_to_glyph_table.cmpexch (nullptr, table))) + { + hb_free (table); + goto retry; + } + return table; + } + public: + bool is_predef_encoding () const { return topDict.EncodingOffset <= ExpertEncoding; } hb_codepoint_t glyph_to_code (hb_codepoint_t glyph, @@ -1383,6 +1429,9 @@ struct cff1 unsigned int num_glyphs = 0; unsigned int num_charset_entries = 0; + + private: + mutable hb_atomic_t std_code_to_glyph_table {nullptr}; }; struct accelerator_t : accelerator_templ_t