GlyphCache Class

Keeps what drawing a glyph computes from one draw call to the next, up to a number of bytes: the coverage of a glyph at a position in a pixel, and the display list of a glyph a font draws with its own colors.

public sealed class GlyphCache

Remarks

A cache is given to DrawingCanvas.FillGlyphs by GlyphRunOptions.Cache. A glyph is found again for the same font object (a Font and the fonts Font.WithVariations makes are different fonts), glyph, size, transformation of the canvas, position in its pixel (a quarter of a pixel along the line, a whole pixel across it), antialiasing and synthetic bold. The pixels are the same with or without a cache: only the time and the allocations of a draw call change.

When an entry does not fit, the entries used least recently are removed. The bytes of an entry are an estimate of what it holds. A cache is thread-safe; it holds the fonts of its entries until they are removed.

Constructors

NameDescription
GlyphCache(long)Initializes a new instance of the GlyphCache class.

GlyphCache(long)

GlyphCache.cs

Initializes a new instance of the GlyphCache class.

public GlyphCache(long maxBytes)

Parameters

maxBytes long
The most bytes the entries may hold.

Exceptions

ArgumentOutOfRangeException
maxBytes is negative.

Properties

NameDescription
BytesGets the bytes the entries hold.
CountGets the number of entries.
MaxBytesGets the most bytes the entries may hold.

Gets the bytes the entries hold.

public long Bytes { get; }

Property value

long

Gets the number of entries.

public int Count { get; }

Property value

int

Gets the most bytes the entries may hold.

public long MaxBytes { get; }

Property value

long

Methods

NameDescription
Clear()Removes every entry.

Removes every entry.

public void Clear()