Commit Graph
21218 Commits
Author SHA1 Message Date
Behdad Esfahbod dd0cefa53d [vector] Rename hb_buf_t → hb_vector_buf_t
Consistent with HarfBuzz naming: hb_vector_* prefix for
all vector library types.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:50:20 -06:00
Behdad Esfahbod 1b8d810501 [vector] Move scale_precision to hb_buf_t method
Replace hb_vector_scale_precision() free function with
hb_buf_t::scale_precision() method.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:49:11 -06:00
Behdad Esfahbod d77a910d8e [vector] Merge hb-vector-buf.cc into hb-vector.cc
The decimal point helper was the only content in the separate
.cc file.  Move it into hb-vector.cc and remove the extra
compilation unit.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:48:06 -06:00
Behdad Esfahbod aa09dd51d1 [vector] Replace hb-vector-utils with hb-vector-buf
Move all buffer functionality into hb_buf_t methods in
hb-vector-buf.hh.  Remove all hb_buf_append_* free functions.

hb_buf_t now owns: append_len, append_c, append_str,
append_unsigned, append_hex_byte, append_num,
append_svg_color, append_base64.

Delete hb-vector-utils.hh.  Rename hb-vector-utils.cc →
hb-vector-buf.cc (keeps only hb_vector_decimal_point_get).

Remove duplicate free functions from hb-vector-svg.hh
(hb_buf_append_str, _unsigned, _hex_byte, _base64, _color).

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:46:45 -06:00
Behdad Esfahbod b5b7331905 [vector] Move append_svg_color and append_base64 to hb_buf_t
Last free function calls in vector code converted to methods.
Zero hb_buf_append_* free function calls remain.

Also fix stale comment referencing old function name.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:42:00 -06:00
Behdad Esfahbod d1cb376123 [vector] Convert remaining free function calls to hb_buf_t methods
Convert hb-vector-svg.hh and hb-vector-path.cc to use
hb_buf_t methods instead of hb_buf_append_* free functions.

Add append_hex_byte method to hb_buf_t (avoids static local
symbol leak from inline method).

Remove hb_buf_append_hex_byte free function from svg.hh
(now a method).

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:38:51 -06:00
Behdad Esfahbod 454ea6ab66 [vector] Migrate to hb_buf_t methods; rename hb-vector-utils
Replace all hb_vector_t<char> with hb_buf_t throughout the
vector code — struct fields, local variables, function
parameters.  Convert hb_buf_append_* free function calls
to hb_buf_t method calls (.append_str, .append_num,
.append_c, .append_len, .append_unsigned).

Drop the keep_nonzero parameter from append_num — callers
that need it already use hb_vector_scale_precision for
sufficient precision.

Rename hb-vector-svg-utils.{cc,hh} → hb-vector-utils.{cc,hh}
since hb_buf_t and the numeric helpers are format-agnostic.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:33:24 -06:00
Behdad Esfahbod 282e55dfa3 [vector-paint-pdf] Use paint's scratch path instead of stack draw_t
hb_pdf_emit_glyph_path was allocating a full hb_vector_draw_t
on the stack (with its own heap-allocated buffers) just to
emit one glyph path.  Use paint->path (the existing scratch
buffer) with the PDF path sink directly — no temporary draw
context, no extra allocations.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:22:03 -06:00
Behdad Esfahbod 3a01d263d6 [vector] Add hb_buf_t; move precision to the buffer
Add hb_buf_t inheriting from hb_vector_t<char> with:
- precision field (default 2)
- append_num, append_c, append_str, append_len, append_unsigned
  convenience methods

Convert defs/body/path in both hb_vector_draw_t and
hb_vector_paint_t from hb_vector_t<char> to hb_buf_t.

Remove the standalone precision field from both structs;
set_precision/get_precision are now methods that propagate
to the buffers.  C API functions are thin wrappers.

