Commit Graph
22210 Commits
Author SHA1 Message Date
Roshan Ramani bb702ff6de [docs] Fix five function names in the user manual
The manual named hb_ot_color_reference_png/svg(),
hb_font_paint_or_fail_glyph(), hb_ft_get_face() and
hb_coretext_face_get_ct_font(), none of which exist. Use
hb_ot_color_glyph_reference_png/svg(), hb_font_paint_glyph_or_fail(),
hb_ft_font_get_face() and hb_coretext_font_get_ct_font().

Assisted-by: Claude Code:claude-opus-5-5
2026-10-17 14:13:49 +03:00
nussaibah shaikh 47b18b6ebd [font] Don't read stale design coords in hb_font_set_variation() (#6402)
hb_font_set_variation() seeds its new design coords from the font's
existing ones for every axis of the current face, trusting an assert
that their lengths match. hb_font_set_face() keeps the font's
variation coords, which stay sized for the old face, so switching to
a face with more axes and then calling hb_font_set_variation() reads
past the old array: a heap-buffer-overflow read with NDEBUG, an
assertion failure otherwise.

Only reuse the existing design coords when their length matches the
current face; otherwise start from the defaults, as when none are set.

Reproduced the overflow under ASan with NDEBUG and the assertion
failure in the default build. Added a regression test in test-font.c
that fails without the fix. The full ASan+UBSan Meson suite passes.

