Class DrawingTextCache
- Namespace
- SixLabors.ImageSharp.Drawing.Processing
- Assembly
- SixLabors.ImageSharp.Drawing.dll
Stores reusable text drawing data shared by one or more drawing canvases.
public sealed class DrawingTextCache
- Inheritance
-
DrawingTextCache
- Inherited Members
Remarks
Two tiers are cached. The glyph cache holds one flattened outline per glyph, keyed by glyph id, size and pen; it is the base layer that avoids re-flattening the same glyph and is shared by every run. The run-path cache is derived from it: the glyphs of a whole uniform run merged into a single positioned path, so that redrawing the run collapses to one composition command instead of one per glyph. The run path is keyed in run-local space, so the same run content drawn at any position, including a fractionally scrolled one, is a hit. The cost is memory, because the merged path holds a copy of each glyph's geometry; far fewer run paths than glyph entries are kept, only whole-run repeats benefit, and a run that differs by a single glyph misses and falls back to the per-glyph commands.
Constructors
DrawingTextCache()
Initializes a new instance of the DrawingTextCache class.
public DrawingTextCache()
DrawingTextCache(int)
Initializes a new instance of the DrawingTextCache class.
public DrawingTextCache(int capacity)
Parameters
capacityintThe maximum number of text cache entries.
Fields
DefaultCapacity
The default maximum number of text cache entries.
public const int DefaultCapacity = 16384
Field Value
Properties
Capacity
Gets the maximum number of glyph cache entries. The smaller run-path cache capacity is derived from this value.
public int Capacity { get; }
Property Value
Count
Gets the number of glyph cache entries. Run-path entries are not included.
public int Count { get; }
Property Value
Methods
Clear()
Removes all cached text drawing data.
public void Clear()