Skip to main content

Module glyph_cache

Module glyph_cache 

Source
Expand description

Glyph path and cell cache for CPU text rendering. Glyph path and cell cache for CPU rendering.

Two-level cache:

  1. Path cache: PathStorage objects keyed by (font, glyph, ppem). Avoids redundant path construction from font outlines.
  2. Cell cache: Rasterizer cells keyed by (font, glyph, ppem, scale, sub-pixel). Avoids the expensive path→cells conversion on every frame. Cells are computed at position (0,0) and offset at render time.

Structs§

CachedCells
Pre-rasterized glyph cells at a canonical position. Contains the rasterizer’s cell output for a glyph at sub-pixel position (subpx_x, subpx_y). To render at actual position (x, y), add integer pixel offset to each cell.
CachedGlyph
Result of a cache lookup: the path plus whether it’s hinted (pixel coords) or not.
GlyphCache
Cache of built glyph paths and pre-rasterized cells.
GlyphCellKey
Cache key for pre-rasterized glyph cells. Includes sub-pixel x/y fractional position quantized to 1/4 pixel.
GlyphPathKey
Cache key for a glyph path. ppem = 0 means unhinted (font-unit path), ppem > 0 means hinted at that size.

Functions§

build_path_from_contours
Build an agg PathStorage from TrueType contour data (points in F26Dot6).