Documentation Index
Fetch the complete documentation index at: https://mintlify.com/chenglou/pretext/llms.txt
Use this file to discover all available pages before exploring further.
Signature
What gets cleared
CallingclearCache() resets all of Pretext’s shared internal state:
- Segment metrics cache — the
Map<font, Map<segment, metrics>>built up byprepare()andprepareWithSegments()calls across all fonts and text variants. - Grapheme segmenter — the hoisted
Intl.Segmenterinstance used for grapheme splitting. - Line text caches — the per-
PreparedTextWithSegmentsgrapheme string caches used internally bylayoutWithLines()andlayoutNextLine().
When to call
CallclearCache() when your app has cycled through many different fonts or large volumes of unique text and you want to release the accumulated heap.
When NOT to call
Relationship to setLocale()
setLocale() calls clearCache() internally whenever the locale changes. You do not need to call both.