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
* [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
If referencing the face blob is not possible (e.g. not implemented by
the font functions), use face builder to create a blob out of
individual table blobs.
Fixes https://github.com/harfbuzz/harfbuzz/issues/5036
Previously, when creating an object from inert inputs (eg:
"hb_font_create(hb_face_get_empty())") we returned the inert
empty object. This is not helpful as there are legitimate
usecases to do that.
We now never return the inert object unless allocation failed.
Tests are revised to reflect.