Callers can still use the old free functions (hb_buf_t
IS-A hb_vector_t<char>).  The new methods allow gradual
migration.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:19:27 -06:00
Behdad Esfahbod b513aaace9 [vector-paint] Flush cache on foreground/palette/custom changes
The SVG color glyph cache keys on (glyph, palette, foreground)
but changing these setters didn't invalidate the cache, so
stale rendered color glyphs could be reused.

Call changed() from set_foreground, set_palette,
set_custom_palette_color, and clear_custom_palette_colors
when the value actually changes.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:00:38 -06:00
Behdad Esfahbod 9fc44028fe Merge pull request #5940 from harfbuzz/vector-split
Split off vector SVG paint into its own file
2026-04-16 23:54:55 -06:00
Behdad Esfahbod c3c51a6150 [vector-draw] Split draw funcs into per-format SVG/PDF sets
Replace the single unified draw callbacks (which switched on
format in every callback) with separate SVG and PDF callback
sets, matching the path sink split pattern.

SVG: straight-line M/L/Q/C/Z operators with comma separators.
PDF: straight-line m/l/c/h operators with space separators.
PDF omits quadratic_to — null fallback auto-promotes to cubic.

Also split append_xy and flush_path into format-specific
methods (append_xy_svg/pdf, flush_path_svg/pdf) in the .hh.

hb_vector_draw_funcs_get() now takes format and dispatches.
hb_vector_draw_get_funcs() passes draw->format through.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:49:37 -06:00
Behdad Esfahbod cbb0aeadb9 [vector] Split SVG paint backend into hb-vector-paint-svg.cc
Extract all SVG-specific paint callbacks (push_transform,
push_clip_glyph, push_clip_rectangle, push_clip_path,
pop_clip, color, image, gradients, push/pop_group,
color_glyph, custom_palette_color) and the SVG render
function into a new file, matching the existing PDF split.

hb-vector-paint.cc retains the public API, format dispatch,
glyph_impl, clear, and render.

Also:
- Move ensure_initialized to a method on hb_vector_paint_t
- Move hb_vector_color_glyph_cache_key helper to .hh
- Rename hb_vector_paint_funcs_get → hb_vector_paint_svg_funcs_get

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:40:51 -06:00
Behdad Esfahbod d4b0a18d4d Merge pull request #5939 from harfbuzz/vector-raster-set-background
[vector/raster] Set foreground/background API where it was missing
2026-04-16 23:39:19 -06:00
Behdad Esfahbod 9161a689f6 [vector] Increase paint fill/sweep radius from 32767 to 1000000
The SVG and PDF paint backends use large clipped rectangles
to fill solid colors and gradient backgrounds.  The old
constant 32767 was sized for upem-space coordinates (~2048
max).  After the pixel-space change, coordinates can be in
font-scale (upem * SCALE, e.g. 131072 for a 2048-upem font
at SCALE=64).  Values above 32767 fell outside the fill
rect, causing COLRv0 glyph layers to be clipped at the top.

Bump all instances to 1000000 as a bandaid; proper fix is
to emit paint coordinates in output-space.

Regenerated vector test expected outputs.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:07:55 -06:00
Behdad Esfahbod b487515093 [util/gpu] Fix color auto-detect for COLRv0 fonts
The GPU util's auto-detect only checked hb_ot_color_has_paint
(COLRv1).  COLRv0 fonts like BungeeTint have layers but no
paint tree, so they were incorrectly routed to the mono draw
path.

Add hb_ot_color_has_layers and hb_ot_color_has_png to the
check, matching the raster and vector utils.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 22:48:01 -06:00
Behdad Esfahbod 8793feb5cb [raster-paint] Fix alignment cast in background fill
Use hb_memcpy instead of casting uint8_t* to uint32_t*
to avoid -Wcast-align on platforms with strict alignment.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 22:46:06 -06:00
Behdad Esfahbod 817d7342c8 [util/vector] Remove all SVG post-processing and CSS var machinery
The paint SVG backend bakes all colors directly — no CSS
var(--hb-...) references remain in the output.  So the util's
SVG parser, var resolver, palette cache, and slice_svg
infrastructure are all dead code.

