Commit Graph
1048 Commits
Author SHA1 Message Date
Behdad Esfahbod bd35da613d [test] Remove disabled advance checks from the obsolete proposal
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>
2026-10-02 11:22:24 -06:00
Behdad Esfahbod c034548995 [subset] Preserve the unrounded sign of constant layout conditions
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>
2026-10-02 11:09:38 -06:00
Behdad Esfahbod e5ce527941 [cff2] Support VARC glyphs beyond the CharStrings INDEX
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>
2026-10-02 06:43:14 -06:00
Behdad Esfahbod 955770eaa8 [subset] Preserve universal first-match records after axis pinning
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>
2026-10-02 06:20:51 -06:00
Behdad Esfahbod 81b68595b1 [subset] Instance FeatureVariationRecord condition formats 2-5
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>
2026-10-02 04:49:46 -06:00
Behdad Esfahbod 02c6a9f935 [glyf] Preserve cubic control pairing across contours
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>
2026-10-02 04:31:02 -06:00
Behdad Esfahbod 95f11782f1 [test] Remove obsolete loca glyph-count checks
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>
2026-10-02 04:27:54 -06:00
Behdad Esfahbod f072bff4b0 [ot] Exercise GPOS lookup variations
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>
2026-10-01 20:40:06 -06:00
Behdad Esfahbod 3f39e24e75 [subset] Partially instantiate lookup conditions
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>
2026-10-01 19:43:47 -06:00
Behdad Esfahbod c8d6c273fb [subset] Instantiate LookupVariationRecord lookups
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>
2026-10-01 19:31:11 -06:00
Behdad Esfahbod 3d6677f05c [subset] Preserve LookupVariationRecord tables
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>
2026-10-01 19:25:17 -06:00
Behdad Esfahbod 48d97c4ad1 [ot] Collect LookupVariationRecord dependencies
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>
2026-10-01 19:14:01 -06:00
Behdad Esfahbod 2c05df744c [ot] Support LookupVariationRecord shaping
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>
2026-10-01 19:08:11 -06:00
Behdad Esfahbod c27beebf87 [VORG] Use published versions in tests
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>
2026-10-01 16:51:20 -06:00
Behdad Esfahbod 58a90bf833 [cmap] Support DMAP
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>
2026-10-01 16:27:20 -06:00
Behdad Esfahbod e109b81788 [GVAR] Correct extended header size
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
2026-10-01 14:47:15 -06:00
Behdad Esfahbod 3d5736e8ab [GDEF] Restore version 1.4 header layout
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>
2026-10-01 13:21:30 -06:00
Behdad Esfahbod 17af97aae4 Merge remote-tracking branch 'origin/main' into beyond-64k
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>
2026-10-01 12:59:54 -06:00
Behdad EsfahbodandClaude Sonnet 5 cb995b5754 [ft] Fix self-deadlock in hb_font_destroy() after hb_ft_font_set_funcs() (#6300)
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>
2026-09-30 16:47:55 -06:00
nussaibah shaikh 3c8a65ed9d [font] fix signed integer overflow in synthetic_glyph_extents (#6296)
* [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
2026-09-30 13:04:22 -06:00
Behdad Esfahbod c87f86eff1 [raster] Widen overflowing scanline accumulators (#6273)
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>
2026-09-21 11:58:49 -06:00
Behdad Esfahbod bf93d86714 [Unicode 18] Update Unicode data and script support
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>
2026-09-17 00:37:58 +03:00
Behdad Esfahbod 92f0aa24f9 [test] Cover static VARC axes without fvar (#6260)
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>
2026-09-14 15:30:54 -06:00
Garret Rieger d2e24847f6 Add null checking and fix memory leak in hb-coretext.cc (#6250)
* 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.
2026-09-10 14:54:07 -06:00
Behdad Esfahbod 155a9d88e8 [subset] Address VARC review comments
Short-circuit unchanged-index checks and simplify glyph closure to use
one pending set with the output glyph set tracking visited glyphs.

Strengthen retained-glyph-ID coverage by comparing the source and subset
outlines using the original glyph ID.

Tested with: meson test -C build --print-errorlogs

Assisted-by: OpenAI Codex <openai-codex@users.noreply.github.com>
2026-09-10 13:24:14 -06:00
Behdad Esfahbod cfe86ce5e7 [subset] Harden VARC closure handling
Propagate allocation and component-decoding failures from VARC closure
instead of continuing with an incomplete glyph set. Treat malformed VARC
records as dependency-extraction failures as well.

Document VARC dependency edges and exercise subset variation-store
remapping at non-default coordinates.

Tested with:
- meson test -C build
- standalone lean and world syntax checks
- CMake harfbuzz-subset build

Assisted-by: OpenAI Codex <openai-codex@users.noreply.github.com>
2026-09-10 12:11:13 -06:00
Behdad Esfahbod 50046742d7 Merge branch 'main' into varc-subsetting
Resolve the VARC record-decoding conflict by preserving the shared
decoder while threading main's rendering budget through axis and
variation work.

Tests: meson test -C build (277 passed, 1 skipped)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-09-07 12:16:12 -06:00
Behdad Esfahbod 74fc05cd14 [subset] Address VARC review findings 2026-09-07 12:10:33 -06:00
Behdad Esfahbod 46ea946ab4 Merge pull request #6214 from harfbuzz/rendering-work-budgets
[limits] Add rendering work budgets
2026-09-06 16:36:58 -06:00
Behdad Esfahbod f2d62aaa7d Fix an int overflow
Fixes https://oss-fuzz.com/testcase-detail/4709124282318848
2026-09-04 14:14:49 -06:00
Behdad Esfahbod 46644f885d [ft] Serialize access to the static FreeType library (#6225)
FreeType requires face creation and destruction on a shared
FT_Library to be serialized. Protect the lazily-created static library,
its reference count, and its internally-owned faces with a lazy mutex.

Keep caller-owned FT_Library instances outside the new lock, and add a
multithreaded regression test for blob-backed faces and font funcs.

Tests: meson test -C build (272/272 passed)

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6224
Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-31 12:19:10 -06:00
Behdad Esfahbod dfee0d4380 [raster] Split outline and pixel budgets; drive them via public API
raster-paint reached into the rasterizer through two internal functions:
hb_raster_draw_set_external_work() to inject a shared work counter and
hb_raster_draw_get_edge_work() to read scanline cost back.  Both are gone.

The paint session now carries two budgets for two different resources:

 - The outline budget bounds glyph outline traversal and curve
   flattening.  It is the public draw/paint budget: raster-paint seeds the
   rasterizer with hb_draw_set_budget() before each glyph and reads the
   remainder back with hb_draw_get_budget_remaining(), so a whole COLR
   walk shares one budget without touching rasterizer internals.

 - The pixel budget bounds scanline and fill work, which scales with
   surface area, not outline complexity.  It is charged from the public
   extents of the rendered mask (and other pixel areas) and keeps its
   surface-sized default.  An unlimited outline policy disables it too.

Folding pixel work into the outline budget was why the default had to be
inflated by the surface passes; the two now live apart, so HB_BUDGET_GLYPH
is a pure outline budget and the surface scaling belongs to the pixel
budget.  Standalone hb_raster_draw is unchanged: it draws once, so its
scanline work needs no session budget, only its structural caps.

COLR drives only push_clip_glyph, whose seed/emit/readback is a single
self-contained step, so the aggregate outline budget is always conserved
across a COLR walk.  The push_clip_path_start/end pair spans client draw
calls; like push/pop it must be balanced by the client for the outline
budget to reconcile, and each render is still bounded by the rasterizer's
structural caps regardless.  hb_draw_set_budget() clamps a negative seed
to zero, so outline exhaustion does not latch across glyphs; an empty
mask can then be rendered once more, but that path is bounded by the
pixel budget.

Add a regression test that paints a real multi-layer COLR glyph into a
1x1 surface (unbounded pixel budget) and checks the outline budget both
aggregates the layers' work and bounds the walk.

Tests: meson test -C build (275/275 passed); the raster and gpu COLR
regression seeds complete in 0.40s and 0.44s.

Assisted-by: Claude <noreply@anthropic.com>
2026-08-27 16:53:55 -06:00
Garret Rieger e67dee3f3a Add tests and benchmarks for hb_set_t next_range(). 2026-08-27 15:10:38 -06:00
Behdad Esfahbod 68641b2aed [limits] Consolidate rendering work budgets
Use HB_BUDGET_GLYPH as the common finite default for VARC and the
in-house draw and paint backends. Raster paint retains its surface-size
scaling so large targets still permit a small number of full passes.

Remove redundant exhaustion checks around hb_budget_spend(). A spend
that lands exactly on zero succeeds; only a negative live value latches
exhaustion. Apply the same boundary consistently to postcharged
renderer work and cover the next positive-cost attempt in tests.

The full Meson suite passes, as do the full TSan suite and the three
rendering regression seeds under ASan and UBSan.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 18:34:31 -06:00
Behdad Esfahbod 7eab9be024 [cairo] Skip external lock inversion under TSan
Cairo's user-font rendering acquires two internal locks in both
orders. The new nested-rendering regression test exposes that existing
lock-order inversion under ThreadSanitizer, including when run against
an unmodified HarfBuzz.

Keep the end-to-end test enabled normally, but skip that workload when
compiled with TSan instead of suppressing deadlock detection globally.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 18:34:02 -06:00
Behdad Esfahbod 15a523bd87 [CFF] Test nested outline budget charges
Exercise CFF work accounting through the public draw-budget callbacks.
Use lower bounds above each parent charstring's flat operator cost so the
CFF1 assertion covers both seac children and the CFF2 assertion covers
proportional blend work.

Keep the interpreter's local cost type consistent with the unsigned spend
interface.

Tests: meson test -C build (275/275 passed)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 17:54:45 -06:00
Behdad Esfahbod 8f3ab5ab87 [cairo] Share work across nested glyph rendering
Cairo's draw callbacks previously received a raw cairo_t, so paint-driven
outline traversals could not share a renderer budget.  Nested color glyphs
also construct fresh HarfBuzz paint contexts while populating the same
scaled-font glyph cache.

Attach a finite budget owner to the scaled font and let each draw/paint
context borrow it.  Recharge only for the outermost glyph callback, expose
the budget callbacks on both function sets, and charge emitted path and
nested color-glyph work.  Exercise the original vector timeout seed through
the Cairo user-font renderer.

Tests: meson test -C build (275/275 passed)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 17:51:34 -06:00
Behdad Esfahbod a38e2831c0 [draw] Forward budgets through synthetic outlines
Synthetic slant and emboldening first render into an outline recorder.
That adapter previously hid the renderer's live budget, allowing the
underlying outline traversal to use a fresh per-glyph allowance.

Forward the destination draw data's remaining-budget pointer through
the recorder.  Add a regression test proving an exhausted synthetic
draw fails against the caller's budget.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 17:42:23 -06:00
Behdad Esfahbod 5be2bffb7c [VARC] Thread the renderer work budget
Make VARC record traversal, variation processing, and all glyf/CFF
leaves consume the renderer-owned live counter. Forward that counter
through the transforming pen and make leaf traversal obtain it from
the active draw session.

Keep a finite standalone allowance for extents, charge records even
when conditions suppress their components, and add public-callback
coverage for cumulative depletion and exhaustion.

Tests: meson test -C build (274/274 passed)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 17:39:46 -06:00
Behdad Esfahbod 9a424f1808 [gpu] Share rendering work budgets
Store finite budget policy and live state on GPU draw and paint
contexts. Charge generated curves against the draw context and make
paint-owned scratch draws borrow the paint session's counter.

Propagate the same live counter through both identity clip extraction
and the transforming forwarding pen. Preserve policy across clear and
restore DEFAULT on reset, with focused lifecycle and propagation tests.

The ClusterFuzz GPU timeout seed completes in 0.11 seconds in the
optimized build.

Tests: meson test -C build (273/273 passed)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 17:28:03 -06:00
Behdad Esfahbod c7797701c0 [raster] Share rendering work budgets
Store budget policy and live state on raster draw and paint contexts.
Make outline traversal and curve flattening borrow the paint session's
live counter, while standalone draw keeps its own finite session counter.

Preserve raster's dynamic surface-sized default, resolving it only after
initialization and never replacing concrete or unlimited client policy.
Recharge on clear and restore DEFAULT on reset. Add lifecycle and lazy
default coverage.

Tests: meson test -C build (273/273 passed)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 17:22:05 -06:00
Behdad Esfahbod 472c3e0fd3 [draw] Add rendering work-budget API
Expose budget policy and remaining-work callbacks on draw and paint function
objects.  The public setters clamp invalid negative caps, distinguish finite
defaults from explicit unlimited operation, and report whether a backend
participates in accounting.

Let draw sessions borrow the live counter owned by draw_data.  OpenType glyf
and CFF traversal then debit the same counter in place, while unsupported
backends retain a finite per-glyph fallback.  Forward budget access through
the parent-font draw adaptor.

Document the new API and cover nil, default, unlimited, clamped, concrete,
and live-depletion behavior.

Tests: meson test -C build (272/272 passed)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 17:11:21 -06:00
Behdad Esfahbod 4981ead8f9 [subset] Prune VARC auxiliary data 2026-08-25 15:32:56 -06:00
Behdad Esfahbod cf7f500d65 [subset] Support VARC tables 2026-08-25 14:47:33 -06:00
ff217d3039 [graphite2] Fix cluster values when the buffer was reversed (#6156)
When the requested direction differs from the script's horizontal
direction, the Graphite2 shaper reverses the buffer before segmenting.
Input cluster values then decrease along the buffer, so assigning each
Graphite group the cluster of its base character can leave earlier
characters outside the resulting cluster map.

Preserve the source span of every Graphite glyph while constructing the
output. At monotone cluster levels, seed each glyph from the minimum
endpoint of that span and use merge_clusters() over each Graphite output
range. Keep the historical base-character behavior at non-monotone
levels.

HarfBuzz cluster values are opaque client labels and can be repeated or
gapped. Merging them can therefore coalesce multiple Graphite layout
groups. Preserve the Graphite group index separately for positioning so
every group's advance is emitted even when its HarfBuzz cluster was
merged. Validate Graphite slot source bounds before indexing the input.

Add shape regressions using a subset of Awami Nastaliq and an API test
with repeated input clusters. The latter used to merge the output
clusters correctly but drop an entire layout-group advance, reducing
the total from 3200 to 1269.

Tested with:
meson test -C build test-graphite2
meson test -C build --suite shape
meson test -C build



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

Co-authored-by: Michael Brown <michael.brown@rubicotech.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-22 12:48:13 -06:00
Behdad Esfahbod 5e75e91ebf [set] Add hb_set_intersects API
Expose the exact set-intersection query so callers can test whether two
sets have any elements in common without copying and mutating a set.
The implementation handles inverted sets through the internal helper.

Document the new API with its release placeholder, add it to the docs
section index, and cover regular and inverted set combinations.

Tested with the full Meson test suite (270/270 passed).

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-19 16:00:05 -06:00
nussaibah shaikh fde0fd8592 Merge pull request #6164 from Nussu06/gpu-clamp-i16-nan-guard
[gpu] handle NaN in clamp_i16 before int16 cast
2026-08-17 13:50:20 -06:00
Behdad Esfahbod 886fc1e645 Merge pull request #6154 from harfbuzz/fix/saturating-position-math
[position] Saturate position arithmetic
2026-08-16 13:19:21 -06:00
Behdad Esfahbod 703e2d1441 [subset] Handle invalid avar2 delta-set indices (#6152)
The subset planner rejected out-of-range avar2 delta-set indices even
though runtime evaluation treats them as zero. The avar2 rewrite also
carried those invalid indices into its output mapping.

Validate delta-set indices centrally and normalize invalid mappings to
NO_VARIATION_INDEX during planning and rewriting. Add coverage for an
empty non-NULL VarStore with an implicit index map.

Tests: meson test -C build

Assisted-by: OpenAI Codex
2026-08-15 11:43:02 -06:00
Behdad Esfahbod 87440579f9 Fix a couple of warnings 2026-08-13 08:43:50 -06:00