* [buffer] Add deserializers with byte offsets
Buffer deserializers return a pointer into caller-owned input. GIR
describes it as an owned UTF-8 string, so bindings can free an
interior pointer or read beyond explicitly sized input.
Add _with_offset variants with bounded byte-array inputs and optional
byte counts. Preserve the existing return values and partial buffer
contents, including on failure. Cross-check both variants against the
existing deserializers in the buffer API tests.
Testing: full Meson suite, buffer tests under Valgrind, and GIR and
PyGObject checks.
Fixes: #6446
Assisted-by: OpenAI Codex
* [buffer] Rename new deserializers to use 2 suffix
Use the established 2 suffix for the new buffer deserializers,
following hb_shape_plan_create2(). Update API docs, NEWS, and tests.
Testing: full Meson suite, generated GIR, and PyGObject checks.
Assisted-by: OpenAI Codex
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
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
Replace the blanket VARC instancing rejection with validation of the
axes referenced by retained components, variation regions, and nested
conditions. Remap those indices when unrelated axes are removed, while
keeping passthrough VARC incompatible with instancing.
Preserve component-internal variation data during avar2 instancing by
avoiding culling based on font-level reachable ranges. Add drawing
comparisons and rejection tests with reproducible fixtures, including
hidden component axes and non-default unrelated-axis pins.
Serialize sparse-region axis references using the revised VARC format.
Regenerate the fixtures without changing their logical VARC contents or
other table bytes, apart from the head checksum adjustment.
Validation: meson test -C build (283 passed); subset suite (130 passed);
C++11 compile checks with HB_NO_VAR and HB_NO_VAR_COMPOSITES.
Assisted-by: Codex
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>
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>
Keep the rendering-work-budget NEWS edit to its intended additions and
drop the incidental end-of-file whitespace change.
Assisted-by: Claude <noreply@anthropic.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>
- Remove draw svg_prefix from New API list and sections.txt
- Document pen_x/pen_y removal, dedup removal, _glyph
simplification in the Vector library section
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Coverage out parameter, premultiplied gradient interpolation,
foreground alpha fix, and the shader signature change.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add hb_vector_draw_set_{foreground,background}() and getters.
SVG: foreground wraps body in <g fill="rgb(...)">; background
emits a <rect> covering the viewBox before content.
PDF: foreground sets fill color via rg operator before glyph
content; background emits a filled rect at the start of the
content stream.
Default: foreground opaque black, background transparent.
Wire both into the hb-vector CLI util alongside the paint
equivalents. Remove the old util-side emit_background_rect.
Regenerated vector test expected outputs.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add hb_vector_paint_set_background() / get_background() and
hb_raster_paint_set_background() / get_background().
For vector: if set to a non-transparent color, the SVG renderer
emits a <rect> covering the viewBox before glyph content, and
the PDF renderer prepends a filled rectangle to the content
stream. Both support semi-transparent backgrounds (SVG via
fill-opacity, PDF via ExtGState /ca).
For raster: the root surface is pre-filled with the background
color before glyph compositing begins.
Default is transparent (no background emitted).
The hb-vector CLI util wires --background to the new API.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add the six raster/vector/gpu draw+paint get_funcs
signature change to "Changed API, general".
* List hb_vector_draw_get_format / hb_vector_paint_get_format
under "New API, Vector library".
* Add a "New API, Draw" section for the new shape helpers
(hb_draw_line, hb_draw_rectangle, hb_draw_circle) and the
hb_draw_line_cap_t / HB_DRAW_LINE_CAP_* constants that
came in earlier this dev cycle but weren't yet listed.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add the push_clip_path_start / _end additions under a new
"Paint API" bullet and list the six new public symbols
(two entry points, two setters, two func_t typedefs) in
the "New API, Paint" block.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Every COLRv1 renderer ends up rewriting these three helpers;
they now live on hb-paint.h so Skia, FreeType-SVG, and other
downstream paint-API implementers can consume a single
canonical implementation.
* hb_paint_reduce_linear_anchors() -- 3-anchor (P0, P1, P2)
to 2-point axis projection.
* hb_paint_normalize_color_line() -- sort + rescale stops
to [0, 1]; returns (min, max) so callers can shift
gradient geometry to match.
* hb_paint_sweep_gradient_tiles() + matching
hb_paint_sweep_gradient_tile_func_t callback typedef --
iterates the full 0..2π sweep produced by a color-stop
list, invoking the callback once per (start, end)
angular segment. Handles PAD / REPEAT / REFLECT.
Implementation moves from src/hb-paint.hh (private, static
inline) to src/hb-paint.cc (public, HB_EXTERN). The sweep
tiler loses its C++ template/lambda flavor and grows a
user_data parameter alongside the function-pointer callback;
the three in-tree callers (cairo, vector-paint, vector-paint-pdf)
now use standalone trampoline functions + context structs
instead of captured lambdas.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/5928
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Consolidate the {vector,raster,gpu}_{draw,paint}_glyph APIs
to match the hb_font_{draw,paint}_glyph / _or_fail pattern:
* Each existing *_glyph() public function now returns void.
For the draw variants this is purely a return-value drop.
For the paint variants the void entry additionally gains a
synthesize fallback for non-color glyphs (calls
hb_font_paint_glyph instead of _or_fail) so a mono glyph
still produces output via a foreground-colored outline.
* New *_glyph_or_fail() variants return hb_bool_t, reporting
exactly what hb_font_{draw,paint}_glyph_or_fail() would.
Callers that care about distinguishing color paint from
synthesized outline now have a clean boolean signal.
Refactors the internal impls behind a shared static helper
parameterised by a `fallible` flag; the two public entries
delegate, passing true (for _or_fail) or false (for the void
alias).
For GPU specifically, paint_glyph_or_fail no longer folds the
encoder's unsupported flag into its return -- that state was
always better reported from hb_gpu_paint_encode() (which
returns NULL), and conflating the two prevented callers from
telling "font has no paint data" from "encoder hit a limit".
While in there, remove a dead branch at the end of
hb_vector_paint_glyph's SVG case (both inner blocks had
already returned; the tail was unreachable).
Updates docs/harfbuzz-sections.txt with the six new symbols
and the NEWS note with the Changed API callouts. Updates
in-tree callers (hb-vector-svg-all, hb-raster-all, test-gpu,
util/vector-output.hh) to the _or_fail variants where they
previously read the return value.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/5926
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PR #5927 dropped the flat-mode API. Add a Removed API entry,
cross-link it to the svg-prefix replacement bullet, and clean up
the now-stale Changed/New API entries that mentioned set_flat.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verb-then-thing matches the rest of the hb-vector setter/getter
naming (set_precision, set_palette, etc.). Update the renamed
internal references and the NEWS / harfbuzz-sections.txt entries
to match.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cover since 14.1.0: GPU paint renderer (hb_gpu_paint_t), Vector
PDF output backend, SVG-in-OT glyph-source removal from Raster
and Vector, cross-subsystem _clear() companions and getter
companions, --output-file flag for hb-gpu, and fuzzer fixes.
List new / removed / changed API grouped by library.
Assisted-by: Claude <noreply@anthropic.com>
Replace the single-slot pending_clip / pending_clip_glyph /
pending_clip_font / pending_clip_transform fields with a stack of
up to HB_GPU_PAINT_MAX_CLIP_DEPTH (3) clips. push_clip_glyph
appends; pop_clip pops; depth > 3 sets `unsupported`.
LAYER_SOLID and LAYER_GRADIENT ops grow from 2 to 3 texels:
texel 0: (op_type, flags, clip1_hi, clip1_lo)
texel 1: (clip2_hi, clip2_lo, clip3_hi, clip3_lo)
texel 2: color (SOLID) or grad meta (GRADIENT)
The existing flags slot (i16) gains:
bit 0 IS_FOREGROUND (SOLID only -- was already there)
bit 8 HAS_CLIP2 (new)
bit 9 HAS_CLIP3 (new)
For GRADIENT the gradient subtype lives in bits 0..7.
Shader: nest the HAS_CLIP2 / HAS_CLIP3 checks (HAS_CLIP3 implies
HAS_CLIP2) so single-clip layers pay only one branch, two-clip
layers pay one extra slug call, three-clip layers pay two extra.
On Noto-COLRv1 the bench is unchanged (~320 fps with the emoji
text the user benches against), within noise of the depth-1
baseline -- the extra branches don't fire on most layers.
Ports across all four shader languages (GLSL, MSL, HLSL, WGSL).
NEWS: limitation entry updated to "up to 3 levels are intersected
exactly; deeper nests set unsupported".
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Mirror the draw API. hb_gpu_paint_t already had x_scale / y_scale
fields and hb_gpu_paint_glyph() set them directly, but no public
setter / getter -- callers that want to use the paint funcs
without going through paint_glyph had no way to wire the scale.
Add the public setters / getters and route paint_glyph through
them, matching hb_gpu_draw_glyph's pattern. Document on both
draw and paint that the convenience wrappers call _set_scale.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Paint encoder used to push past several limits and produce a blob
that wraps an int16, overflows the shader's group stack, or skips
unsupported callbacks entirely. Detect each:
- num_ops > 32767 (the i16 blob header field's range): set
paint->unsupported in every emit path.
- group depth > HB_GPU_PAINT_MAX_GROUP_DEPTH (4 -- matches the
fragment shader's HB_GPU_PAINT_GROUP_DEPTH): set unsupported
in push_group; mirror the symmetric pop guard.
- PaintImage: register an `image` callback that sets unsupported
(the slug+gradient encoder can't represent raster images).
push_clip_rectangle is intentionally NOT trapped -- the encoder
silently ignores it; rendered output is wider than the rectangle
asks but doesn't fail.
Nested PaintGlyph clips still silently override the outer clip
(only depth 1 is faithfully stored); follow-up commit will lift
this to depth 2.
Document all of the above in NEWS, and relax the COLR test to
tolerate a font where every glyph trips one of these limits.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
test/api/test-gpu: extends the existing draw test suite with
paint counterparts -- create/destroy, get_funcs singleton,
shader_source for all four langs, empty encode returns nullptr,
encode of a monochrome glyph (synthesized single-layer fallback),
encode of a real COLRv1 glyph (test_glyphs-glyf_colr_1.ttf,
scanning for a glyph our encoder fully supports), auto-clear on
encode, reset wipes config, recycle_blob roundtrip.
perf/benchmark-gpu: add BM_GpuPaintEncode parallel to
BM_GpuDrawEncode (renamed from BM_GpuEncode for symmetry) so the
two paths can be compared on the same fonts.
NEWS: draft entry under "leading to NEXT (REPLACEME)" listing the
new hb_gpu_paint_* API surface and the recent GPU library changes
(--draw / --paint flags, gradient inverse-transform). Release
manager will fold this into the actual release section.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>