When an edge fell to the left of the rendering surface (col < 0),
cell_add() discarded its winding contribution entirely. For glyphs
whose outlines extend beyond the surface bounds (e.g. COLR v1
spliceMask clip glyphs), this caused the interior winding number to
stay zero, producing empty rasterizations.
Fix by forwarding the cover delta to column 0 so the left-to-right
sweep picks up the correct accumulated winding.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove hb_raster_extents_from_glyph_extents and switch callers to the new transform-aware set_glyph_extents APIs on raster draw/paint. Also add test coverage for transformed glyph extents and update section symbol listings.
hb-raster-all now renders color glyphs via hb_raster_paint_t and checks
the image format (A8 vs BGRA32) when writing PPM output. hb-ft-raster-all
also switched from PGM to PPM for consistency.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both hb-raster and hb-ft-raster now always produce PPM (color) output,
compositing alpha over foreground/background colors. This makes the
output format consistent regardless of whether the font has color data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pre-compute seam rows during edge bucketing where one edge's yH matches
another edge's yL at a mid-pixel-row y-coordinate. For these rare rows
(typically 2 per glyph), split into two sub-rows and sum absolute alpha
values to avoid winding cancellation. Non-seam rows take the exact same
code path with only a single branch check overhead.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When two contours share a y coordinate that falls mid-pixel-row,
their edges contribute opposite-winding cover values at different
fractional heights. The analytic formula |cover·512 − area|
computes the signed sum, which partially cancels, producing a
visible one-row artifact.
Fix by detecting these seam rows (an edge yH matching another
edge's yL within the same pixel row) and splitting into sub-rows.
Each sub-row's |cover·512 − area| is computed independently, then
the absolute alpha values are summed. This gives correct coverage
because each sub-row has consistent winding direction.
Performance impact is negligible: seam detection piggybacks on the
existing edge-removal loop (zero cost for non-seam rows), and
sub-row processing only runs for the rare seam rows (typically 1-2
per glyph).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two bugs fixed:
- atan2f returns [-pi,pi] but sweep gradient angles are in [0,2*pi];
normalize pixel angle to [0,2*pi) so the seam matches the OT spec.
- REFLECT extend mode was identical to REPEAT because floorf after
the initial mod made period always 0.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the current transform has rotation/skew, push_clip_rectangle now
rasterizes the actual transformed quad using edge cross-product tests
instead of approximating with an axis-aligned bounding box.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Track bounding box (min_x/y, max_x/y) on all clip masks. Paint
callbacks (solid fill, image, gradients) now iterate only within
the clip bounding box instead of the full surface.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move pixel helpers (div255, src_over, alpha_mul, pack_pixel) to
hb-raster.hh as shared inline functions with hb_raster_ prefix.
Move all blend mode implementations and hb_raster_composite_images()
to hb-raster-image.cc for reuse outside of paint.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement a software paint backend (hb_raster_paint_t) that renders
COLRv0/v1 color glyphs into BGRA32 pixel buffers with no external
dependencies. Implements all 14 hb_paint_funcs_t callbacks including
solid fills, linear/radial/sweep gradients, glyph clipping, rectangle
clipping, group compositing, and BGRA image blitting.
Update hb-raster utility to detect color fonts and use the paint path,
outputting PPM (RGB) instead of PGM (greyscale).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Define HB_RASTER_FLAT_THRESH 0.25f for the maximum Bézier deviation in
pixels; each flattener squares it locally.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Same approach as the quadratic: control-point deviation also shrinks 4×
per de Casteljau subdivision, so err² shrinks 16× per level, giving the
same upfront subdivision-count formula. The cubic adds a constant third
difference d³f = 6·a·h³ and one extra accumulator in the inner loop.
Keep the recursive de Casteljau version as flatten_cubic_recursive
(static HB_UNUSED inline, depth=0 default). flatten_cubic() dispatches
to flatten_cubic_fd() by default.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Revive the recursive de Casteljau flattener as flatten_quadratic_recursive
(static inline, depth=0 default argument) alongside the forward-differencing
flatten_quadratic_fd. flatten_quadratic() dispatches to the fd variant by
default.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Exploit the property that quadratic Bézier error shrinks exactly 4×
per de Casteljau subdivision. Compute the subdivision count upfront,
then iterate with constant-cost additions (forward differencing)
instead of recursive branching. ~1.5% speedup.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace all hardcoded 64/63/6/128/8192/4096/13 constants with
HB_RASTER_PIXEL_BITS / HB_RASTER_ONE_PIXEL / HB_RASTER_PIXEL_MASK /
HB_RASTER_FULL_COVERAGE macros. Changing HB_RASTER_PIXEL_BITS from
6 (26.6, current) to 8 (24.8, like FreeType's rasterizer) switches
the entire pipeline.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Avoid recomputing y_top = py << 6 inside edge_sweep_row; the caller
already has it.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>