Skip to main content

Module cache

Module cache 

Source
Expand description

Bounded LRU shape cache for crate::SwashShaper.

ShapeCache wraps an lru::LruCache in an RwLock so it can be shared across threads. Cache keys (ShapeKey) identify a unique shaping request by font identity, text content, and a hash of any variation-axis settings in use.

§Font identity

The font_id field is the pointer address of the Arc<[u8]> holding the font bytes. This is the same keying strategy used throughout the raster pipeline. Callers must hold the same Arc alive across calls for cache hits to occur; a newly constructed Arc from the same bytes will have a different pointer and thus be treated as a cache miss.

§Variation axes

axis_values_hash reserves a slot for future variation-axis support. Set it to 0 for non-variable fonts (the common case in Slice 5a).

Structs§

ShapeCache
Thread-safe bounded LRU cache for ShapedRuns.
ShapeKey
Cache key for a single shaping request.

Type Aliases§

FontId
Stable identifier for a font resource, derived from Arc<[u8]> pointer.