Table of Contents

Class FontCache

Namespace
KernSmith
Assembly
KernSmith.dll

Thread-safe cache for font data bytes, supporting file paths, system fonts, and raw data.

public sealed class FontCache
Inheritance
FontCache
Inherited Members

Properties

Count

Number of fonts currently in the cache.

public int Count { get; }

Property Value

int

Methods

Add(string, byte[])

Adds raw font data bytes to the cache under the specified key.

public void Add(string key, byte[] fontData)

Parameters

key string
fontData byte[]

Clear()

Removes all entries from the cache.

public void Clear()

Contains(string)

Returns true if the specified key exists in the cache.

public bool Contains(string key)

Parameters

key string

Returns

bool

Get(string)

Retrieves cached font data by key. Throws if the key is not cached.

public byte[] Get(string key)

Parameters

key string

Returns

byte[]

LoadFile(string)

Loads a font file from disk and caches it by its full file path.

public void LoadFile(string path)

Parameters

path string

LoadSystemFont(string)

Resolves a system font by family name and caches the font data.

public void LoadSystemFont(string fontFamily)

Parameters

fontFamily string

TryGet(string, out byte[])

Attempts to retrieve cached font data. Returns true if found.

public bool TryGet(string key, out byte[] fontData)

Parameters

key string
fontData byte[]

Returns

bool