write_blob is now just fwrite.

Removes ~340 lines: slice_svg, write_slice_resolving_palette_vars,
parse_var_color_expr, find_next_var_expr, find_matching_paren,
emit_css_color, lookup_palette_color, init_palette_color_cache,
skip_ascii_ws, trim_ascii_ws_right, parsed_var_color_expr_t,
and associated palette cache state.

Regenerated vector test expected outputs (color font SVGs
now emit directly without var resolution pass).

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 19:37:22 -06:00
Behdad Esfahbod 8b324b69a7 [util/vector] Remove SVG post-processing; write draw blobs directly
Now that the draw library handles per-glyph foreground fills
and background rects, the util no longer needs to parse and
re-emit SVG for draw blobs.  Draw blobs are written directly
to the output file, same as PDF.

Paint SVG still needs var(--hb-...) resolution, so paint
blobs go through the existing write_slice_resolving_palette_vars
path.

Removes ~120 lines: emit_fill_group_open/close,
emit_draw_body_with_palette, emit_fill_stroke_attrs_for_color,
emit_stroke_attrs, and the draw-specific branches in write_blob.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 19:28:16 -06:00
Behdad Esfahbod 2f78333f1b [vector-draw] Extract flush_path helper; apply foreground to all paths
Move the path→body flush logic into draw->flush_path() and
use it everywhere: per-glyph emission, pre-glyph flush, and
render-time final flush.

The helper applies the current foreground color to every
flushed path — both glyph outlines and free-form draw ops
(like show-extents overlays) inherit the foreground that
was set at flush time.

SVG: fill="rgb(...)" on the <path> inside the Y-flip <g>.
PDF: rg operator before each fill.

Regenerated vector test expected outputs.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 19:24:21 -06:00
Behdad Esfahbod 02f38ff8c3 [vector-draw] Per-glyph foreground color
Move foreground fill from a global wrapper (SVG <g fill>,
PDF initial rg) to per-glyph emission:

SVG: each <use> gets fill="rgb(...)" from the current
draw->foreground at emission time.

PDF: each glyph path gets an rg operator before fill.

This lets callers change foreground between glyph calls
(e.g. per-glyph palette cycling) without post-processing.

Wire per-glyph palette cycling for the draw path in the
hb-vector util, matching how paint already does it.

Regenerated vector test expected outputs.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 19:20:13 -06:00
Behdad Esfahbod fbc2da4741 [util/vector] Remove write_combined_svg; simplify render
With --draw/--paint forcing a single mode per render, the
draw and paint paths are mutually exclusive — both can't
produce output in the same render.  Remove the combined
SVG merger and simplify to a single blob output.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 19:15:12 -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 c2f7639c06 [util/vector] Remove util-side emit_background_rect
The util had its own background rect emitter that wrote
directly to the output file.  Now that hb_vector_paint has
set_background, the library handles it.  Remove the
duplicate to avoid double background emission.

Note: the draw path currently has no background support;
this is consistent — mono/draw SVGs are typically embedded
inline where background comes from the container.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 19:04:47 -06:00
Behdad Esfahbod 549f845139 [util] Add --background=none for transparent background
Allows explicitly requesting transparent output without
needing to spell out --background=00000000.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 19:01:34 -06:00
Behdad Esfahbod 533246778a [NEWS] Nit 2026-04-16 18:56:34 -06:00
Behdad Esfahbod bced89d417 Merge pull request #5938 from harfbuzz/vector-pdf-gradient-opacity
Fix ector pdf gradient opacity
2026-04-16 18:54:47 -06:00
Behdad Esfahbod e5e9d7881f Merge branch 'main' into vector-pdf-gradient-opacity 2026-04-16 18:54:39 -06:00
Behdad Esfahbod 38008edb84 Merge pull request #5937 from harfbuzz/vector-scale-changed
Vector scale changed
2026-04-16 18:54:27 -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 Esfahbod 05d5e35f36 [vector-paint-pdf] Add SMask alpha for sweep gradient meshes
Sweep gradients use Coons patch meshes (ShadingType 6) which
encode vertex colors as RGB bytes — no alpha channel.

