Commit Graph
21243 Commits
Author SHA1 Message Date
Behdad Esfahbod d8b1d6bb57 [gpu] Return edge coverage from hb_gpu_paint(); apply stem darkening and gamma to it
hb_gpu_paint() now takes an out float coverage parameter that
receives the maximum slug coverage across all paint layers.
This lets the caller apply stem darkening and gamma correction
to edge antialiasing only, without distorting interior paint
colors (gradients, semi-transparent layers).

The demo shaders (GLSL, MSL, HLSL, WGSL) use the new parameter
to share a single coverage-correction block between draw and
paint paths.  Also fixes the blend func to GL_ONE for correct
premultiplied compositing.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 14:09:34 -06:00
Behdad Esfahbod 43b8568139 [vector] Fix potential use-after-free in check_font()
Reference the new font before destroying the old one, in case
both pointers are the same object.  In practice the caller always
holds its own reference so this cannot trigger, but the pattern
is safer and silences Coverity CID 503195/503196.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 13:43:21 -06:00
Behdad Esfahbod a5bd445578 [vector] Expand section docs with usage examples and caveats
Add sample code for both draw and paint contexts, note that
render clears accumulated content (get extents first), and
document the semi-transparent overlap compositing behavior.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 13:36:57 -06:00
Behdad Esfahbod ba66cfcc0b [util] Document --background=none in help string
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 13:36:57 -06:00
Behdad Esfahbod 0272f02af7 [vector] Adjust duplicate header and improve docs 2026-04-17 13:36:57 -06:00
Behdad Esfahbod 15a451c205 Merge pull request #5941 from harfbuzz/vector-touchups
vector touchups
2026-04-17 13:35:54 -06:00
Behdad Esfahbod 3c9fe077b1 [gpu] Interpolate gradient color stops in premultiplied space
The OpenType COLR spec requires gradient interpolation in
premultiplied space.  The shader was interpolating unpremultiplied
stop colors directly, which produced washed-out transitions when
a stop fades toward transparency (e.g. opaque red to transparent
gives desaturated pink instead of red at decreasing opacity).

Premultiply stop colors before mix(), unpremultiply the result.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 03:57:17 -06:00
Behdad Esfahbod 178402d7b4 [gpu/demo] Fix blend func for premultiplied paint output
hb_gpu_paint() returns premultiplied RGBA, as documented in
hb-gpu.cc.  The GL demo was using GL_SRC_ALPHA which
double-applied alpha, darkening semi-transparent colors.

Use GL_ONE as the API docs prescribe.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 03:42:55 -06:00
Behdad Esfahbod af21e3c227 [vector/raster] Remove is_foreground substitution; pass foreground directly
These backends use immediate-mode foreground: they pass their
foreground color to hb_font_paint_glyph() and use the resolved
color from the callback directly.  The is_foreground substitution
was redundant (a no-op when foreground alpha is 255) and prevented
semi-transparent foreground alpha from working correctly.

Now the foreground is passed as-is (including its alpha) to
hb_font_paint_glyph(), and the color callback ignores
is_foreground — the color already carries the correct value.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 03:35:29 -06:00
Behdad Esfahbod dba796ff28 [gpu] Fix foreground alpha: only modulate alpha channel, not RGB
The previous commit scaled all four components of the foreground
uniform by the baked paint-tree alpha, which darkened the RGB
towards black.  The foreground is unpremultiplied, so only the
alpha channel should be modulated; the shader's later premultiply
step handles the rest.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 03:24:30 -06:00
Behdad Esfahbod 9031600cc2 [paint] Document is_foreground semantics on color callback and color stops
Explain the two valid usage modes: immediate (use @color directly)
and deferred (substitute own foreground RGB, combine alpha).  Note
that deferred mode requires passing an opaque foreground to
hb_font_paint_glyph().

hb_color_stop_t defers to hb_paint_color_func_t for the
is_foreground/color contract.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 03:17:50 -06:00
Behdad Esfahbod f546f73b1f [gpu] Preserve paint-tree alpha for foreground entries in shaders
When is_foreground was set, the shader replaced the entire baked
color with the foreground uniform, discarding the paint-tree alpha
encoded in the color's alpha channel.  This meant COLRv1 glyphs
with a separate alpha on their foreground color sentinel would
lose that alpha at render time.

Now the shader multiplies the foreground uniform by the baked alpha
(ct.a / 32767 for LAYER_SOLID, b.a / 32767 for gradient stops),
preserving the paint-tree modulation.

Updated all four shader languages (GLSL, HLSL, MSL, WGSL) and
regenerated the .hh artifacts.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 03:11:59 -06:00
Behdad Esfahbod 7f333335b1 [font] Synthesized mono paint: pass is_foreground=true, alpha=255
The synthesized fallback should signal is_foreground=true so
backends like cairo that handle foreground specially can detect
it.  Pass alpha=255 since the caller passes opaque foreground
to paint_glyph; backends that care about foreground will apply
their own alpha.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 02:44:20 -06:00
Behdad Esfahbod d17dbe74d1 Revert "[vector] Remove is_foreground substitution from paint backends"
This reverts commit 9d1ce8c942.
2026-04-17 02:40:19 -06:00
Behdad Esfahbod 4e2a9b0c58 [vector/raster] Pass opaque foreground to paint_glyph
The COLR walker's get_color bakes foreground_alpha into
the returned color.  Since our backends don't substitute
paint->foreground in their callbacks (they trust the walker's
resolved color), passing foreground with its own alpha would
double-count it.