Assisted-by: Claude
2026-10-16 12:18:00 -06:00
Behdad Esfahbod cb651c51d9 [ot] Ignore variation deltas at the default instance (#6401)
Use has_nonzero_coords when creating a shaping plan, and treat explicit
all-zero coordinates as an empty location in ItemVarStoreInstancer.
A constant GDEF delta then cannot change a condition at the default
instance, matching OFF section 7.1 and the condition's default field.

Keep the Boolean result in the stored int16 default when partial
instancing moves an oversized condition value into a private bias row.
Only the excess belongs in that row, since default instances ignore it.

Add a regression for empty versus explicit default plan keys and shaping
across default, varied, and default locations. Existing subset precision
tests cover the private bias and repeated instancing.

Validation: all 290 Meson test groups pass with experimental APIs enabled.

Assisted-by: Codex
2026-10-16 11:01:47 -06:00
Mar 5365d272d5 [font] Deprecate hb_font_set_face()
Changing the face now resets font funcs. Deprecate the setter in favor
of creating a new font with hb_font_create() and setting its properties.
Keep the exported symbol and move its declaration to hb-deprecated.h.

Document the deprecation in NEWS and the API section index. Guard the
face-setter tests with HB_DISABLE_DEPRECATED, and suppress expected
warnings from their deliberate use of the deprecated API.

The full ASan Meson suite passes (270 passed, 1 skipped). test-font also
builds and passes with HB_DISABLE_DEPRECATED. Its source passes Clang
-Werror checks both with and without deprecated APIs enabled.

Assisted-by: Claude
Assisted-by: Codex
2026-10-16 00:19:21 +03:00
Mar ef64f7ea8b [font] Reset font funcs in hb_font_set_face()
Font funcs and their data may hold pointers into the font's face.
hb_font_set_face() released the old face but kept those funcs, causing
stale lookups or a use-after-free when the last face reference was gone.

Release the font funcs and their data while the old face is still alive,
then install the default funcs for the new face. Preserve the other font
properties and document the callback reset in the API docs and NEWS.

Add regressions for OpenType lookups and custom font-data destruction.
Reproduced stale glyph lookup and the heap-use-after-free under ASan
before the fix. The full ASan Meson suite passes (270 passed, 1 skipped),
and the two regressions also pass with HB_FONT_FUNCS=ft.

Assisted-by: Claude
Assisted-by: Codex
2026-10-16 00:19:21 +03:00
Behdad Esfahbod 6cb629b389 Merge pull request #6400 from harfbuzz/codex/ot-layout-size-followup
[subset] Share GPOS subsetting across table widths
2026-10-15 14:52:57 -06:00
Behdad Esfahbod 7aa4508c7c [subset] Share retained mark attachment row selection
Use the same count-bounded coverage, class-map filtering, non-null
anchor test, and row-major index selection for MarkBase and MarkMark.
Pass a read-only 16/24-bit offset view after decoding the matrix rows.
Keep typed anchor serialization and the existing vector error behavior.

Saves 5120 bytes at -O3 and 3160 bytes at -Os with GCC 15.3 without
LTO, and 5912 bytes with Clang 21 LTO. The full Meson suites pass with
beyond-64k enabled and disabled; 288 synthetic subset cases match
baseline table bytes, plus 144 cases in the no64 build.

Sampled subset CPU-time geometric means change by +0.82% for ordinary
fonts and -0.55% for variable fonts. The largest ordinary-font change
is +3.42% for Noto Sans Devanagari.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 14:49:13 -06:00
Behdad Esfahbod a140b5dc1e [subset] Share PairSet value traversal across glyph widths
Expose the source glyphs, values, count, stride, and device-offset
base through a native view. Share effective-format analysis and
variation-index collection without changing typed glyph emission.
Move the value-copy context out of the source-width template too.

Retain the outer scan guard for variable-device instancing and the
existing record-serialization error behavior.

Saves 1576 bytes at -O3 and 128 bytes at -Os with GCC 15.3 without
LTO. The full Meson suite passes and 288 synthetic narrow/wide subset
cases match baseline table bytes. Sampled CPU-time geometric means
change by -1.08% with hint stripping and -0.23% for font instancing.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 14:45:30 -06:00
Behdad Esfahbod 01e3e76ac8 [subset] Share mark attachment variation-index traversal
Use read-only 16/24-bit offset views to share mark-anchor and
ligature-matrix traversal. Keep count-limited coverage iteration,
row-major index selection, original anchor bases, and null offsets.
The typed wrappers retain table sanitization and field decoding.

Saves 5752 bytes at -O3 and 3272 bytes at -Os in the subset library
with GCC 15.3 without LTO. The full Meson suite passes. Synthetic
16/24-bit subset checks match baseline table bytes in 192 cases,
including variation devices, null matrices, class pruning, and
retain-GID modes. Sampled variable-font subset CPU time changes by
+0.57% overall, with individual cases from +0.24% to +0.79%.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 14:39:33 -06:00
Behdad Esfahbod 72dd0b0d96 [subset] Share PairPos class-matrix subsetting across widths
Resolve the source base, value formats, and matrix dimensions before
analyzing and copying class-pair values. Keep those operations in a
common native view instead of duplicating them in the small and
beyond-64k table instantiations.

Preserve the variable-device scan guard and propagate allocation
failure when collecting retained second-class indices.

Saves 2864 bytes at -O3 and 1336 bytes at -Os in the subset library
with GCC 15.3 without LTO. The full Meson suite passes. Sampled subset
CPU-time geometric means change by -0.56% for ordinary fonts and
-1.55% for variable fonts.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 14:23:51 -06:00
Behdad Esfahbod ca4f037495 [subset] Share mark-to-ligature coverage serializers across widths
The coverage iterator needs glyph IDs and the mark-record count, but
zipping in the records gives it a type that depends on the source
width. Zip with a bounded index range instead, retaining the same
truncation when coverage and record counts differ.

Saves 7552 bytes at -O3 and 2112 bytes at -Os in the subset library
with GCC 15.3 without LTO. The full Meson suite passes; sampled subset
CPU-time changes range from -0.18% to +0.83%.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 14:19:55 -06:00
Behdad Esfahbod fda2374fd0 [ot] Reduce duplicated layout code for beyond-64k tables (#6399)
* [ot] Share mark attachment positioning across table widths

MarkArray::apply instantiates the same positioning and attachment-chain
updates for each mark-array and anchor-matrix representation.

Resolve the format-specific anchors in the wrapper and pass them to a
common helper. Preserve the anchor checks, buffer flags, messages, and
attachment overflow behavior.

With GCC 15.3 on x86-64 without LTO, this removes 1576 bytes of core
code/read-only data at -O3 and 648 bytes at -Os. Validated with the full
Meson suite (292 passed, one skipped) and sampled shaping benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>

* [ot] Share cursive attachment positioning across table widths

CursivePosFormat1_2 duplicates the direction-dependent positioning and
attachment-chain updates for legacy and beyond-64k entry/exit records.

Keep record access and anchor validation in the format-specific wrapper,
then pass the resolved anchors to a common attachment helper. Preserve
all direction cases, chain reversal, overflow handling, and messages.

With GCC 15.3 on x86-64 without LTO, this removes another 2760 bytes of
core code/read-only data at -O3 and 864 bytes at -Os. Validated with the
full Meson suite (292 passed, one skipped) and sampled shaping benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>

* [subset] Share mark-class remapping across record widths

Mark classes remain 16-bit values in both mark-record representations;
only the record stride and array count differ. Decode those in the
wrapper and share the class collection and remapping work.

Give the common helper hidden inline linkage so its body is shared
across translation units as well as record formats. Class ordering,
existing mappings, and allocation behavior are preserved.

With GCC 15.3 on x86-64 without LTO, this removes 1152 bytes of subset
code/read-only data at -O3 and 1440 bytes at -Os. Validated with the full
Meson suite (292 passed, one skipped) and subset benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>

* [subset] Share SinglePos serializers across source formats

SinglePos output serializers only need the source value format and
ValueBase pointer, but carried the full source lookup type through
several template layers. The per-glyph mapper also had distinct lambda
types for legacy and beyond-64k source tables.

Pass the source format and base directly, and use a common mapper with
the same reference captures as the original lambda. Output formats,
device offsets, value copying, and allocation behavior are preserved.

With GCC 15.3 on x86-64 without LTO, this removes 18080 bytes of subset
code/read-only data at -O3 and 9472 bytes at -Os. Validated with the full
Meson suite (292 passed, one skipped) and subset benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>

* [subset] Share delta substitution subset serialization

SingleSubstFormat1_3 constructs equivalent remapping iterators in each
source-format specialization, giving the output and coverage serializers
distinct iterator types and duplicating their bodies.

Move the subset preparation into a common helper taking the decoded
coverage, delta, and glyph mask. Preserve the glyph intersection,
modular delta calculation, remapping, and serializer failure behavior.

With GCC 15.3 on x86-64 without LTO, this removes 11896 bytes of subset
code/read-only data at -O3 and 5776 bytes at -Os. Validated with the full
Meson suite (292 passed, one skipped) and subset benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>

* [ot] Share SinglePos optical-bound context setup

SinglePos position_single duplicates the temporary apply context and
value application for each source representation. Keep coverage and
value-index checks in the wrappers and share the context setup through
ValueFormat, passing the original value base explicitly.

With GCC 15.3 on x86-64 without LTO, this removes 2088 bytes of core
code/read-only data at -O3 and 616 bytes at -Os. Optical-bound benchmarks
show no consistent slowdown across the four source formats.

Validated with the full Meson suite (292 passed, one skipped) and
synthetic optical-bound checks for all directions, 16/24-bit glyph IDs,
missing glyphs, and device adjustments.

Assisted-by: OpenAI Codex <codex@openai.com>

* [subset] Share retained mark-anchor index collection

Mark-to-base and mark-to-mark variation collection construct the same
row-major anchor-index lists, but do so inside each table-width template.
Pass the decoded row and class counts to a common collector.

Preserve coverage filtering, class selection, index order, and the
existing vector allocation behavior. Anchor access remains in the
format-specific wrappers.

With GCC 15.3 on x86-64 without LTO, this removes 2896 bytes of subset
code/read-only data at -O3 and 2152 bytes at -Os. Validated with the full
Meson suite (292 passed, one skipped) and variable-font subset benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>

* [ot] Share delta substitution glyph traversal across widths

Closure, dependency extraction, and glyph collection for delta
substitutions only need a decoded coverage, delta, and glyph mask.
Share those traversals instead of instantiating them for each source
representation.

Keep the closure population and overlapping-range guards, dependency
bounds filtering, traversal order, and allocation behavior unchanged.

With GCC 15.3 on x86-64 without LTO, this removes 1112 bytes of core and
952 bytes of subset code/read-only data at -O3, and 608/712 bytes at -Os.
Validated with the full Meson suite (292 passed, one skipped), C++11
syntax checking, and subset benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>

* [subset] Share pair-position variation-index collection

Resolve the table-width-dependent PairPos fields before collecting
variation indices. Share the class sets and matrix traversal between
the small and beyond-64k formats while retaining the original value
base for device offsets.

Saves 3328 bytes at -O3 and 2312 bytes at -Os in the subset library
with GCC 15.3 without LTO. The full test suite passes, including the
HB_NO_BEYOND_64K build; variable-font subset timings remain close.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 14:15:15 -06:00
Behdad Esfahbod c094e220c9 [ot] Erase glyph widths in contextual lookup helpers (#6398)
Contextual lookup helpers are instantiated separately for 16-bit
glyphs, 24-bit glyphs, and coverage offsets, duplicating traversal
code when beyond-64k support is enabled.

Use an allocation-free glyph-data view carrying the pointer and
element width to share matching, contextual application, intersection,
collection, closure, and dependency helper bodies. Preserve the
existing forced-inlining policy for the matching helpers.

With GCC 15.3 on x86-64 without LTO, each stripped shared library
shrinks by 12 KiB at -O3. Shaping and subset timings stay close to
baseline overall, with a measured 2% slowdown on Duployan shaping.

Validated with the full Meson suite, API/shaping/subset tests with
HB_NO_BEYOND_64K, Clang reduced-feature syntax checks, and synthetic
24-bit contextual shaping, would-apply, and glyph-collection checks.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 14:00:12 -06:00
Behdad Esfahbod 570c92b993 [subset] Share pair-position variation-index collection
Resolve the table-width-dependent PairPos fields before collecting
variation indices. Share the class sets and matrix traversal between
the small and beyond-64k formats while retaining the original value
base for device offsets.

Saves 3328 bytes at -O3 and 2312 bytes at -Os in the subset library
with GCC 15.3 without LTO. The full test suite passes, including the
HB_NO_BEYOND_64K build; variable-font subset timings remain close.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 12:32:45 -06:00
Behdad Esfahbod f2c944c7c9 [ot] Share delta substitution glyph traversal across widths
Closure, dependency extraction, and glyph collection for delta
substitutions only need a decoded coverage, delta, and glyph mask.
Share those traversals instead of instantiating them for each source
representation.

Keep the closure population and overlapping-range guards, dependency
bounds filtering, traversal order, and allocation behavior unchanged.

With GCC 15.3 on x86-64 without LTO, this removes 1112 bytes of core and
952 bytes of subset code/read-only data at -O3, and 608/712 bytes at -Os.
Validated with the full Meson suite (292 passed, one skipped), C++11
syntax checking, and subset benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 12:27:50 -06:00
Behdad Esfahbod ffa5d3faf1 [subset] Share retained mark-anchor index collection
Mark-to-base and mark-to-mark variation collection construct the same
row-major anchor-index lists, but do so inside each table-width template.
Pass the decoded row and class counts to a common collector.

Preserve coverage filtering, class selection, index order, and the
existing vector allocation behavior. Anchor access remains in the
format-specific wrappers.

With GCC 15.3 on x86-64 without LTO, this removes 2896 bytes of subset
code/read-only data at -O3 and 2152 bytes at -Os. Validated with the full
Meson suite (292 passed, one skipped) and variable-font subset benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 12:23:41 -06:00
Behdad Esfahbod 3e831689a9 [ot] Share SinglePos optical-bound context setup
SinglePos position_single duplicates the temporary apply context and
value application for each source representation. Keep coverage and
value-index checks in the wrappers and share the context setup through
ValueFormat, passing the original value base explicitly.

With GCC 15.3 on x86-64 without LTO, this removes 2088 bytes of core
code/read-only data at -O3 and 616 bytes at -Os. Optical-bound benchmarks
show no consistent slowdown across the four source formats.

Validated with the full Meson suite (292 passed, one skipped) and
synthetic optical-bound checks for all directions, 16/24-bit glyph IDs,
missing glyphs, and device adjustments.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 12:18:30 -06:00
Behdad Esfahbod e6827ea9da [subset] Share delta substitution subset serialization
SingleSubstFormat1_3 constructs equivalent remapping iterators in each
source-format specialization, giving the output and coverage serializers
distinct iterator types and duplicating their bodies.

Move the subset preparation into a common helper taking the decoded
coverage, delta, and glyph mask. Preserve the glyph intersection,
modular delta calculation, remapping, and serializer failure behavior.

With GCC 15.3 on x86-64 without LTO, this removes 11896 bytes of subset
code/read-only data at -O3 and 5776 bytes at -Os. Validated with the full
Meson suite (292 passed, one skipped) and subset benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 12:13:07 -06:00
Behdad Esfahbod dafbe9c4bb [subset] Share SinglePos serializers across source formats
SinglePos output serializers only need the source value format and
ValueBase pointer, but carried the full source lookup type through
several template layers. The per-glyph mapper also had distinct lambda
types for legacy and beyond-64k source tables.

Pass the source format and base directly, and use a common mapper with
the same reference captures as the original lambda. Output formats,
device offsets, value copying, and allocation behavior are preserved.

With GCC 15.3 on x86-64 without LTO, this removes 18080 bytes of subset
code/read-only data at -O3 and 9472 bytes at -Os. Validated with the full
Meson suite (292 passed, one skipped) and subset benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 12:08:37 -06:00
Behdad Esfahbod 4423a80460 [subset] Share mark-class remapping across record widths
Mark classes remain 16-bit values in both mark-record representations;
only the record stride and array count differ. Decode those in the
wrapper and share the class collection and remapping work.

Give the common helper hidden inline linkage so its body is shared
across translation units as well as record formats. Class ordering,
existing mappings, and allocation behavior are preserved.

With GCC 15.3 on x86-64 without LTO, this removes 1152 bytes of subset
code/read-only data at -O3 and 1440 bytes at -Os. Validated with the full
Meson suite (292 passed, one skipped) and subset benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 11:59:38 -06:00
Behdad Esfahbod 1ea14e1cf1 [ot] Share cursive attachment positioning across table widths
CursivePosFormat1_2 duplicates the direction-dependent positioning and
attachment-chain updates for legacy and beyond-64k entry/exit records.

Keep record access and anchor validation in the format-specific wrapper,
then pass the resolved anchors to a common attachment helper. Preserve
all direction cases, chain reversal, overflow handling, and messages.

With GCC 15.3 on x86-64 without LTO, this removes another 2760 bytes of
core code/read-only data at -O3 and 864 bytes at -Os. Validated with the
full Meson suite (292 passed, one skipped) and sampled shaping benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 11:55:19 -06:00
Behdad Esfahbod 87454172a8 [ot] Share mark attachment positioning across table widths
MarkArray::apply instantiates the same positioning and attachment-chain
updates for each mark-array and anchor-matrix representation.

Resolve the format-specific anchors in the wrapper and pass them to a
common helper. Preserve the anchor checks, buffer flags, messages, and
attachment overflow behavior.

With GCC 15.3 on x86-64 without LTO, this removes 1576 bytes of core
code/read-only data at -O3 and 648 bytes at -Os. Validated with the full
Meson suite (292 passed, one skipped) and sampled shaping benchmarks.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-15 11:52:19 -06:00
nussaibah shaikh fe407340d5 Clamp transformed CFF2 blend deltas before int conversion (#6397)
When partially instancing a CFF2 font, the blend rewriters in
hb-subset-cff2.cc pass each old delta row through the region transform
and store the result with (int) round (transform_delta (...)).
transform_delta accumulates in double with no bound. Private DICT
operands can be BCD reals of any magnitude, so a StdVW blend delta of
1e12 yields about 3.7e11 at wght=300:600, and the double-to-int
conversion is undefined behavior (UBSan float-cast-overflow in
cff2_private_dict_blend_opset_t::rewrite_blends).

Saturate with hb_clamp_to<int>, as number_t::to_int already does.
The charstring blend rewriter uses the same expression and gets the
same clamp. Charstring operands are bounded by the 16.16 range, so
that site is not known to overflow in practice. Results that fit in
int are unchanged.

Add a regression test to test-instance-cff2 with a fixture generated
from AdobeVFPrototype.abc.otf. Under UBSAN_OPTIONS=halt_on_error=1 it
fails before the fix and passes after. The full Meson suite passes
under ASan+UBSan (290 ok).

Assisted-by: Claude
2026-10-15 11:16:49 -06:00
Behdad Esfahbod 1b352dfc0f [ot] Keep lookup-variation shape-plan keys compact (#6396)
* [ot] Keep lookup-variation shape-plan keys compact

Resolving every feature's lookup set into the shape-plan key copies
shared lookup lists once per feature, even when shaping never uses those
features. Small fonts can therefore retain large keys and allocate
another copy on every cache lookup.

Store sorted offsets of distinct satisfied conditions instead. Evaluate
shared tables and conditions once, and expand lookup sets only when
building selected features. Preserve default lookups and feature-table
substitutions, and adapt full-axis instancing to resolve retained
features from the same compact condition state.

Condition outcomes form a conservative cache key: different outcomes
may keep otherwise equivalent lookup unions in separate plans.

Add regressions for shared records, null and shared conditions,
overlapping lookup sets, empty overrides, default lookups, sorting,
and allocation failure. The full Meson suite passes (292 passed,
1 skipped). ASan/UBSan runs pass on 64 failing-malloc inputs, and the
touched code compiles with HB_NO_VAR under C++11.

Assisted-by: OpenAI Codex <codex@openai.com>

* [test] Use an unsigned lookup condition count

Adding two boolean expressions produces an int, which GCC rejects when
compared with the unsigned vector length under -Werror=sign-compare.
This prevents the new regression test from compiling in the Linux,
docs, Rust, and Valgrind jobs.

Store the expected count as unsigned before comparing it with the
vector length. Reproduced the error with GCC C++11; the corrected test
builds and runs with GCC. The full Meson suite passes (292 passed,
1 skipped).

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-14 20:33:52 -06:00
nussaibah shaikh 3fff90528d clamp variable advance before unsigned conversion (#6395)
get_advance_with_var_unscaled adds the HVAR/VVAR advance delta to the
base advance and returns the sum as unsigned. The delta from
ItemVariationStore::get_delta is an unbounded float, so an HVAR whose
item-variation store uses long-word (int32) deltas across several
regions that all peak at the axis extreme can make advance + roundf
(delta) exceed the unsigned range; converting that float to unsigned is
then undefined behavior (UBSan float-cast-overflow), and hb_max (0.0f,
NaN) would likewise pass NaN to the conversion. Reached from the public
hb_font_get_glyph_h_advance / v_advance on a variable font.

Clamp the accumulated value into the unsigned range with hb_clamp_to
before returning, matching the saturation already used for the
variation-derived glyph-extents arithmetic. Valid advances are
unchanged. The template is shared by hmtx/HVAR and vmtx/VVAR, so all
three advance sites are covered.

Add a regression test under test/api driving a crafted long-word HVAR;
it reports float-cast-overflow under the sanitizers job without the fix
and passes with it. The full meson test suite passes.
2026-10-14 10:51:09 -06:00
Behdad EsfahbodandMar 9df939b153 [vector] Fix use-after-free when appending from own storage (#6393)
push (v[i]) reads its argument after alloc() may have moved the
vector's backing storage. Array extension has the same problem.
This is reachable through item_variations_t::duplicate_row() when
subsetting avar2 axes that share a variation row.

Construct a temporary before growth when a push argument aliases our
storage, and recover aliased source arrays by offset after allocation.
Keep the alias check on the push growth path, and reject already-failed
vectors before moving from their arguments.

Share the array extension implementation and route direct vector
extension through it, making v.extend (v) safe as well. General iterator
adapters into the same vector still cannot survive reallocation.

Add regressions for trivial and non-trivial copies, aliased moves,
constructor arguments, mutable and const arrays, direct self-extension,
and already-failed vectors. Reproduced push and both extension failures
under ASan before the fix. The updated tests pass under ASan+UBSan and
GCC with HB_TINY; injected allocation failures are clean under the
sanitizers. The full Meson suite passes (292 passed, 1 skipped).

Assisted-by: Claude
Assisted-by: Codex

Co-authored-by: Mar <mardgez13@gmail.com>
2026-10-13 16:32:31 -06:00
Behdad EsfahbodandChi-Iroh fed245b6ab [build] Disable hidden inline visibility on XCOFF
IBM i and AIX use XCOFF, which rejects hidden visibility on references
to imported inline symbols. This can prevent test-repacker from linking
against libstdc++.

Disable inline visibility hiding for these hosts in Meson and CMake,
while preserving the existing setting on other systems.

The full configured Meson suite passed (288 tests), and a native CMake
shared-library build succeeded. Platform-policy checks cover AIX,
OS400, Linux, macOS, and Windows. Native IBM i/AIX was unavailable.

Co-authored-by: Chi-Iroh <69324626+Chi-Iroh@users.noreply.github.com>
Assisted-by: OpenAI Codex
2026-10-13 12:56:42 +03:00
dependabot[bot] fba9b0dec2 Bump github/codeql-action/upload-sarif from 4.38.2 to 4.38.3
Bumps [github/codeql-action/upload-sarif](https://github.com/github/codeql-action) from 4.38.2 to 4.38.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2...24c54180a607b1449ed407dd24f251e4e9147c8d)

---
updated-dependencies:
- dependency-name: github/codeql-action/upload-sarif
  dependency-version: 4.38.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-13 12:54:28 +03:00
dependabot[bot] cc9c6c04aa Bump actions/upload-artifact from 7.0.1 to 7.0.2
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 7.0.1 to 7.0.2.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/043fb46d1a93c77aae656e7c1c64a875d1fc6a0a...cf430e030ddbb5b0abf93d22962f4752f3646cd9)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-13 12:53:55 +03:00
dependabot[bot] 0af507f995 Bump actions/download-artifact from 8.0.1 to 8.0.2
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 8.0.1 to 8.0.2.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c...9000827ccba6bdab643e8b6fd33ac0654aef8333)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 8.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-13 12:53:23 +03:00
Behdad Esfahbod 2329384670 [subset] Preserve COLR sentinel-only variation maps (#6389)
COLR closure returned before planning delta-set index mappings when
there was no store or no live variation index. Variable paint and stop
serialization then failed to find their remapped bases, dropping COLR.

Remap explicit delta-set indices even when every entry is the
NO_VARIATION_INDEX sentinel. Keep variation-row planning conditional on
live rows. Cover NULL and empty stores with ordinary subsetting,
partial instancing of either axis, and full instancing.

Testing: meson test -C build passed 271 targets, with one skip.

Assisted-by: OpenAI Codex
2026-10-12 17:50:56 -06:00
Behdad Esfahbod e8ed626526 [subset] Preserve Fixed base precision in COLR affine values (#6384)
Instancing PaintVarTransform loses low Fixed bits when the stored base
is converted to float before adding its delta. This occurs at ordinary
translation values and even when the delta is zero.

Add the float delta to the precise stored integer in double precision,
then round to the target Fixed integer. Preserve the existing default
coordinate fast path.

Cover all six coefficients, signed and zero deltas, and direct and
composed instances in both axis orders at ordinary magnitudes. The
pre-fix library fails the translation regression. All 256 configured
Meson tests pass, and all 28 matrices match FontTools exactly in each
instancing order.

Assisted-by: Codex
2026-10-11 14:41:09 -06:00
Behdad Esfahbod 534f82e726 [subset] Preserve negative derived COLR radial gradients (#6387)
Reparameterize circles and color stops together when a derived radius
is negative. Preserve pad, repeat, reflect, and stable stop ordering.
Normalize constant gradients after a partial pin without creating
constant variation regions at the new default.

Allow fractional parameter shifts on the common lattice of the circle
coordinates and F2Dot14 stops. This preserves odd stop bits in ordinary
coordinate ranges that integer-only shifts incorrectly rejected.

Assisted-by: Codex
2026-10-11 14:37:21 -06:00
Behdad Esfahbod d5e4f22a13 [COLR] Round variable clip edges outwards (#6388)
Round minimum clip edges down and maximum edges up in font units.
Nearest rounding can shrink bounds and cut painted pixels.

Cover signed fractional deltas, default coordinates, rendering, and
full/composed instances in both axis orders at ordinary values.
All 256 configured Meson tests passed.

Assisted-by: Codex
2026-10-11 14:32:47 -06:00
Behdad Esfahbod fac913b1de [math] Preserve and apply shared GDEF variation indices (#6385)
MATH devices were evaluated against an empty variation store, and the
subsetter dropped them without folding deltas into the base values.
MATH users were also omitted when pruning GDEF's shared store.

Evaluate MATH VariationIndex devices with GDEF's store. Collect indices
from retained constants, glyph information, and assemblies, then fold
pinned deltas and remap residual devices during subsetting. Preserve
ordinary ppem device corrections and reject unrepresentable values.

Add a reproducible two-axis fixture covering every MathValueRecord
location, axis orders, full and partial instances, and glyph pruning.
All 255 configured tests pass; reduced-feature syntax checks pass.

Assisted-by: Codex
2026-10-11 00:41:07 -06:00
Behdad Esfahbod 173eeb59a3 [subset] Allow unchanged VARC axis range requests (#6371)
Assisted-by: Codex
2026-10-11 00:38:36 -06:00
Behdad Esfahbod 5c5172fcd2 [subset] Preserve zero-contour glyph instructions when instancing (#6369)
Zero-contour glyphs can contain instructions for phantom-point metrics.
Non-default instancing discarded them, while the empty-glyph branch
also bypassed ordinary hint removal.

Copy these instructions into owned compiled storage, and remove them
when hinting is dropped. Keep discarded .notdef outlines empty.

Add generated data and regressions for ordinary subsets, default pins,
partial and full instances, hint removal, and phantom-point advances.
The configured Meson suite passes: 253 tests and one skipped.

Assisted-by: Codex
2026-10-11 00:38:02 -06:00
Behdad Esfahbod 3b39c74c3a [subset] Preserve overflowing static COLRv1 scales (#6370)
Assisted-by: Codex
2026-10-11 00:37:22 -06:00
Behdad Esfahbodandartemkulyk bc1e757db1 [subset/CBDT] Share strike data without losing bitmaps on OOM (#6368)
Identical CBLC subtables can share exact image blocks instead of
copying the same CBDT bytes for every strike. Carry forward the sharing
implementation and expected font outputs from #6287.

A cache allocation failure previously discarded a strike without
setting a serializer error, so subsetting could succeed with no bitmap
strikes. Treat cache insertion as best-effort and stop further insertions
after a cache error. Propagate failures in the required temporary image
and offset buffers to the serializer instead of silently dropping data.

Add a regression that fails all three cache allocations in turn and
compares both strikes and every image byte with uncached output. It also
checks required allocation failures cannot silently discard a strike.
The cache regression fails against the original PR and passes here.

The full configured Meson suite passed: 289 tests, including all 224
CBDT subset cases. MSVC and native 32-bit builds were not run locally.


Assisted-by: OpenAI Codex

Co-authored-by: artemkulyk <artem.kulyk@gmail.com>
2026-10-11 00:36:18 -06:00
Behdad EsfahbodandChi-Iroh e53a34da63 [meson] Link auxiliary libraries with the thread dependency (#6366)
Auxiliary libraries use inline HarfBuzz object and container code that
can reference pthread mutex functions. Meson's link_with does not
propagate the main library's external dependencies into these targets,
which leaves unresolved pthread symbols on IBM i.

Use common_harfbuzz_deps for the raster, vector, GPU, and Cairo
libraries, and thread_dep for the ICU and GObject libraries. CMake
already propagates Threads::Threads through the main library.

The full configured Meson suite passed (288 tests). All six libraries
have the thread compiler flags, and a build with optional libraries and
multithreading disabled succeeds. Native IBM i/AIX was unavailable.


Assisted-by: OpenAI Codex

Co-authored-by: Chi-Iroh <69324626+Chi-Iroh@users.noreply.github.com>
2026-10-11 00:34:56 -06:00
Behdad Esfahbod bfabf3f178 [vector] Document blob recycling ownership transfer (#6362)
The recycle functions store the supplied blob without taking another
reference. Mark both arguments transfer-full and explain that the
caller must not destroy the transferred reference. Also clarify that
the blob and its data may be reused by subsequent renders.

Verified ownership with a rendered blob's user-data destroy callback.
This change affects documentation only.

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6357
Assisted-by: Codex
2026-10-10 18:40:28 -06:00
Behdad Esfahbod 58fbf06d6a [docs] Update vector quick-start glyph signatures (#6365)
The vector overview still passed pen coordinates to glyph functions,
whose public signatures now take a single extents mode instead.
Use HB_VECTOR_EXTENTS_MODE_EXPAND for both draw and paint examples.

Extracted both snippets from the documentation and compiled them as
C99 and C++11 with warnings treated as errors. The original snippets
fail to compile. Documentation only.

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6360
Assisted-by: Codex
2026-10-10 18:35:14 -06:00
Behdad Esfahbod aa5eff6b85 [docs] Qualify the object constructor failure guarantee (#6364)
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
2026-10-10 18:34:47 -06:00
Behdad Esfahbod 9d044f792d [vector] Clear accumulated content after failed renders (#6363)
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
2026-10-10 18:33:11 -06:00
Behdad Esfahbod 94e9073251 [raster] Restore background and palette defaults on paint reset (#6361)
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
2026-10-10 18:32:30 -06:00
Yao Zi 123eb68025 [meson] Fix CMake package prefixes on usr-merged systems (#6280)
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
2026-10-10 18:10:44 -06:00
Behdad Esfahbod d89fa94461 [subset] Preserve distinct feature parameters and variations (#6350)
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
2026-10-10 17:07:29 -06:00
Behdad Esfahbod d45fa42c5a [vector] Restore reset defaults and clear PDF draw resources (#6355)
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
2026-10-10 16:59:13 -06:00
Behdad Esfahbod 199cae8b28 [buffer] Document message callback lifetime across reset (#6354)
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
2026-10-10 16:58:18 -06:00
Behdad Esfahbod 86c92a4735 [buffer] Clarify what clear_contents preserves (#6353)
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
2026-10-10 16:57:40 -06:00