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
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
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
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
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>
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>
Instancing can add base fields absent from the source value format.
Matching the original format after an early PairSet or class row is
therefore no longer an upper bound on the effective output format.
Disable the early exit when a variation-delta map is supplied. Add
regressions for both PairPos formats and both value records, with a
zero pinned delta in the first row and a nonzero delta in a later row.
Tests: full Meson suite (279 passed), including the new regressions.
Assisted-by: OpenAI Codex <codex@openai.com>
Overlapping bounding ranges do not imply that strided input and output
slots overlap. For equal strides, check field separation modulo the
stride, including the gap across record boundaries. Share this check
between advances and vertical origins.
Cover interleaved glyph/position records and hb-ot-normalize's mapping
from codepoint to var1.u32 within the same glyph-info array.
Tests: full Meson suite (281 passed, 1 skipped), using opt-level=0 for
Clippy's nightly compiler workaround. An exhaustive standalone check
covered 3,136,320 stride/offset/count layouts. Seven-run medians for
interleaved Roboto improved 2.64x for horizontal advances, 22.77x for
vertical advances, and 1.77x for vertical origins.
Assisted-by: OpenAI Codex
Register the vertical-origins batch callback. Compute X using HarfBuzz's
batched horizontal advances, then compute Y with v_origin_y_batched.
Retain HarfBuzz line and glyph-extents callbacks for fallback behavior.
Preserve scalar write order for aliased inputs, overlapping outputs, and
repeated X slots while batching normal interleaved position buffers.
Add default/varied glyf, CFF, and CFF2 coverage with strided, unaligned,
in-place, repeated, invalid-glyph, and zero-count queries.
Tests: full Meson suite (281 passed, 1 skipped); font-only Clippy; unchanged
144-case metric snapshots. Another 48 full-font batch cases (53,622 glyph
origins) matched the old scalar implementation. Clippy used opt-level=0
for the nightly compiler workaround.
Seven-run origin medians improved about 19% overall, about 36-38% for
unvaried glyf fonts; varied glyf and CFF/CFF2 remain dominated by extents.
Assisted-by: OpenAI Codex
Replace safe pointer helpers that manufactured static mutable references
with explicit unsafe reads/writes and a callback-scoped output iterator.
Compute byte offsets in pointer width. Preserve direct batch writes for
aligned, disjoint buffers; use stack outputs for unaligned, repeated, or
overlapping slots without allocating or creating aliased references.
Add unaligned nominal/advance, padding, repeated output, and in-place
advance coverage. Tests: full Meson suite (281 passed, 1 skipped), font-only
Clippy, and unchanged 144-case metric snapshots. Clippy used opt-level=0
for the nightly compiler workaround.
Seven-run medians across 36 nominal/horizontal/vertical advance cases,
compared again with the saved old library on one CPU, showed no slowdown:
nominal about 6% faster, horizontal unchanged, vertical about 36% faster.
Assisted-by: OpenAI Codex
Font serial changes include scale changes, which need not discard the
read-fonts instance's variation and metrics caches. Compare normalized
coordinates using the builder's padding, truncation, and default-location
rules, and rebuild only when the effective coordinates change.
Test scale changes, zero coordinates, omitted axes, extra axes, and resets
against fresh Fontations instances. Preserve existing rounding behavior.
Tests: full Meson suite (281 passed, 1 skipped); 144 font/scale/location
snapshots matched the previous implementation. Clippy used opt-level=0
for the nightly compiler workaround.
Assisted-by: OpenAI Codex
Concurrent readers could replace and destroy a face's reverse-name map
while another reader was using it. Publish with replace=false, reclaim
losing maps, and retrieve the winner. Return failure if publication fails
without a winner instead of retrying indefinitely on allocation failure.
Add a concurrent initialization regression that fails before the fix.
Tests: full Meson suite (281 passed, 1 skipped). Clippy used opt-level=0
to avoid a nightly compiler timeout; library compilation remained opt=3.
Assisted-by: OpenAI Codex
Move character mapping, line and glyph metrics, vertical origins, and
glyph names to the new Font model. Use its batched advance APIs while
preserving horizontal rounding and HarfBuzz fallback callbacks.
Share the blob owner with the shaper and remove the metrics lifetime
transmute. Enable two existing vertical variation regressions for
Fontations and add strided batch advance coverage.
Tests: ninja -C build lib; meson test -C build (281 passed, 1 skipped).
Font-only and shape-only cargo checks also passed; the shape-only check
used CARGO_INCREMENTAL=0 after a nightly compiler crash.
Assisted-by: OpenAI Codex
The dense DefaultUVS copy path merged adjacent source ranges without
respecting additionalCount's 8-bit limit. Subsetting 257 consecutive
default UVS mappings could leave only one mapping after count truncation.
Start a new range before the additional count overflows. Exercise cmap
formats 14 and 15 at 1, 255, 256, 257, 512, 513, and 768 mappings, checking
both the retained mapping count and the last variation glyph.
Built with C++11 and ran the complete Meson suite: 279 passed.
Assisted-by: OpenAI Codex
* [VARC] Apply constant deltas in static fonts
Static VARC fonts have no fvar coordinates, but sparse regions without
active axes still contribute constant deltas. Empty coordinate guards
were skipping those deltas in conditions, transforms, and axis values.
Supply an implicit zero coordinate for VARC variation-store evaluation
and remove its coordinate-presence guards. Keep inherited component
coordinates and the shared variation-store evaluators unchanged.
Add a generated static font and drawing/extents regression covering all
three consumers, with both constant and default-inactive regions.
Tests: meson test -C build (281 passed, 1 skipped); C++11 syntax checks
with default, HB_NO_VAR, and HB_OPTIMIZE_SIZE configurations.
Assisted-by: OpenAI Codex <codex@openai.com>
* [VARC] Allow empty coordinates in the multi-item instancer
The region evaluators already treat missing coordinates as zero.
MultiItemVarStoreInstancer is used only by VARC, so remove its
coordinate-presence checks instead of supplying a dummy coordinate
from the VARC caller.
Document why empty coordinates must allow constant VARC deltas, and
the ordinary instancer's existing empty-coordinate shortcut. Leave
ordinary instancer behavior unchanged.
Tests: meson test -C build (281 passed, 1 skipped); C++11 syntax checks
with default, HB_NO_VAR, and HB_OPTIMIZE_SIZE configurations.
Assisted-by: OpenAI Codex <codex@openai.com>
Packed VARC deltas can use the full signed 32-bit range. Converting
them to float before scaling and accumulation loses small residuals
when large contributions cancel, affecting conditions, transforms,
and component axis values.
Accumulate MultiItemVariationStore deltas in double and keep condition
and axis values at that precision until comparison or rounding. Leave
region scalars, drawing transforms, and ordinary variation stores
unchanged.
Add a generated regression font covering all three consumers.
Tests: meson test -C build (281 passed, 1 skipped); C++11 syntax checks
with default, HB_NO_VAR, and HB_OPTIMIZE_SIZE configurations.
Assisted-by: OpenAI Codex <codex@openai.com>
Partial instancing rounds the default and surviving deltas of format-2
layout conditions independently, moving their Boolean boundary and
changing GSUB or GPOS lookup selection.
Rescale variable conditions into private variation-store rows before
integer encoding, leaving shared positioning values unchanged. Prefer
exact integers; otherwise use the available signed 32-bit precision.
Carry defaults outside int16 in a neutral variation region.
Keep source values separate from output mappings so serialization retries
start with the original condition, and make private-row order independent
of source addresses. Propagate store-instancing failures to the serializer.
Add legacy and additive feature-variation fixtures covering nested
conditions, fractional coefficients, large defaults, shared positioning
rows, and a second instancing pass.
Tested: full Meson suite with and without experimental API (279 passed;
261 passed and 1 skipped respectively), C++11 reduced-feature syntax
checks, and C++11 sanitizer builds with failing allocation checks.
Assisted-by: OpenAI Codex <codex@openai.com>
Use a uint32 sparse-region count, region-relative Offset32 axis
references, and an Offset32 reference to the delta-set INDEX. Update
evaluation, sanitization, and subset serialization together.
Migrate all seven affected fixtures. Their logical VARC contents and
non-VARC table bytes are unchanged apart from head checksum adjustment.
Tests: full Meson suite (277 passed), C++11 amalgamation compilation,
and compilation with HB_NO_VAR and HB_NO_BORING_EXPANSION.
Spec: https://github.com/harfbuzz/boring-expansion-spec/pull/175
Offset-base erratum: https://github.com/harfbuzz/boring-expansion-spec/issues/177
Assisted-by: OpenAI Codex
Delete the remaining dead assertions for the old beyond-64K hmtx
extension, along with their stale adaptation comment. The current
specification uses separate capital-letter tables.
Leave the active legacy-table assertions and fixture unchanged.
Testing: full Meson suite: 281 passed, one skipped.
Assisted-by: OpenAI Codex <codex@openai.com>
Partial instancing used the rounded positioning delta to fold format-2
conditions. A positive fraction could round to zero and lose a lookup.
Evaluate the original GDEF store at the pinned/default coordinates when
the projected variation index becomes NO_VARIATION_INDEX instead.
Keep integer rounding for conditions with remaining variation and for
ordinary positioning values. The new helper is internal-only.
Extend the legacy condition grid and add an additive lookup regression
using existing fonts. The full Meson suite passes (281 tests, one skip),
including shape and subset suites. All 32 cross-library full/partial
GSUB/GPOS instancing diagnostics preserve the original shaping.
Assisted-by: OpenAI Codex <codex@openai.com>
OFF permits CFF2 CharStrings to omit a tail of glyphs provided by
VARC. Accept this count mismatch only when VARC is present, and
validate FDSelect against both the CharStrings and font glyph counts.
Reject malformed explicit FDSelect tables instead of using FD zero.
Add draw and count-mismatch regressions, plus FDSelect format 3 and 4
sentinel checks. The full Meson suite passes: 281 passed, 1 skipped.
C++11 syntax checks pass with extended and reduced features.
Assisted-by: OpenAI Codex <noreply@openai.com>
A satisfied condition set becomes universal when all its conditions are
dropped, even if no remaining condition requested retention. Mark that
record universal and retain it while other axes remain, preventing
later records and an obsolete default catch-all from changing behavior.
Serialize reduced unconditional records with a null ConditionSet.
Regress GSUB and GPOS together, with an earlier conditional record and
LookupVariationRecord ADD_DEFAULT_LOOKUPS interaction. Regenerate the
existing instance goldens for the unconditional-record representation.
Testing: full Meson suite, 281 passed and one expected skip.
Assisted-by: OpenAI Codex <noreply@openai.com>
Legacy FeatureVariationRecords forced non-axis conditions to false when
choosing the new default features. Their empty range maps also compared
equal, discarding distinct conditional records during partial instancing.
Evaluate value and boolean conditions against the original GDEF store
at the new default, classify their surviving ranges conservatively, and
avoid range-only deduplication for complex conditions. Reuse the lookup
condition serializer to fold pinned axes and remap variation indices.
Materialize a false condition rather than emitting a null (true) offset.
Remove the unused condition-subset TODO stubs.
Add GSUB/GPOS coverage with 75 full/partial-instancing comparisons of
glyph selection and advances, covering formats 2-5 and null children.
Testing: meson test -C build (281 passed, 1 skipped); C++11 reduced-
feature syntax checks with HB_NO_VAR, HB_NO_BEYOND_64K, HB_NO_CUBIC_GLYF.
Assisted-by: OpenAI Codex <noreply@openai.com>
Starting every contour at its last point rotates all-off-curve cubic
controls by one point, changing the implied curves. Preserve their
original order instead. Reset the second leading control between
contours, and draw a two-control contour as a cubic, not a point.
Add regressions using current MAXP, GLYF, LOCA, HHEA, and HMTX tables
for all-off-curve contours, consecutive contours, and two controls.
Testing: meson test -C build (281 passed, 1 skipped).
Assisted-by: OpenAI Codex <noreply@openai.com>
The disabled checks reflect an abandoned beyond-64k proposal that
derived the glyph count from loca. Remove them while retaining the
active maxp compatibility and fallback tests.
Testing: meson test -C build (281 passed, 1 skipped).
Assisted-by: OpenAI Codex <noreply@openai.com>
Extend the lookup-variation fixture with a GDEF ItemVariationStore-backed
ConditionValue and a GPOS conditional positioning lookup. This covers
variation-index evaluation, GPOS shaping, and lookup collection while
reusing the existing partial-instancing checks.
Tested with the full Meson suite and OTS validation of the fixture.
Assisted-by: OpenAI Codex <codex@openai.com>
* [raster] Fix background color premultiplication and stride handling
ensure_initialized()'s background fill had two bugs:
1. The background pixel was built with HB_COLOR(blue, green, red,
alpha), which packs channels through HB_TAG's bit layout
(b<<24 | g<<16 | r<<8 | a). Every other pixel in this buffer is
premultiplied BGRA32 (b | g<<8 | r<<16 | a<<24, see hb-raster.hh's
SRC_OVER comment: "premultiplied src over premultiplied dst"), so
the background was both unpremultiplied and in the wrong byte
positions: a half-transparent red background (blue=0, green=0,
red=255, alpha=128) filled the buffer with 0x0000ff80 instead of
the correct premultiplied 0x80800000.
2. The fill then wrote that pixel into a contiguous run of
width * height uint32_t slots starting at the buffer origin,
assuming every row is packed at exactly width * 4 bytes. Once a
caller sets a stride wider than that (row padding, alignment,
embedding the glyph image inside a larger atlas), the fill drifts
across row boundaries after the first row, leaving later rows
partially uninitialized or wrongly colored.
Build bg with color_to_premul_pixel(), the same helper solid fills
already use, and fill row by row using the actual stride.
Added two regression tests in test/api/test-raster.cc:
test_background_premultiplied (default stride, half-alpha background,
checks the stored pixel is premultiplied) and test_background_stride
(stride much wider than width * 4, opaque background, checks every
row).
Assisted-by: Claude
* [raster] Handle unaligned background strides
A caller-supplied stride does not have to be word-aligned, so casting
each row to uint32_t * can perform misaligned stores.
Use hb_packed_t<uint32_t> for the row writes, and exercise an odd
stride in the regression test with byte-wise pixel checks.
Tests: meson test -C build
Assisted-by: Codex <noreply@openai.com>
---------
Co-authored-by: Arthur031221 <levi74108520963@gmail.com>
Reduce LookupVariationRecord conditions to false, true, or a residual
condition when axes are pinned or restricted. Fold compound AND, OR,
and NOT conditions, remap value-condition variation indices, and emit a
constant condition when a surviving lookup becomes unconditional.
Extend the test font with a second axis and all condition formats so the
subset tests cover structural, full, and partial instancing behavior.
Tested with the full Meson test suite, targeted Clang HB_NO_VAR and GCC
builds, and OTS validation of the fixture.
Assisted-by: OpenAI Codex <codex@openai.com>
Resolve lookup variations at the pinned coordinates and store their final
lookup sets in the subset plan. Use those sets when serializing the main
Feature tables before dropping FeatureVariations from a full instance.
This reuses the shaping resolver so version 1.0 feature substitutions,
ADD_DEFAULT_LOOKUPS, compound conditions, and GDEF variation data are
evaluated consistently.
Tested with the full Meson test suite and a targeted HB_NO_VAR build.
Assisted-by: OpenAI Codex <codex@openai.com>
Subset FeatureVariations 1.1 lookup records while remapping feature and
lookup indices. Preserve all condition formats and remap variation
indices used by value conditions.
Keep features with lookup variations distinct during feature
deduplication, since equal default lookup lists do not imply equal
variable behavior.
Tested with the full Meson test suite and a targeted HB_NO_VAR build.
Assisted-by: OpenAI Codex <codex@openai.com>
Include conditionally referenced lookups in layout collection, feature
closure, and GSUB dependency data. Also retain variation indices used
by FeatureVariations conditions in GSUB and GPOS when remapping the
GDEF variation store.
Tested with the full Meson test suite and targeted HB_NO_VAR builds of
the touched runtime translation units.
Assisted-by: OpenAI Codex <codex@openai.com>
Parse and sanitize the FeatureVariations 1.1 lookup-oriented records.
Resolve their effective lookup sets while constructing the shape-plan
key so cache entries remain exact without retaining raw coordinates.
Handle ADD_DEFAULT_LOOKUPS, multiple matching conditions, and the
interaction with version 1.0 feature substitutions. Keep the existing
public FeatureVariations query API behavior unchanged.
Tested with the full Meson test suite.
Assisted-by: OpenAI Codex <codex@openai.com>
Encode versions 1.0 and 2.0 in the VORG fixtures instead of the undefined
minor version 1. The test behavior is unchanged, but the input now conforms
to the final Open Font Format definition.
Tested with test-be-subset-tables and the full Meson suite.
Assisted-by: OpenAI Codex <codex@openai.com>
Consult DMAP before cmap for nominal and variation mappings, and combine
their character coverage while retaining DMAP precedence. Reuse the cmap
parser and serializer for DMAP, including effective subsetting closure.
Keep DMAP available independently of beyond-64K support; only cmap format
15 remains conditional.
Tested with the full Meson suite and with an HB_NO_BEYOND_64K build.
Assisted-by: OpenAI Codex <codex@openai.com>
Account for the uint24 glyphCount field when reserving the uppercase
GVAR header. The fixed 20-byte size caused the final byte of the
glyphVariationDataArrayOffset to overlap the first array offset.
Add an exact binary subsetting regression for the 21-byte header.
Testing: meson test -C build --print-errorlogs
Assisted-by: OpenAI Codex
reference_ft_library() returns an owned FT_Library reference that the
success paths hand to the FT_Face finalizer or the blob user-data
destructor. Four early returns in hb_ft_face_create_from_file_or_fail,
hb_ft_face_create_from_blob_or_fail and hb_ft_font_set_funcs returned
without releasing it, pinning the static library on invalid input and
OOM. Release it via destroy_ft_library() on each path.
Use the final version 1.4 header with five appended Offset32 fields
instead of the obsolete major-version-2 layout. Honor each nonzero
Offset2 field in preference to its legacy counterpart when reading and
subsetting the table.
Add a binary regression test that gives the legacy and extended glyph
class definitions different values, ensuring the extended field wins.
Testing: meson test -C build
Assisted-by: OpenAI Codex <codex@openai.com>
Reconcile the beyond-64K table type changes with the dependency API,
graph result handling, and variation-budget updates from main. Preserve
the branch's wider table variants while adopting the new behavior.
Build and test with Meson (281 passed, 1 skipped).
Assisted-by: OpenAI Codex <noreply@openai.com>
on a stream-backed FT_Face
hb_ft_font_set_funcs() creates its own internal FT_Face from the
font's face blob, and hooks that blob to the FT_Face's generic
finalizer (_release_blob), with the shared static FT_Library hooked
to the blob's user-data destructor (destroy_ft_library).
On hb_font_destroy(), _hb_ft_face_destroy_static() locks
static_ft_library_mutex and calls FT_Done_Face(), which synchronously
runs the finalizer chain: _release_blob() -> hb_blob_destroy(). For a
face created from a custom FreeType stream (FT_OPEN_STREAM), each
hb_face_reference_blob() call synthesizes a brand-new, unshared blob
(via _hb_ft_reference_table()), so this hb_blob_destroy() call drops
it straight to zero, which triggers destroy_ft_library(), which tries
to lock the same non-recursive static_ft_library_mutex again on the
same thread. Self-deadlock.
This didn't reproduce for a file-path or memory-blob face, because
there the blob handed to the internal FT_Face is the same blob shared
by the outer hb_face_t, so the drop inside the lock only decrements
its refcount without reaching zero; the final unref (and
destroy_ft_library() call) happens later, outside the lock, when the
outer face itself is destroyed.
Fix by holding an extra reference on the blob across the locked
FT_Done_Face() call, so it can only reach a zero refcount (and invoke
destroy_ft_library()) after static_ft_library_mutex has been
released. FT_Done_Face() itself remains fully serialized, as intended
by 46644f885d.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6276
Tests: meson test -C build (260/260 passed); added
test_native_ft_set_funcs_stream_face_no_deadlock to test/api/test-ft.c,
which hangs on unfixed code and passes with the fix. Also verified
against the reporter's original repro.c.
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
* [font] fix signed integer overflow in synthetic_glyph_extents
synthetic_glyph_extents applies synthetic slant and embolden to a
glyph's extents with plain hb_position_t arithmetic: x_bearing +
width and y_bearing + height in the slant branch, plus the += / -=
shifts in the embolden branch. glyf's contour_bounds_t and the sbix
png-dimension path each clamp x_bearing/width and y_bearing/height to
the full hb_position_t range independently via
hb_clamp_to<hb_position_t>(), so one field can reach INT32_MIN/MAX on
its own and the sum overflows, which is undefined behavior (UBSan
signed-integer-overflow at hb-font.hh:221). Reached from
hb_font_get_glyph_extents when synthetic slant/bold is set and the
glyph has extents but no drawable outline.
This is the sibling of 873dbc1 (scale_glyph_extents), which fixed the
same x_bearing + width overflow in the adjacent function. Accumulate
the slant terms in double and the embolden terms in int64, saturating
each result to hb_position_t with hb_clamp_to, matching that fix and
the copy in hb-ft.cc. Valid in-range extents are unchanged.
Add a regression test in test/api/test-font.c that drives the sink
with INT32-extreme extents; it aborts under the asan/ubsan job without
the fix. Full meson test -C build stays green.
* [font] use int64_t for slant accumulation in synthetic_glyph_extents
The analytic rasterizer stored every row's area and cover in 32- and
16-bit accumulators. Highly overlapping outlines could exceed those
ranges and trigger signed overflow before coverage was clamped.
Keep compact SIMD accumulators for rows with at most 127 active edges.
Lazily use 64-bit scalar accumulators for denser rows, where the narrow
cover bound no longer holds. Add regressions for area overflow and
cover wrapping.
Tested with meson test -C build, the ASan/UBSan raster API test, all
raster fuzzer corpus chunks, and the supplied reproducer.
Assisted-by: OpenAI Codex <noreply@openai.com>
Update the generated Unicode and language-tag tables for Unicode 18.0.
Add script values for Jurchen, Proto-Cuneiform, and Seal, route them
through USE, and select ideographic baselines for Jurchen and Seal.
Document the new script values and extend Unicode and baseline tests.
Tested with meson test -C build: 278 passed, 1 skipped, 0 failed.
Assisted-by: Codex <codex@openai.com>
Verify that VARC component coordinates can address axes retained in gvar
when a static font has no fvar table.
Tested with the full Meson test suite.
Assisted-by: Codex <codex@openai.com>
* Add null checking and fix memory leak in hb-coretext.cc
Assisted by: Gemini
* Add RAII hb_cf_ptr_t to manage coretext object lifetimes.
* Remove HAVE_CORETEXT guard in hb-coretext.hh
hb-coretext.hh will only be included when HAVE_CORETEXT is defined, so no need for the guard.