rememberTextMeasurer

Composable Function

Common
@Composable
fun rememberTextMeasurer(cacheSize: Int = DefaultCacheSize): TextMeasurer

Creates and remembers a TextMeasurer. All parameters that are required for TextMeasurer except cacheSize are read from CompositionLocals. Created TextMeasurer carries an internal TextLayoutCache with cacheSize capacity. Provide 0 for cacheSize to opt-out from internal caching behavior.

Parameters

cacheSizeCapacity of internal cache inside TextMeasurer. Size unit is the number of unique text layout inputs that are measured. Value of this parameter highly depends on the consumer use case. Provide a cache size that is in line with how many distinct text layouts are going to be calculated by this measurer repeatedly. If you are animating font attributes, or any other layout affecting input, cache can be skipped because most repeated measure calls would miss the cache.