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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
Widen position differences before taking their absolute value. This
avoids signed overflow when hb_buffer_diff() compares positions near
opposite ends of the hb_position_t range.
Add an API regression covering INT32_MIN versus INT32_MAX.
Tested with: meson test -C build --print-errorlogs
Assisted-by: OpenAI Codex
Mark-to-mark attachment can accumulate an unbounded cross-direction
offset. Clamp anchor conversion and saturate the immediate addition so
overlong mark clusters stop at hb_position_t limits instead of invoking
signed-overflow undefined behavior.
Add a regression for issue #6151 using 35,000 combining marks.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
SubsetGlyph stores borrowed slices into the source glyf table. Faces
created with a table callback may return a fresh blob on each request,
so destroying the population accelerator left those slices dangling
before they were serialized.
Retain the exact glyf blob through serialization. Exercise this path
by making the existing create-for-tables test return copied blobs.
Reported by WinD39 - Huynh Dinh Vu.
Fixes: https://issues.chromium.org/issues/536584255
Assisted-by: OpenAI Codex <codex@openai.com>
The fragment shader picks one horizontal and one vertical band from
the fragment position and walks only that band's curve list, so a
curve must be listed in every band its bounding box reaches into.
The encoder computed those bounding boxes from the unquantized
control points, but the shader only ever sees the coordinates after
they are rounded to quarter font units. When rounding pushed a
curve's extreme across a band boundary, the curve was left out of the
band it now reached into. Fragments landing in that sliver never saw
the curve, so their winding number was off by one and the pixel came
out empty in the middle of a filled area -- a thin black line through
the glyph, appearing and disappearing as the font size moves the
pixel grid.
The rounding error is at most an eighth of a font unit, so this is
invisible for an integer-coordinate glyph rendered at its own upem.
It gets easy to hit when the coordinates are fractional: CFF glyphs
after cu2qu, or any font whose hb_font_t scale is not its upem. With
hb_font_set_scale(font, 163, 163), as in issue #6131, more than half
of the glyphs of util/gpu/default-font.ttf had at least one band the
shader could reach but that did not list the curve.
Compute the bounds (and the is_horizontal/is_vertical tests) from the
quantized control points instead, and widen the band range by 1/1024
of a band so that the double arithmetic here cannot disagree with the
shader's float32 band index right at a boundary.
Verified with a CPU port of _hb_gpu_slug_single: comparing the banded
lookup against a walk over every curve of the glyph, at sizes 39, 47
and 107 with scale 163, default-font.ttf had 27 wrong pixels before
and none after. Encoded atlas size grows by 0.12%.
Adds test_encode_band_membership, which checks the invariant directly
on the encoded blob and fails before this change.
Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
For fetching various bit fields scattered around OpenType tables. Many of
these are legacy or unreliable, but applications might need them for
various legacy reasons.
Fixes https://github.com/harfbuzz/harfbuzz/issues/1920
* [test/fuzzing] Skip hb-depend-closure-parity without GLib
It depends on GLib unlike the other fuzzers.
* [ci] Build the msan bot without external dependencies
We don’t care about msan errors in code that is not ours, and some
libraries like GLib are not built with memory sanitizers in mind.
* [ci] Don't pipe sanitizer test output
The pipe was masking meson exit status, and it was redundant anyway
since the sanitizer output is is already symbolized and demangled.
* [COLR] Fix integer overflow in get_extents
Use to_glyph_extents(), which guards against this.
Update test expectation since we now round instead of truncate.
* [raster] clamp coordinates before converting to int
the transformed glyph extents and the flattened segment endpoints are floats derived from int32 inputs and can land far outside the int range, so the conversions were undefined and the extent subtraction overflowed on top of that. saturate through a shared helper and widen the subtraction.
* [raster] generalize int32 saturating cast into hb_clamp_to<>
Move the raster-local hb_raster_clamp_to_int32 helper into hb-algs.hh
as a generic hb_clamp_to<T> that saturates a floating-point value to
the range of any integer type, and use hb_clamp_to<int32_t> at the
three raster call sites.
Signed-off-by: nussaiba shaikh <nussaibah@bugqore.com>
---------
Signed-off-by: nussaiba shaikh <nussaibah@bugqore.com>
hb_ot_tag_to_language returns NULL for HB_OT_TAG_DEFAULT_LANGUAGE, and hb_language_to_string returns NULL for it, so the script-suffix path called strlen on a NULL pointer whenever the primary script tag did not match the input. Skip the suffix construction when there is no base language string and leave the default (NULL) language in place.
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
push_clip_path_end wrote clip_stack[clip_depth] without the
HB_GPU_PAINT_MAX_CLIP_DEPTH check that push_clip_glyph and
push_clip_path_start both apply. clip_depth can be pushed past
the fixed 3-entry clip_stack, so closing a clip path while the
stack is full writes a pending_clip_t past the array. Guard it
like the sibling clip pushes.
The range test guarding the bilinear sampler is comparison-based, so NaN
coordinates pass it and reach (int) floorf() in
hb_raster_sample_bilinear_premul, where only x1/y1 are clamped. The
determinant guard has the same shape, so a transform that overflows to
infinity is accepted and 1/inf turns inf * 0 into NaN.
The dispatch wrapper handed the callback user_data->push_clip_glyph
instead of user_data->color_glyph, so a client registering both
callbacks with different contexts got the wrong pointer on every
COLR glyph.