Force alpha=255 when passing foreground to hb_font_paint_glyph
and _or_fail, matching what cairo does.  The backend applies
foreground alpha through its own mechanisms (draw fill-opacity,
raster compositing).

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 02:29:27 -06:00
Behdad Esfahbod e76163ebc8 [vector-draw] Add PDF fill opacity via inline ExtGState
The PDF draw context was dropping foreground alpha because
it had no resource dict for ExtGState.  Semi-transparent
fills (e.g. --rainbow) rendered fully opaque.

Add a per-flush ExtGState with /ca (fill opacity) when
alpha < 255.  The ExtGState entries are inlined in the
page's resource dict — no separate PDF objects needed.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 02:18:47 -06:00
Behdad Esfahbod 9d1ce8c942 [vector] Remove is_foreground substitution from paint backends
The SVG and PDF paint_color callbacks were substituting
paint->foreground when is_foreground=true, ignoring the
color the COLR walker already resolved.  The original paint
API contract is: if is_foreground, the color IS the
foreground — use it directly.

Same fix for gradient color stops: the color line already
has foreground colors resolved by the walker.  Drop the
redundant substitution + alpha multiplication.

This removes the dependency on paint->foreground in the
paint callbacks, eliminating the dual-foreground path.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 02:14:41 -06:00
Behdad Esfahbod 7b82745f28 [font] Fix synthesized mono paint: pass foreground as literal color
The synthesized mono fallback was passing is_foreground=true,
which caused the backend to modulate the foreground alpha
with the color's alpha — squaring the alpha when the color
was the foreground itself.

Instead, pass the foreground as a literal color (is_foreground=
false).  This avoids any interaction with the backend's own
foreground state and passes the caller's foreground value
straight through.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 02:01:51 -06:00
Behdad Esfahbod 14c789de8d [vector-paint] Don't clear output buffers on changed()
changed() was clearing defs, path, and group_stack (the
accumulated output) in addition to the glyph caches.  When
set_foreground was called per-glyph (e.g. --rainbow), each
color change wiped all previous glyphs — only the last one
survived in the rendered output.

Only clear the caches (defined_outlines, defined_clips,
active_color_glyphs, defined_color_glyphs).  Leave the
output buffers and counters intact.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:38:12 -06:00
Behdad Esfahbod f3dc687620 [util] Semi-retire --stroke; hide from --help
The recently added --stroke option is only meaningful in
hb-view (cairo rendering).  The experimental utils
(hb-raster, hb-vector, hb-gpu) don't support stroked
outline rendering.  Hide from --help but keep functional;
--rainbow still enables it implicitly.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:33:11 -06:00
Behdad Esfahbod 370ed58a70 [vector-paint-pdf] Use scale_precision for transform matrix entries
The PDF push_transform and per-glyph cm were emitting
matrix entries (xx, yx, xy, yy) at default precision=2.
For small values like 1/31.25 = 0.032, this rounded to
0.03 — a 6.25% error that accumulated through nested
transforms, visibly distorting color emoji rendering.

Use scale_precision (min 7) for matrix entries, matching
the SVG paint backend.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:30:02 -06:00
Behdad Esfahbod 9dfd7aa5a5 [vector] Fix global paint transform for output-space
The SVG global transform prefix emitted x0/y0 raw without
dividing by scale_factor.  The PDF per-glyph cm was reduced
to identity + translation, losing the matrix entries from
paint->transform when non-identity.

Fix: divide x0/y0 by sf in SVG; emit full matrix in PDF cm.
Update stale comment.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:22:56 -06:00
Behdad Esfahbod bc1346db0d [vector] Emit PDF paint coordinates in output-space
Same treatment as SVG: scale all PDF paint coordinates by
1/scale_factor so clip paths, transforms, gradients, images,
and sweep meshes emit in fractional pixel values.

The per-glyph cm matrix becomes a simple translation (the
content is already in output-space).  Revert the 1000000
fill rect bandaid back to 32767.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:14:38 -06:00
Behdad Esfahbod bc7e513b2d [vector] Emit SVG coordinates in output-space
Scale all SVG paint and draw coordinates by 1/scale_factor
so paths, clips, gradients, transforms, and images emit
fractional pixel values instead of font-scale integers.

The per-glyph <use> transform now applies only a Y-flip
(scale(1,-1)) instead of scale(1/sf,-1/sf), since the
content is already in output-space.

Revert the 1000000 fill rect bandaid back to 32767 — in
output-space, 32767 pixels is always large enough.

SVG paint callbacks:
- push_clip_glyph: path sink divides by scale_factor
- push_clip_rectangle: coords divided by sx/sy
- push_transform: translation (dx,dy) divided by sx/sy
- gradient coords: divided by sx/sy
- sweep center: divided by sx/sy
- image extents: divided by sx/sy

SVG draw:
- Glyph outline path sink divides by scale_factor

Regenerated all vector test expected outputs.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:07:45 -06:00
Behdad Esfahbod d442e7e839 [vector] Rename hb-vector-svg.hh → hb-vector-internal.hh
Nothing SVG-specific remains in this header — it holds
blob recycling, transform helpers, extents helpers, and
the SVG instance transform.  Rename to reflect its actual
role as shared vector internals.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:56:08 -06:00
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