Extend partial-instance default overflow checks to signed coordinates,
unsigned radii, affine values, transform centers, and clip boxes. These
values must remain unbounded while retained axes can still vary them.
Use the constant-region fallback introduced for F2DOT14 fields.
Regressions check default-location painting of a 40000-unit translation,
a negative radial radius, and a 40000 affine coefficient, plus composed
instances with explicit and implicit maps. All 254 configured Meson tests
pass. Skera, HarfBuzz, and FontTools agree on six full-instance COLR tables.
Assisted-by: Codex
An empty coordinate array represents default coordinates, but a region
that ignores every axis still contributes its constant delta there.
Remove the empty-coordinate shortcut in ItemVarStoreInstancer and use
the actual variation store's presence for its boolean conversion.
A regression paints a source constant-alpha font and its partial instance
with implicit and explicit default coordinates. Both must be opaque.
All 254 configured Meson tests pass.
Assisted-by: Codex
Folding a moved default into F2DOT14 can wrap alpha, scale, sweep angles,
or gradient stops before retained axes have applied their deltas. Keep
base fields unchanged and retain constant tuples in COLR's rebased item
variation store when the default does not fit.
Constant regions can also contribute deltas at default coordinates, so
check referenced COLR rows before taking the pinned-at-default shortcut.
Add generated fixtures and regressions for explicit and implicit maps,
changed defaults, constant regions, and composed instancing.
All 254 configured Meson tests pass.
Assisted-by: Codex
Matching lookup lists alone cannot establish that same-tag features are
duplicates. Different feature parameters carry distinct UI metadata, and
alternate features can have different behavior in each language system.
Compare complete supported parameter data before merging, and preserve
indices referenced by retained feature variations. Fully pinned fonts can
still merge features after resolving their alternates.
Add GSUB/GPOS regressions with differing cv01 character arrays, size
values, ss01 names, and ss02 alternatives, plus identical ss03 controls.
The full Meson suite passes, as do reduced-feature compilation checks.
Assisted-by: Codex
Vector reset omitted draw colors, paint background, SVG id prefixes,
and custom palette overrides. Restore these defaults while preserving
configuration across clear.
The PDF draw context also kept its opacity resource dictionary and
counter after clear, including automatic clearing after render.
Clear both with the accumulated output so later documents do not carry
resources from earlier renders.
Add regressions for SVG/PDF reset, configuration preservation, custom
palette overrides, and fresh-context PDF equivalence after explicit
clear, reset, and repeated rendering. All three regression groups fail
against the original implementation.
Tested with meson test -C build: 288 passed, 1 skipped, 0 failed.
The vector suite and the issue reproducer pass. The regression also
compiles and runs as C99 with -Wall -Wextra -Werror.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6342
Assisted-by: OpenAI Codex
Buffer reset has retained message callbacks since their introduction,
although its documentation promised a freshly created buffer state.
Clarify that callbacks, their associated data, and attached user data
survive reset. Document explicit callback removal and destruction.
Add a regression test for callback-directed lookup skipping after
clear/reset, restoration of ligatures after removal, and exactly-once
destruction on replacement, removal, and final buffer destruction.
Tested with meson test -C build: 287 passed, 1 skipped, 0 failed.
The API test also compiles without buffer messages or OT shaping.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6341
Assisted-by: OpenAI Codex
The documentation listed only two retained settings, although
clear_contents also preserves flags, cluster level, invisible and
not-found glyphs, the message callback, and attached user data.
Document these properties and the random-state reset without changing
existing behavior.
Tested with meson test -C build: 287 passed, 1 skipped, 0 failed.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6340
Assisted-by: OpenAI Codex
Adding 0.5 in float can round up before floor sees the value. This
turns the predecessor of 0.5 into 1, and changes sufficiently large
odd integral floats by one. The latter also shifts exactly representable
16.16 axis bounds when the subsetter writes fvar.
Add 0.5 in double to preserve the input's fractional bits while retaining
the existing tie direction toward positive infinity. Exercise half ties,
their neighboring floats, and large positive and negative integers.
Validation: the new regression fails before the fix; the full Meson suite
passes all 282 configured tests after it.
Assisted-by: Codex
* [number] Don't mutate input pointer on failure
Two last tests in test_parse_double used to fail but now don't.
* [number] Deduplicate the logic around fraction
Forming a new abstraction, _hb_fraction, just to consume the fraction part.
Alternate feature serialization lacks the source feature tag, so it
cannot identify and retain cvXX, ssXX, or size parameters. Name-ID
closure also visits only the original base feature, losing labels
referenced by retained alternates or fully instantiated substitutions.
Carry source tags for retained features after deduplication. Collect
name IDs from the current base feature, retained variation records,
and original features used by catch-all records.
Add ordinary, full, partial, and range regressions for all three
parameter formats in GSUB and GPOS. Ten of twelve regression subtests
fail before the fix. The complete Meson suite passes: 284 tests.
The changed layout units also compile with HB_NO_VAR.
Assisted-by: Codex
Replace the blanket VARC instancing rejection with validation of the
axes referenced by retained components, variation regions, and nested
conditions. Remap those indices when unrelated axes are removed, while
keeping passthrough VARC incompatible with instancing.
Preserve component-internal variation data during avar2 instancing by
avoiding culling based on font-level reachable ranges. Add drawing
comparisons and rejection tests with reproducible fixtures, including
hidden component axes and non-default unrelated-axis pins.
Serialize sparse-region axis references using the revised VARC format.
Regenerate the fixtures without changing their logical VARC contents or
other table bytes, apart from the head checksum adjustment.
Validation: meson test -C build (283 passed); subset suite (130 passed);
C++11 compile checks with HB_NO_VAR and HB_NO_VAR_COMPOSITES.
Assisted-by: Codex
Pass the requested minimum CharStrings offset size to the CFF1 INDEX
serializer, matching the CFF2 path. The conversion previously emitted
short offsets even with HB_SUBSET_FLAGS_IFTB_REQUIREMENTS enabled.
Add a Cantarell downgrade regression, registered with the existing
IFTB tests only when experimental API support is enabled. The original
subsetter fails it with and without preprocessing.
Full Meson suites pass with experimental API enabled (282 tests) and
disabled (263 tests, one skipped).
Assisted-by: Codex
Check the real value when identifying zero operands. Converting to an
integer truncates nonzero displacements smaller than one, allowing
h/v specialization to remove them and change glyph geometry.
Add move and line regressions covering positive and negative fractions
on either axis, alongside genuine zero operands. The regression fails
before the fix. The full Meson suite passes: 277 passed, one skipped.
Assisted-by: Codex
IUP adds rebased constant tuples to the plan's cached contour points.
When serialization needs a larger buffer, another gvar serialization
adds the same constants again. The final optimizer then chooses points
against a different outline than the one stored in glyf.
Copy the cached points before IUP instancing so every serialization
attempt starts from the original contour coordinates. Check allocation
failure through the usual vector error path.
Add a shifted-default Roboto Flex regression that fails on the original
subsetter. The entire configured Meson suite passes (278 tests, one
skipped).
Assisted-by: Codex
hlineto and vlineto alternate directions for successive arguments.
Combining commands by their operator alone changes geometry: two
vertical segments become a vertical segment followed by a horizontal
one. Merging a mixed run also needs its argument-count parity.
Require odd parity before combining opposite starting directions and
even parity before combining identical h/v operators.
Test all 1,020 orientation sequences through eight segments at stack
limits 4 and 48, reconstructing every point after specialization. The
original specializer fails that test. Add a shifted Source Serif
instance and update its existing downgrade reference. The entire
configured Meson suite passes (277 tests, one skipped).
Assisted-by: Codex
The IUP optimizer returns success for contours larger than its 512-bit
sets can represent, leaving every optimized reference false. The
resulting partial instance loses the contour's variation data.
Keep all explicit references when skipping optimization at that limit.
This preserves the existing bounded search without changing geometry.
Add a 600-point contour regression. The original subsetter fails both
normal and preprocessed checks. The entire configured Meson suite
passes (278 tests, one skipped).
Assisted-by: Codex
Variation deltas can take solid and gradient stop alpha outside [0, 1].
Narrowing those values to F2DOT14 before clamping wraps alpha 2 to -2
and alpha -3 to 1, reversing the intended opacity.
Clamp full instances in float before storing alpha. Keep partial bases
unclamped because surviving axes can bring them back into range.
Add synthetic solid and gradient regressions for overflow, underflow,
and a partial base of 1.5 reduced to 0.5 by the retained axis. The old
subsetter fails four full-instance checks; the entire configured Meson
suite passes (278 tests, one skipped).
Assisted-by: Codex
There is one known difference before and after the change that comes
from 32bit/64bit machines difference on long size which is documented
in the tests.
Previously it was changing value's pointer even if the parsing
was declarad a failure, this fixes it by changing the value
only if the parsing was successful.
Once the project was avoiding STL and everything related at all cost
but now use of std:: provided things exists on the project despite
still no runtime dependency to STL (which is fantastic) and
since this in tests and even this doesn't pull STL, use of std::
should be okay to resolve the issue some of the CI bots have with
accessing signbit and isinf (unlike my local machine which is ok).
m.set (99, m.get (1)) passes a reference into the map's own items
array. If the insertion needs to grow the table, alloc() frees that
array before the value is read, so set_with_hash() copies from freed
memory. Same for the key, eg. m.set (m.get (1), v).
When growth is needed and the key or value lies within our storage,
copy them out first and insert the copies. The copies are
default-constructed and then assigned, matching how items are filled,
since some key types (eg. OT::OffsetTo) are not copy-constructible.
Added test-map cases for value and key aliasing, including a
non-trivial value type. Reproduced with ASan before the fix; test-map
is clean under ASan+UBSan after it, and meson test passes.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Adding a sorted array to an inverted set delegates to the underlying deletion path, but set_sorted_array() always added bits. Excluded members stayed excluded, and existing included members could become excluded.
Use the requested bit value, as set_array() already does. The regression covers duplicates, excluded and included members, and both existing and absent pages.
Assisted-by: OpenAI Codex
Copy assignment resets the destination before reading the source. When
they are the same vector, this also clears the source. In particular,
hb_set_set(set, set) loses the set's stored pages.
Return immediately for self assignment. Cover trivial and nontrivial
vector elements and public set assignment in both inversion modes.
Validation: both regressions fail before the fix; meson test -C build
passes (261 passed, 1 skipped).
Assisted-by: OpenAI Codex
Deleting the last member of a page leaves an empty page in the sparse set. `hb_bit_page_t::get_max()` returned zero for that page, so reverse iteration could report a value that was never in the set. For example, add and delete 512, then iterate backward from 1024: HarfBuzz reported 512 from an empty set.
Return INVALID for an empty page, matching get_min(), so previous() skips it. Cover reverse scalar/range iteration with retained empty pages, including inverted sets.
Assisted-by: OpenAI Codex
The mixed-inversion equality path compares zipped iterators, which stop
at the shorter set. An empty set therefore compares equal to a full
inverted set, as does any matching finite prefix.
Check populations before comparing members and add regression coverage
for empty sets and matching prefixes in both argument orders.
Validation: meson test -C build (261 passed, 1 skipped).
Assisted-by: OpenAI Codex
When the cursor's page is absent, bfind selects the next stored page.
Using the cursor's offset in that different page can skip its members,
or skip the entire page when the cursor ends on a page boundary.
Apply the cursor offset only when the selected page matches its major
index. Cover batch and scalar iterator agreement across missing pages
for both ordinary and inverted sets.
Validation: the new regression fails before the fix; meson test -C build
passes (261 passed, 1 skipped).
Assisted-by: OpenAI Codex
* [machinery] Don't cache the Null object in face accelerator loaders
When libharfbuzz and libharfbuzz-subset (or raster, vector, gpu,
cairo) are separate shared libraries, each has its own hidden
_hb_NullPool. If an accelerator's allocation failed, the lazy loader
stored the calling library's Null object in the face. When the face
was later destroyed from the other library, do_destroy () did not
recognize that Null object and ran the destructor on read-only
memory.
hb_face_lazy_loader_t's create () only fails on allocation failure,
so stop storing get_null () there and retry on next access instead.
A stored instance is now always a real object. Other loaders, whose
get_null () is a shared static default, keep caching it. The
success path and get_relaxed () are unchanged.
Since a failed load no longer leaves anything behind for
get_relaxed (), the subsetter, which runs closure_lookups () on its
own GSUB/GPOS blob and recurses through the face accelerator with
get_relaxed (), now forces the accelerator to load through the public
hb_ot_layout_has_substitution/positioning () and fails the plan if
it is missing. Calling get () from libharfbuzz-subset is not an
option since the accelerator constructor uses a hidden symbol.
Testing: the six hb-subset-fuzzer crashes against a shared-library
ASan build (write to _hb_NullPool in hb_ot_face_t::fini ()) no
longer reproduce. A deterministic regression test is not practical
since it needs a specific allocation to fail in a process using two
of the shared libraries. meson test: 261 passed, 1 skipped.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6324
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* [machinery] Cache failed face accelerators as a tagged Null pointer
The previous commit stopped caching the Null object when a face
accelerator failed to allocate. That made repeated accesses to the
same accelerator inconsistent under OOM: a failed get () returned
Null and a later one could retry and succeed. CIFuzz found the
subset driver taking its table from one access and its blob from the
next, then subsetting with the Null CFF1 accelerator (null fdSelect).
Many places access an accelerator more than once, so fixing callers
one at a time is not viable.
Revert that, and the subsetter guard it needed, and instead cache the
failure as get_null () with its low bit set. get_stored () and
get_stored_relaxed () mask the bit off, so every access keeps seeing
the same object, and do_destroy () skips tagged pointers by the bit
rather than by comparing against this library's Null address. That
comparison is what failed when libharfbuzz and libharfbuzz-subset
(or raster, vector, gpu, cairo) are separate shared libraries, each
with its own _hb_NullPool.
Only hb_face_lazy_loader_t opts in; other loaders compile as before.
A loader instance must stay one pointer in size, so the flag is
carried in the pointer rather than a separate member. The tagged
pointer only ever refers to the static Null object, never to heap
memory.
Testing: the CIFuzz testcase no longer reproduces (static and shared
ASan builds), nor do the six shared-build hb-subset-fuzzer crashes.
meson test: 261 passed, 1 skipped.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6324
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
ff9183045f commented out the unused GET_METRIC_X in
_hb_ot_metrics_get_position_common () to silence -Wunused-macros,
but the trailing backslashes on the // lines then triggered gcc's
-Wcomment. Delete the dead macro and its matching #undef instead.
meson test: 261 passed, 1 skipped; no warnings from hb-ot-metrics.cc
with -Wunused-macros.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Resolve condition-evaluation conflicts while preserving the layout
instancing fixes and main's double-precision and static VARC support.
Tests: full Meson suite (279 passed), and C++11 syntax checks with
HB_NO_VAR, HB_NO_SUBSET_LAYOUT, and HB_OPTIMIZE_SIZE.
Assisted-by: OpenAI Codex <codex@openai.com>
Adding a fractional pinned delta to a large condition default in float
loses its low bits. A scaled 32-bit bias also loses bits when stored in
float tuples, and float variation-store accumulation can erase small
residuals when large deltas cancel.
Use double accumulation for layout condition evaluation and instancing,
keeping ordinary positioning and region-scalar arithmetic unchanged.
Split large biases into float-exact parts, which integer row assembly
combines before serializing a single neutral-region delta.
Add large-default fractional fixtures for GSUB and GPOS, with both
legacy and additive feature variations. Test a positive 1/12288 residual
at cancellation, partial and repeated instancing, and direct evaluation
of 32-bit variation deltas outside float's exact integer range.
Tests: full Meson suite (279 passed), sanitized item-varstore tests,
C++11 reduced-feature checks, and sanitized allocation sweeps over the
new fixtures (2334 full-font attempts and 21 row-encoder attempts).
Assisted-by: OpenAI Codex <codex@openai.com>
The PairPos allocation sweep exposed a pre-existing serializer assertion.
A failed class-map allocation supplies invalid class indices, which are
then reported as integer overflow. Continuing with that recoverable error
can unbalance nested serializer objects before a snapshot rollback.
Propagate class-map allocation errors before remapping or serializing
indices. Also propagate failure to collect PairPos format-2 columns so
an empty vector cannot silently omit the positioning matrix.
Add a failed-map regression. Tested with the full Meson suite (279
passed), C++11 reduced-feature checks, and Address/UndefinedBehavior/
LeakSanitizer allocation sweeps over the new fixtures (2334 attempts).
Assisted-by: OpenAI Codex <codex@openai.com>
Several tuples can contribute to one region column. Select long-word
encoding from the accumulated cell and reject signed 32-bit overflow
instead of overflowing the addition.
Check row-vector and deduplication-map errors before testing whether
any rows remain. Otherwise a failed first row allocation looks like
an empty subtable and its error can be cleared on the next iteration.
Add accumulated-width and overflow tests. A sanitizer allocation sweep
reproduces the silent success before the fix and rejects every failed
allocation in the one-row encoder afterward (21 attempts).
Tests: full Meson suite (279 passed), sanitized item-varstore tests,
and the row-encoder allocation sweep.
Assisted-by: OpenAI Codex <codex@openai.com>
GSUB conditions need GDEF's remapped indices and precise condition
values, just as GPOS does. With avar2, GDEF waits for avar, allowing
GSUB to run first unless its dependency is explicit.
Add GSUB to the GDEF dependency and generate identity-avar2 fixtures
for legacy and additive feature variations in both layout tables.
The regressions compare shaping after partial and repeated instancing.
Tests: full Meson suite (279 passed).
Assisted-by: OpenAI Codex <codex@openai.com>