Use Skrifa's bitmap-strike API to provide glyph extents and paint PNG
and BGRA images from CBDT and sbix tables. Select strikes using the
font's requested ppem and preserve the OT backend's table precedence.
Keep the face blob alive through image blobs retained by paint
callbacks.
Tests: meson test -C build --no-rebuild
Assisted-by: OpenAI Codex <codex@openai.com>
Skrifa exposes resolved COLRv1 clip boxes independently of outline
glyph metrics. Use them when present so glyph extents report the clip
bounds instead of falling back to painted-content bounds.
Keep the existing paint fallback for color glyphs without a clip box.
Assisted-by: OpenAI Codex <codex@openai.com>
The RuleSet fast paths filtered out rules requiring another glyph when
the skipping iterator reached the end of the buffer. Unlike the normal
rule walk, that early return did not record the resulting
unsafe-to-concat range.
Keep the end-of-input optimization, but track filtered rules and mark
their concat hazard before returning. Cover both contextual and chained
contextual rule sets with a five-rule font that forces the fast paths.
Assisted-by: OpenAI Codex <codex@openai.com>
A zero-valued PairPos record can select a different, non-zero record
if the second glyph changes, so keep the pair unsafe to concat even
when no positioning was applied.
Likewise, make the ligature second-glyph digest rejection report the
same hazard as the full ligature walk.
Tests: meson test -C build
Port of https://github.com/harfbuzz/harfrust/pull/465
Assisted-by: OpenAI Codex <codex@openai.com>
Build a compact class digest for every format-2 contextual RuleSet in
the subtable's existing external cache. Reject a RuleSet before walking
its rules when the next input glyph cannot match any rule's first class.
Rules without another input position force the digest open. Digest
collisions only cause the normal rule walk, and allocation failure falls
back to the uncached path.
Assisted-by: Codex <codex@openai.com>
U+180F MONGOLIAN FREE VARIATION SELECTOR FOUR was added in Unicode
14.0 and has Default_Ignorable_Code_Point=Yes, but
is_default_ignorable() only covered U+180B..180E, so FVS4 was never
hidden and leaked a .notdef into the output.
8c65442069 ("[Unicode 14] Handle U+180F FVS4") added the U+180F case
to _hb_glyph_info_set_unicode_props() and to the Arabic shaper, but
that branch sits inside "if (unicode->is_default_ignorable (u))", so
it has been unreachable since it was written. Extending the range to
U+180B..180F makes it live.
U+180B..180F are all Default_Ignorable_Code_Point per
DerivedCoreProperties.txt, so the range stays contiguous.
Before, with a font with no Mongolian coverage:
$ hb-shape Roboto-Regular.abc.ttf -u U+0061,U+180F
[1=0+1114|0=0@-908,0+0]
Every other default ignorable (U+180B..180E, U+FE00, U+200B) on that
font shapes to [1=0+1114]. After the change U+180F matches them.
Added two cases to mongolian-variation-selector.tests, which already
covered FVS1, FVS2, FVS3 and MVS but not FVS4: U+180F, and U+1810
MONGOLIAN DIGIT ZERO to pin the top of the range so it cannot be
widened by accident.
Tested with "meson test -C build": 254/254 OK, 0 failures. Restoring
the old U+180B..180E fails in-house 6174/6176, and widening it to
U+180B..1810 fails the same way.
Assisted-by: claude-opus-5
Co-authored-by: Dylan Pulver <dylanpulver@users.noreply.github.com>
Error handling in repacker is in rough shape. Many of the methods are fallible, but often the return values aren't being checked for error state.
To help address this I thought it might be useful to introduce a result type similar to Result<> in rust (or std::expected) that would force callers to deal with errors in the returns.
This PR introduces hb_result_t<OkVal, ErrVal>.
Assisted by: Gemini
FreeType requires face creation and destruction on a shared
FT_Library to be serialized. Protect the lazily-created static library,
its reference count, and its internally-owned faces with a lazy mutex.
Keep caller-owned FT_Library instances outside the new lock, and add a
multithreaded regression test for blob-backed faces and font funcs.
Tests: meson test -C build (272/272 passed)
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6224
Assisted-by: OpenAI Codex <codex@openai.com>
context_depend_lookup and chain_context_depend_lookup build the
input-position glyph sets with for (i = 0; i < inputCount - 1; i++),
so a Rule with inputCount 0 (what a null rule offset resolves to)
underflows the bound to UINT_MAX and reads past the object into the
Null pool. Rewrite both loops as i + 1 < inputCount, matching the
guarded inputCount handling used everywhere else in the file. Reached
from hb_subset_depend_from_face_or_fail on a crafted GSUB context
rule; seed added under test/fuzzing/fonts.
The Win1256 fallback is a static GSUB recipe selected by a narrow glyph-ID
signature; it does not call a Windows API. Enable it outside Windows too,
while retaining HB_NO_WIN1256 as an explicit opt-out.
Tested: meson test -C build; build with -DHB_NO_WIN1256
Assisted-by: Codex <codex@openai.com>
The HarfRust Arabic fallback cache now supports no-std builds. Emit the
presentation-form and ligature data without a std feature gate so the
generated Rust table is available there as well. The C++ output is unchanged.
Tested: meson test -C build
Assisted-by: Codex <codex@openai.com>
hb_bit_page_t::add_range and del_range compute la = &elt(a) and
lb = &elt(b) and memset the span between them. When a and b map to
element indices out of order within the page (la > lb), the pointer
difference (char *) lb - (char *) la goes negative and wraps to a
huge size_t, so the memset writes past the page.
Only run the multi-element branch when la < lb, and otherwise leave
the page untouched. The single-element (la == lb) branch is already
memory-safe. This defends the page code itself in addition to the
inputCount cap on the depend path.
Extend the Arabic table and PUA generators to emit the data needed by
HarfRust's fallback shaper. Require explicit PUA input paths so regeneration
does not depend on the current working directory, and pass them from the
HarfBuzz update makefile.
The generated C table payload remains byte-for-byte unchanged; its invocation
comment now records the required inputs. The Rust output passes HarfRust's full
workspace tests, no-std check, formatting, and strict clippy; the full
HarfBuzz Meson suite also passes.
Assisted-by: Codex <codex@openai.com>
context_depend_recurse_lookups tracks covered sequence positions in
a fixed hb_bit_page_t, but the dependency-graph path never bounded
inputCount the way the shaping apply path does. A crafted GSUB
contextual rule with glyphCount past the page (e.g. 512) and a
SubstLookupRecord whose sequenceIndex lands in a higher page element
than endIndex makes hb_bit_page_t::add_range compute its memset
length as (char*)lb - (char*)la, which is negative and wraps to a
huge size_t, writing past the stack-allocated page. Reachable from
hb_subset_depend_from_face_or_fail on a crafted face.
Cap inputCount at HB_MAX_CONTEXT_LENGTH before the page is used,
matching the apply path; rules longer than that never apply during
shaping, so no real dependency edges are lost. Adds a regression
seed exercised by the depend fuzzer.