Project

ChartForgeX

Render deterministic charts, dashboards, topology, hierarchy, and report visuals directly from .NET.

Stars 47
Forks 2
NuGet downloads 75,067
Release ChartForgeX-v2.0.0
Language: HTML Updated: 2026-10-12

API Reference

Class

FontRegistry

Namespace ChartForgeX.Typography
Assembly ChartForgeX
Modifiers static

Font faces an application registers once from files, bytes, or streams and then names by family everywhere raster text is drawn: chart, grid, topology, and visual block themes, FontSpec.FromFamily text, VisualCanvas themes, and SVG font-family in SvgRasterizer.

Inheritance

  • Object
  • FontRegistry

Remarks

A registered family takes precedence over an installed family of the same name, and its faces are chosen by the same weight and slant matching; installed faces of that family are not mixed in. Registering a generic family name (sans-serif, serif, monospace) sets the face that stacks ending in that keyword fall back to, and a registered sans-serif is also the last resort on a host with no usable fonts, such as a bare Linux container. TrueType and CFF outlines and colour-only emoji faces are supported (.ttf, .otf, .ttc, .otc). All members are thread-safe.

Methods

public static Void Clear() #
Returns: Void

Removes every registered face, so families resolve to installed fonts again.

Register 3 overloads
public static Void Register(String family, String path, Int32 weight = 400, Boolean italic = false, Int32? collectionIndex = null) #
Returns: Void

Registers one face of a font file under a family name.

Parameters

family System.String requiredposition: 0
The family name stacks will use, such as Inter or sans-serif.
path System.String requiredposition: 1
The OpenType font or collection file (.ttf, .otf, .ttc, .otc).
weight System.Int32 = 400 optionalposition: 2
The CSS weight of this face, 1 through 1000.
italic System.Boolean = false optionalposition: 3
True when this face is the italic of the family.
collectionIndex System.Int32? = null optionalposition: 4
The face within a .ttc or .otc collection; the first usable text or colour face when omitted.

Exceptions

  • ArgumentException – The family is empty or the file is not a readable OpenType text or colour font.
public static Void Register(String family, Byte[] data, Int32 weight = 400, Boolean italic = false, Int32? collectionIndex = null) #
Returns: Void

Registers one OpenType face from bytes under a family name, without filesystem access.

Parameters

family System.String requiredposition: 0
The family name used by font stacks, including generic names such as sans-serif.
data System.Byte[] requiredposition: 1
The complete TrueType, CFF, or OpenType collection data. Registration retains its own copy.
weight System.Int32 = 400 optionalposition: 2
The CSS weight of this face, 1 through 1000.
italic System.Boolean = false optionalposition: 3
True when this face is the italic of the family.
collectionIndex System.Int32? = null optionalposition: 4
The collection face index; the first usable text or colour face when omitted.

Exceptions

  • ArgumentNullException – data is null.
  • ArgumentException – The family is empty or the data is not a readable OpenType text or colour font.
  • ArgumentOutOfRangeException – The weight is outside 1 through 1000.
public static Void Register(String family, Stream stream, Int32 weight = 400, Boolean italic = false, Int32? collectionIndex = null) #
Returns: Void

Registers one OpenType face from a readable stream, without filesystem access.

Parameters

family System.String requiredposition: 0
The family name used by font stacks, including generic names such as sans-serif.
stream System.IO.Stream requiredposition: 1
A readable stream containing a complete font from its current position to its end. It need not support seeking.
weight System.Int32 = 400 optionalposition: 2
The CSS weight of this face, 1 through 1000.
italic System.Boolean = false optionalposition: 3
True when this face is the italic of the family.
collectionIndex System.Int32? = null optionalposition: 4
The collection face index; the first usable text or colour face when omitted.

Exceptions

  • ArgumentNullException – stream is null.
  • ArgumentException – The family is empty, the stream is unreadable, or its remaining data is not a readable OpenType text or colour font.
  • ArgumentOutOfRangeException – The weight is outside 1 through 1000.
  • IOException – Reading the stream fails.
public static Int32 RegisterDirectory(String directory) #
Returns: Int32

Registers every readable .ttf, .otf, .ttc, and .otc face in a folder and its subfolders under their own family names.

Parameters

directory System.String requiredposition: 0

Returns

The number of faces registered; files that are not readable OpenType text fonts are skipped.

public static Int32 RegisterFile(String path) #
Returns: Int32

Registers every face of a font file under the family, weight, and slant the file itself declares.

Parameters

path System.String requiredposition: 0

Returns

The number of faces registered.

Exceptions

  • ArgumentException – The file declares no readable OpenType face.

Properties

public static IReadOnlyCollection<String> Families { get; } #

Gets the registered family names.