When any stop has alpha < 255, build a parallel DeviceGray
mesh with the alpha channel and wrap it in a Form XObject
soft mask, same pattern as the linear/radial SMask support.

Also refactor: extract add_shading_by_id for mesh shadings
that are already allocated as objects (they contain streams).

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 18:08:04 -06:00
Behdad Esfahbod 692454636a [vector-paint-pdf] Add SMask support for gradient alpha
PDF DeviceRGB shadings have no alpha channel, so gradient
stops with partial opacity (like emoji blushes fading to
transparent) were rendered as solid color.

When any color stop has alpha < 255, build a parallel
DeviceGray shading for the alpha channel, wrap it in a
Form XObject transparency group, and reference it as a
luminosity soft mask via ExtGState.  The mask is vector
(resolution-independent) — the PDF renderer evaluates
the grayscale function analytically.

Applied to both linear (Type 2) and radial (Type 3)
gradient handlers.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 18:08:04 -06:00
Behdad Esfahbod 05e9bd5099 [vector] Fix aggregate init for hb_vector_path_sink_t
Drop default member initializers for x_scale/y_scale since
C++11/14 doesn't allow aggregate initialization of structs
with default member initializers.  All callers now specify
all four fields explicitly.

Fixes CI build failure.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:50:47 -06:00
Behdad Esfahbod 3c533add46 [vector-paint-pdf] Normalize gradient color stops before emit
The SVG paint backend normalizes color-line stops to [0, 1]
(via hb_paint_normalize_color_line) and adjusts gradient
coordinates accordingly.  The PDF backend was emitting raw
stop offsets and unadjusted coordinates, causing mismatched
gradient geometry — most visibly, radial gradients with a
non-zero focal radius (like emoji blushes) rendered with
r0=0 instead of the correct adjusted inner radius.

Fetch and normalize stops before building the PDF gradient
function, then shift linear/radial coordinates by (mn, mx)
the same way SVG does.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:41:47 -06:00
Behdad Esfahbod c225835410 [vector] Scale clip path coordinates by 1/scale_factor
Clip path coordinates arrive in font-scale (input space) but
need to be in output space for both SVG and PDF.  Add x_scale
and y_scale fields to hb_vector_path_sink_t (default 1.0) and
divide through in the append_xy helpers.

For clip paths, the SVG and PDF paint backends set these to
scale_factor so the emitted coordinates land in output space
without needing a wrapping transform.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:25:24 -06:00
Behdad Esfahbod fbdd39bed7 [util/vector] Fix show-extents stroke width scaling
get_normalized_stroke_width() was gated on stroke_enabled,
returning the raw pixel value (1.0) when --stroke wasn't
active.  The show-extents overlay uses this value regardless
of --stroke, so it got a stroke_width of 1 in font-scale
space (= 0.016 pixels after /SCALE).

Remove the stroke_enabled guard so the pixel → font-scale
conversion always applies.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:21:04 -06:00
Behdad Esfahbod 8ed9cc3ff5 [vector-draw] Fix SVG show-extents: flush path before next glyph
Free-form draw ops (extents overlay rectangles/circles) emitted
via hb_vector_draw_get_funcs() accumulate in draw->path.  But
the SVG glyph emission clears draw->path when drawing each new
glyph outline, discarding the overlay from the previous glyph.

Flush any accumulated path data to body (wrapped in the Y-flip
<g>) before clearing for the next glyph outline, so overlays
for all glyphs survive to the final SVG.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:17:58 -06:00
Behdad Esfahbod d1bb9a595c [util/vector] Drop upem_font; operate in font-scale space
The vector util was creating a separate upem-scaled font clone,
converting all shaping positions from font-scale to upem, and
setting scale_factor to upem/font_size to undo that on emit.

