mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 14:31:10 +01:00
* [test] Force the ot shaper in the layout budget tests
test_ot_layout_gpos_mark_base_rescan_budget calls hb_shape() with no
shaper forced, then asserts an OT-specific max_ops trip via
hb_buffer_allocation_successful(). Under the HarfRust shaper
(HB_SHAPER_LIST=harfrust, as the rust CI job re-runs the api suite)
it aborts, because harfrust shapes independently and never reaches
the C-side max_ops paths it tests.
Shape with hb_shape_full(..., {"ot", NULL}) so it exercises the OT
shaper regardless of the configured shaper list, as
test_shape_lookup_budget already does.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [layout] Charge the skip, skipped-record and ligature walks
The per-pass `len / 16` charge does not bound per-position inner work:
the skipping iterator's rescans over default-ignorables, apply_lookup's
walk over a rule's skipped LookupRecords, and match_input /
ligate_input's walk over a ligature's components and marks. Each is a
CPU-DoS a crafted font triggers under the default max_ops.
Charge each on its work path only, so honest shaping is unaffected:
skipping_iterator_t::next/prev charge one op per skip (a first-try
match charges nothing); apply_lookup charges each skipped record;
match_input charges the ligbase backward walk and ligate_input the
mark re-adjust walk, once each.
Reproducers drop from 20 s / 6.8 s / 3.8 s to 0.05 s / 0.003 s /
0.02 s; in-house and aots shaping tests pass with no output change
(the pre-existing text-rendering-tests failures are unchanged).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [layout] Stop matching once the skip/walk budget is spent
The previous commit charged the walks, but the skipping iterator's skip
arm only decremented max_ops; within one pass a tiny aliased font could
still re-run a walk per candidate, per rule or per subtable without bound
(dfrg's harfrust #604 review found the same gaps here).
Flag the buffer unsuccessful when the skip arm spends the budget -- it
still never early-returns, so *unsafe_to stays set for the kern machine --
and stop the loops that repeat walks once it clears: apply_backward,
Ligature::apply, the reverse-chain and mark-base/lig subtable applies,
and context_apply_lookup / chain_context_apply_lookup. apply_forward
already checks successful.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [layout] Enforce the budget in the shared subtable loop
dfrg's re-review (harfrust #604): the per-kind entry guards miss paths
that scan before reaching them -- context format 3, the context/ligature
pre-match scans, cursive and mark-to-mark -- so a lookup aliasing thousands
of subtables restarts a buffer scan at each one. Guard the shared
accelerator apply instead (hb_applicable_t::apply), and drop the
now-redundant reverse-chain and mark-base/lig entry guards it subsumes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>