The lifecycle chapter claimed that all constructors return empty
singletons on failure. Constructors ending in _or_fail instead return
NULL, including the established blob constructors.
Describe both conventions and require checking _or_fail results.
Validated the XML and reproduced the blob constructor behavior with
a nonexistent file and an oversized blob. Documentation only.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6359
Assisted-by: Codex
Early returns for missing extents, empty PDF paint output, or other
render failures retained content despite the automatic-clear contract.
Move clearing to scope guards in the common draw and paint render
entry points, covering every return for SVG and PDF.
Document the failure behavior. Extend the lifecycle regression to
compare subsequent output with fresh contexts for both formats,
including PDF resources and empty PDF paint renders. The regression
fails before the fix. The full Meson suite passes: 290 passed and one
existing test was skipped. The lifecycle test also passes as C99.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6358
Assisted-by: Codex
Paint reset omitted the background and palette, leaving settings from
the previous render despite its documented default-state guarantee.
Reset both fields and document that clear preserves these settings.
Add coverage for clear, reset, and rendering with a recycled image.
The regression fails before the fix. The full Meson suite passes:
290 tests passed and one existing test was skipped.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6356
Assisted-by: Codex
CMake can discover the package through /lib when that directory is a
symlink to /usr/lib. Collapsing the relative prefix lexically then
selects the filesystem root instead of /usr.
Resolve the configuration directory before appending the relative
prefix, without raising the minimum CMake version.
Tested six path layouts, including the failing usr-merged case, spaces,
multiarch, lib64, and symlinked prefixes. The full configured Meson
suite passed: 288 tests.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6278
Assisted-by: OpenAI 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>
* [meson] Skip vector tests when vector is disabled
The vector budget test was built unconditionally even when vector was
explicitly disabled. Its empty dependency supplied neither include paths
nor libraries, breaking otherwise valid reduced-feature builds.
Skip the vector test directory when the library is disabled. Add a Linux
CI build and test pass with vector disabled to cover this configuration.
Reproduced the missing hb.h failure on Linux before the fix. The full
suite with vector, raster, and GPU disabled passed 229 tests with one
skip; all three vector tests passed with vector enabled.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6277
Assisted-by: OpenAI Codex <codex@openai.com>
* [ci] Remove extra vector-disabled build pass
Keep the fix focused on guarding the vector test directory without adding
another build and test pass to the Linux workflow.
CI-only change; the previously validated Meson guard is unchanged.
Assisted-by: OpenAI Codex <codex@openai.com>
* [meson] Guard dependency fuzzers when subset is disabled
With experimental APIs enabled, dependency fuzzers referenced
libharfbuzz_subset even when the subset library was disabled, causing
Meson setup to fail with an unknown-variable error.
Require subset support when building the dependency fuzzers and when
registering their tests.
Full tests with experimental APIs enabled: 92 passed with subset
disabled, and 247 passed with subset enabled. Both dependency fuzzers
and their 13 tests remain registered in the enabled configuration.
Assisted-by: OpenAI Codex <codex@openai.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>