Text

Text set by gezira's rasterizer: each glyph's outline curves, wrapped into lines, laid out, clipped and rasterized by one Nile pipeline, on the CPU or the GPU.

How to use: edit the text, drag the size, or pick a font; drop a .ttf file onto the page to set the text in it. The renderer menu switches between the CPU (JavaScript or WebAssembly) and the GPU; all four run the same Nile.

Rendering: about 170 lines of Nile and 390 of TypeScript (210 of them read TrueType fonts), compiled by umgeni. The page’s interface isn’t counted.

See the Nile pipeline

This Nile pipeline, TextSpans, takes a stream of GlyphBeziers: each glyph's outline curves, read from the font by plain TypeScript, tagged with the glyph's advance. It wraps the text into lines (WordWidths runs backwards, so each word's first glyph knows how wide the word is), lays the glyphs out, transforms them onto the page, clips them and rasterizes them into coverage spans. PaintSpans turns the spans into coloured pixels, which TypeScript writes to the canvas. The pipeline is parameterized by the line width, the line height, a matrix that scales and places the text, and the clip rectangle. Colour emoji are layers of outlines, so the page splits the stream after layout and paints each colour in turn. On the GPU, the rasterizer runs as WGSL (RasterizeParallel).