Module text

Source
Expand description

Text rasterizer for Text clips: system fonts (fontdb) + ab_glyph. Produces a tight, straight-alpha RGBA image with fill, outline (dilated coverage), shadow (offset + box blur) and optional background box. Output is cached by (style.cache_key(), scale bits). scale = canvas px per project px, so a 72 px style at a 960-wide preview of a 1920 project renders at 36 px.

Structs§

TextRasterizer

Constants§

MAX_SIDE 🔒
Largest rendered text image side — keeps silly sizes from allocating gigabytes.

Functions§

blur_lines 🔒
1-D box blur of lines lines of len elements; element j of line i is at ilstride + jestride.
box_blur 🔒
Two iterations of a separable box blur with radius r (≈ Gaussian of radius 2r).
dilate 🔒
Disc dilation of a coverage mask by radius r (antialiased rim): exact Euclidean distance transform (Felzenszwalb–Huttenlocher, columns then rows), O(px) whatever the radius.
dt1d 🔒
1-D squared-distance transform of sampled function f into d (lower envelope of parabolas). v/z are scratch of len ≥ f.len() / f.len()+1.
over 🔒
Straight-alpha “over”: c with coverage cov (0..255) onto the straight-alpha pixel d.