Adds --background command-line option to hb-draw, similar to hb-view/hb-cairo.
Supports RGB and RGBA color formats (rrggbb[aa]). Background is rendered as
an SVG rect element covering the viewBox when specified.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1. If smaller set has empty pages the subset checking logic was incorrectly incrementing the larger page index after skipping the empty smaller page index.
2. The logic for is_subset() on mixed inverted/not inverted sets was wrong.
Color glyphs are now defined once in <defs> and reused via <use> elements,
similar to non-color glyphs. Previously each color glyph instance rendered
the full paint operations inline, causing duplication.
Tested with repeating emoji: reduces SVG size by ~44% for files with
repeated color glyphs (e.g., 3 emoji instances: 5.8KB vs 11KB without reuse).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
In reuse mode, the outer scale(font_scale_x, -font_scale_y) wrapper
already flips Y. The color glyph wrapper was incorrectly also applying
scale(1,-1), causing a double Y-flip that made the output appear
off-bounds at any font size other than upem.
Now only apply scale(1,-1) in upem_scale mode (no outer wrapper).
Also restore precision 9 for 1/upem scale values.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reduce MAX_ANGLE from pi/8 to pi/16, producing ~32 slices per full
circle instead of ~16. This reduces visible color banding in sweep
gradient approximation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Coordinate data uses the user's --precision (default 2), but scale and
transform matrix values need more decimal places to avoid compounding
rounding errors. Add scale_precision() helper that returns max(precision, 5).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Creating upem_font as a sub-font of the main font (which has scale =
upem * 64 due to subpixel bits) caused the paint API to emit spurious
parent→child scale transforms. With precision=2 rounding, 1/64 rounds
to 0.02 and 0.02*64 = 1.28, destroying the mathematical cancellation
and making color glyphs ~1.6x too large.
Fix by creating upem_font directly from the face, eliminating the
parent-child relationship. Update expected test outputs accordingly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Render COLRv0/v1, CBDT/sbix bitmaps, and SVG table glyphs as rich SVG
with colors, gradients, compositing, and inlined bitmap images using
hb_font_paint_glyph(). Falls back to monochrome outlines when no color
data is available.
New options: --no-color, --palette N, --foreground rrggbb[aa]
Glyph outline paths are stored as shared <defs> and reused by both
display <use> elements and <clipPath> references, avoiding duplicate
path data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>