Simplify: use the caller's font directly.  Positions from
shaping are stored as-is (in font-scale = pixel * SCALE).
scale_factor is just SCALE (= 1 << subpixel_bits), so the
lib divides by SCALE on emit to produce pixel-space output.

This removes ~40 lines: the upem_font creation, variation
coord copying, scale_to_upem_x/y helpers, and the complex
upem_per_pixel margin/stroke conversions.  Margin conversion
simplifies from margin * upem * SCALE / x_scale to just
margin * SCALE.

Regenerated vector test expected outputs for the new
coordinate space.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:11:45 -06:00
Behdad Esfahbod 36bf8ecaf2 [vector] Auto-flush glyph caches on font change
Track the font pointer and serial in both hb_vector_draw_t and
hb_vector_paint_t.  On each draw/paint_glyph call, compare the
incoming font against the cached values; if the pointer or
serial changed, call changed() to flush all cached glyph data
(defined_glyphs, defs, color glyph cache, counters).

The cached_font holds a reference so pointer-reuse after
destroy is detected correctly.

This makes context reuse across font changes safe without
requiring callers to call any explicit invalidation API.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:59:19 -06:00
Behdad Esfahbod 80ca5617ff [vector] Split path draw funcs into per-format singletons (#5935)
Replace the single hb_vector_path_draw_funcs_get() (which
dispatched on sink->format via a switch in every callback)
with two format-specific singletons:

  hb_vector_svg_path_draw_funcs_get()
  hb_vector_pdf_path_draw_funcs_get()

Each callback set is straight-line code with no branching.
The PDF set omits the quadratic_to callback, so the
framework's null fallback auto-promotes quadratics to cubics
— removing the manual quad-to-cubic conversion that was
previously hand-rolled in the PDF quadratic_to case.

A convenience dispatcher hb_vector_path_draw_funcs_get(format)
is kept for callers that select at runtime.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:58:56 -06:00
Behdad Esfahbod 68afee084c [vector-paint-pdf] Fix use-of-uninitialized in indexed smask
inflate() with Z_FINISH can return Z_STREAM_END after
decompressing fewer bytes than the expected raw_len when
the IDAT data is truncated or the width/height don't match
the actual compressed payload.  The un-filter loop then
reads uninitialized tail bytes from the raw buffer.

Check that stream.total_out matches raw_len after inflate;
bail out if the sizes disagree.

Fixes: https://oss-fuzz.com/testcase-detail/5190826362994688

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:32:38 -06:00
Behdad Esfahbod 3c5352badd Merge pull request #5933 from harfbuzz/paint-clip-path
Arbitrary clip paths in paint sinks
2026-04-16 16:25:37 -06:00
Behdad Esfahbod 76d543adc9 fixup! [draw][paint] Make get_funcs instance-aware; add get_format 2026-04-16 16:23:32 -06:00
Behdad Esfahbod 6636f042fc Address PR #5933 review feedback
- Reset Since tags to XSince: REPLACEME for changed
  get_funcs signatures (gpu, raster, vector draw+paint).
- Replace (transfer none) annotation syntax with prose in
  clip_path_start docs (hb-paint.cc and hb-paint.h).
- Document that returned draw funcs/data are only valid
  until the matching clip_path_end call, and no other paint
  calls should be made in between.
- Use switch instead of ternary for format in
  hb-vector-path.cc.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:22:42 -06:00
Behdad EsfahbodandClaude Opus 4.6 f7ebd549ed [util/hb-view] --show-extents: foreground color, no per-color split
Drop the bespoke red pen dot + magenta extents rectangle in
favor of a single foreground-color overlay that matches the
look raster, vector, and gpu now produce after their port to
the shared helper: stroked rect around each glyph's ink box,
plus a filled dot at the pen origin.

Cairo's annotation pass stays native (post-glyph drawing
through cairo, not via hb_paint funcs); only the colors and
the dot rendering changed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:22:42 -06:00
Behdad EsfahbodandClaude Opus 4.6 c152eaceb3 [util] --show-extents: add a filled dot at the pen origin
Extend the shared overlay helper (and rename it from
util_emit_extents_rect_into_* to util_emit_extents_overlay_
into_*) to emit two pieces of geometry per glyph: the
existing stroked rect around the ink box, plus a filled
dot at the pen origin via hb_draw_circle.  Both go in the
foreground color through the same draw / paint flow.

