Commit Graph
273 Commits
Author SHA1 Message Date
Khaled Hosny 3df40d9b98 15.1.0 2026-11-04 23:03:36 +02:00
Eugenio Depalo 2db1b3ab9d [buffer] Add deserializers with byte offsets (#6552)
* [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
2026-11-04 12:05:35 -06:00
Khaled Hosny 35f656a1a2 15.0.0 2026-10-22 19:31:32 +03: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 1bf17d7295 [subset] Allow instancing axes unrelated to VARC (#6265)
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
2026-10-10 04:04:32 -06:00
Khaled Hosny c7a7457b73 14.6.0 2026-10-05 23:11:34 +03:00
Khaled Hosny eb033319fc 14.5.1 2026-10-01 02:34:38 +03:00
Khaled Hosny 863d3f7787 14.5.0 2026-09-21 00:41:07 +03: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 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 148fcb3c79 [NEWS] Restore the trailing blank line at end of file
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>
2026-08-27 15:42:37 -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
Khaled Hosny 36cb489cb0 14.4.0 2026-08-26 22:27:05 +03:00
Behdad Esfahbod cf7f500d65 [subset] Support VARC tables 2026-08-25 14:47:33 -06:00
Khaled Hosny ab5ecbb839 14.3.1 2026-08-13 01:49:23 +03:00
Khaled Hosny 4c2aa80467 14.3.0 2026-07-31 17:49:40 +03:00
Khaled Hosny 56feae4035 14.2.1 2026-06-02 14:30:59 +03:00
Khaled Hosny b0ffab42d4 14.2.0 2026-04-20 05:10:48 +02:00
Behdad Esfahbod 7a7fbdd173 [NEWS] Typos 2026-04-19 13:08:19 -06:00
Behdad Esfahbod e5755c8274 [raster/vector] Address review feedback 2026-04-19 12:52:17 -06:00
Behdad Esfahbod 750df72e2b [NEWS/docs] Update for vector API changes
- 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>
2026-04-18 11:36:05 -06:00
Behdad Esfahbod 13cac4f57e [NEWS] Document GPU shader API changes
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>
2026-04-17 15:18:58 -06:00
Behdad Esfahbod 7c54a401c0 [vector-draw] Add foreground/background color API
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>
2026-04-16 19:13:33 -06:00
Behdad Esfahbod 533246778a [NEWS] Nit 2026-04-16 18:56:34 -06:00
Behdad Esfahbod d774a9a4e2 [vector/raster] Add set_background / get_background API
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>
2026-04-16 18:22:07 -06:00
Behdad EsfahbodandClaude Opus 4.6 88dc4c9926 NEWS: Document get_funcs signature change and draw helpers
* 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>
2026-04-16 16:22:14 -06:00
Behdad EsfahbodandClaude Opus 4.6 2b732039d1 NEWS: Document arbitrary-path clip paint API
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>
2026-04-16 16:18:20 -06:00
Behdad Esfahbod 390ec06fa7 Merge pull request #5931 from harfbuzz/paint_or_fails
[vector/raster/gpu] Add *_glyph_or_fail() variants across all three
2026-04-16 16:13:05 -06:00
Behdad Esfahbod 64d2c7311b [paint] Promote reduce_anchors / normalize_color_line / sweep_tiles to public (#5932)
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>
2026-04-16 14:56:15 -06:00
Behdad Esfahbod 98f3a42ee2 [vector/raster/gpu] Add *_glyph_or_fail() variants across all three
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>
2026-04-16 00:36:37 -06:00
Behdad Esfahbod c559eb8bc9 [vector] NEWS: document hb_vector_*_flat removal
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>
2026-04-15 15:07:11 -06:00
Behdad Esfahbod addaafd255 [vector] Rename svg_{set,get}_prefix to {set,get}_svg_prefix
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>
2026-04-15 15:07:05 -06:00
Behdad Esfahbod 32fbe980ad [NEWS] Attribution 2026-04-14 22:08:06 -06:00
Behdad Esfahbod cb834b17b5 [NEWS] Draft entry for upcoming release
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>
2026-04-14 21:35:54 -06:00
Behdad Esfahbod 7c7b1756c1 [gpu] Support 3 nested glyph clips per layer
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>
2026-04-14 19:25:58 -06:00
Behdad Esfahbod f6cd414c9f [gpu] Add hb_gpu_paint_set_scale / _get_scale
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>
2026-04-14 19:08:03 -06:00
Behdad Esfahbod b38c5189df [gpu] Detect paint-encoder limits, fail rather than misrender
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>
2026-04-14 18:45:35 -06:00
Behdad Esfahbod 157e5111b3 [gpu] Add tests + benchmark for hb_gpu_paint, NEWS draft
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>
2026-04-14 16:00:51 -06:00
Khaled Hosny cfb70b0b91 14.1.0 2026-04-04 20:31:18 +02:00
Khaled Hosny da69b6585c 14.0.0 2026-04-01 14:54:05 +02:00
Behdad EsfahbodandClaude Opus 4.6 b26f1a8bc1 [docs] Rename "Core libraries" to "Libraries", update NEWS
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 20:48:15 -06:00
Behdad EsfahbodandClaude Opus 4.6 541ed9ab3f [docs] Add NEWS entry for 14.0.0
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 20:13:37 -06:00
Khaled Hosny 6f4c5cec30 13.2.1 2026-03-19 16:09:56 +02:00
Khaled Hosny 5ad3909af4 13.2.0 2026-03-19 00:45:24 +02:00
Khaled Hosny 70b812d8d2 13.1.1 2026-03-13 03:08:03 +02:00
Khaled Hosny 68d19d6964 13.1.0 2026-03-11 04:01:41 +02:00
Khaled Hosny c298b921d6 13.0.1 2026-03-07 20:25:13 +02:00