The dot helps debug glyph positioning at a glance and gives
the previously-uncalled hb_draw_circle a real caller in the
suite.

Raster, vector, and gpu utils pick up the dot automatically
via the renamed helper.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:22:42 -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 48fdb0ec34 [cairo] Implement arbitrary-path clip in paint funcs
Wire push_clip_path_start / push_clip_path_end into the
cairo paint backend.  start() saves the cairo state, opens
a fresh path, and hands the caller hb_cairo_draw_get_funcs
with the cairo_t as draw data — same draw funcs that
push_clip_glyph already uses internally to walk a glyph
outline as a cairo path.  end() closes the path and calls
cairo_clip; pop_clip's cairo_restore tears down the saved
state as before.

Lets cairo paint consumers compose arbitrary-path clips
(say, an outline for a non-glyph shape) the same way
push_clip_glyph builds a glyph clip.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:21:49 -06:00
Behdad EsfahbodandClaude Opus 4.6 591748f1e1 [draw][paint] Make get_funcs instance-aware; add get_format
The six public draw / paint funcs getters across raster,
vector, and gpu used to be singletons:

  hb_raster_draw_get_funcs (void)
  hb_raster_paint_get_funcs (void)
  hb_vector_draw_get_funcs (void)
  hb_vector_paint_get_funcs (void)
  hb_gpu_draw_get_funcs (void)
  hb_gpu_paint_get_funcs (void)

That works fine for raster and gpu, where there's a single
backend per type, but breaks for the vector backend where
SVG and PDF have separate funcs sets — callers using the
public getter always got SVG funcs and silently produced
SVG markup inside PDF output streams when invoking the new
arbitrary-path clip API on a PDF context.

Make all six take a const-pointer to the relevant context
instance.  vector_paint dispatches on paint->format; the
other five just use the instance for symmetry today (room
for future format-style dispatch later).

Also expose hb_vector_draw_get_format / hb_vector_paint_
get_format public getters so callers (or third parties)
can ask a vector context for its format without poking at
internals.

Also: hb_vector_paint_push_clip_path_end now wraps the
emitted SVG clipPath's path in transform="scale(1,-1)" so
free-form arbitrary clips at base body level land in the
same coord system the per-glyph <use scale(_,-sy)>
wrappers establish.  Without this, free-form clip-path
arbitrary outlines emitted between paint_glyph calls came
out mirrored across the X axis.

Updates internal callers (hb_vector_paint_glyph,
hb_pdf_emit_glyph_path, hb_raster_paint_push_clip_path_
start, hb_gpu_paint_push_clip_path_start, the GPU pen
adapter), util sites (raster-output.hh, vector-output.hh,
gpu/demo-font.cc), API tests (test-raster.cc, test-gpu.cc),
and the docs section index.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:21:49 -06:00
Behdad EsfahbodandClaude Opus 4.6 fe77507f14 [util/gpu] Port --show-extents to the shared paint helper
Use util_emit_extents_rect_into_{draw,paint} from
helper-extents-overlay.hh so the GPU demo's extents
overlay matches the raster and vector ports — same
coordinate, padding, and stroke convention; same
foreground-color fill via the arbitrary-path clip API in
paint mode.

Adds --show-extents support for the paint (color-glyph)
path, which previously only the draw path implemented.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:19:17 -06:00