Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
Gondwana.Rendering.Text.FontManager Class Referencesealed

Centralized manager for loading, retrieving, and unloading shared fonts. Fonts are stored by string key and reused across the application. More...

Inheritance diagram for Gondwana.Rendering.Text.FontManager:

Public Member Functions

SKTypeface LoadFromFile (string key, string filePath)
 Loads a font from a file path and stores it under the given key. If the key already exists, the old font is disposed and replaced.
SKTypeface LoadFromResource (string key, Assembly assembly, string resourceName)
 Loads a font from an embedded resource in the specified assembly and stores it under the given key. If the key already exists, the old font is disposed and replaced.
SKTypeface LoadFromResource (string key, string resourceName)
 Loads a font from an embedded resource in the calling assembly and stores it under the given key. If the key already exists, the old font is disposed and replaced.
SKTypeface Get (string key)
 Gets a font by key.
bool TryGet (string key, out SKTypeface? typeface)
 Tries to get a font by key.
SKTypeface GetOrDefault (string key)
 Retrieves the typeface associated with the specified key, or returns the default typeface if the key is not found or is null or whitespace.
bool Contains (string key)
 Returns true if a font exists for the given key.
bool Remove (string key)
 Removes a single font entry by key and disposes the stored typeface.
void Clear ()
 Disposes all loaded fonts and clears the manager.
void Dispose ()
 Disposes all loaded fonts managed by this instance and prevents further use.

Properties

static FontManager Instance [get]
 Gets the singleton instance of the FontManager.
IReadOnlyCollection< string > Keys [get]
 Gets all currently registered font keys.

Detailed Description

Centralized manager for loading, retrieving, and unloading shared fonts. Fonts are stored by string key and reused across the application.

Definition at line 10 of file FontManager.cs.

Member Function Documentation

◆ Clear()

void Gondwana.Rendering.Text.FontManager.Clear ( )

Disposes all loaded fonts and clears the manager.

Definition at line 198 of file FontManager.cs.

◆ Contains()

bool Gondwana.Rendering.Text.FontManager.Contains ( string key)

Returns true if a font exists for the given key.

Parameters
keyThe lookup key for the resource.
Returns
true if a player is registered for the key; otherwise, false.

Definition at line 165 of file FontManager.cs.

◆ Dispose()

void Gondwana.Rendering.Text.FontManager.Dispose ( )

Disposes all loaded fonts managed by this instance and prevents further use.

Definition at line 242 of file FontManager.cs.

◆ Get()

SKTypeface Gondwana.Rendering.Text.FontManager.Get ( string key)

Gets a font by key.

Parameters
keyLogical name of the font.
Returns
The matching font.
Exceptions
KeyNotFoundExceptionThrown when the key does not exist.

Definition at line 108 of file FontManager.cs.

◆ GetOrDefault()

SKTypeface Gondwana.Rendering.Text.FontManager.GetOrDefault ( string key)

Retrieves the typeface associated with the specified key, or returns the default typeface if the key is not found or is null or whitespace.

Parameters
keyThe key used to identify the desired typeface. If null, empty, or consists only of whitespace, the default typeface is returned.
Returns
The typeface associated with the specified key, or the default typeface if the key is not found or the key is null or whitespace.

Definition at line 148 of file FontManager.cs.

◆ LoadFromFile()

SKTypeface Gondwana.Rendering.Text.FontManager.LoadFromFile ( string key,
string filePath )

Loads a font from a file path and stores it under the given key. If the key already exists, the old font is disposed and replaced.

Parameters
keyLogical name for the font.
filePathPath to the font file.
Returns
The loaded font.
Exceptions
ArgumentExceptionThrown when key or filePath is invalid.
InvalidOperationExceptionThrown when the font could not be loaded.

Definition at line 36 of file FontManager.cs.

◆ LoadFromResource() [1/2]

SKTypeface Gondwana.Rendering.Text.FontManager.LoadFromResource ( string key,
Assembly assembly,
string resourceName )

Loads a font from an embedded resource in the specified assembly and stores it under the given key. If the key already exists, the old font is disposed and replaced.

Parameters
keyLogical name for the font.
assemblyAssembly containing the embedded font resource.
resourceNameFully qualified embedded resource name.
Returns
The loaded font.
Exceptions
ArgumentExceptionThrown when arguments are invalid.
InvalidOperationExceptionThrown when the resource is missing or the font could not be loaded.

Definition at line 64 of file FontManager.cs.

◆ LoadFromResource() [2/2]

SKTypeface Gondwana.Rendering.Text.FontManager.LoadFromResource ( string key,
string resourceName )

Loads a font from an embedded resource in the calling assembly and stores it under the given key. If the key already exists, the old font is disposed and replaced.

Parameters
keyThe lookup key for the resource.
resourceNameThe resource name.
Returns
The resulting sk typeface.

Definition at line 97 of file FontManager.cs.

◆ Remove()

bool Gondwana.Rendering.Text.FontManager.Remove ( string key)

Removes a single font entry by key and disposes the stored typeface.

Parameters
keyLogical name of the font.
Returns
True if the font was found and removed; otherwise false.

Definition at line 180 of file FontManager.cs.

◆ TryGet()

bool Gondwana.Rendering.Text.FontManager.TryGet ( string key,
out SKTypeface? typeface )

Tries to get a font by key.

Parameters
keyThe lookup key for the resource.
typefaceThe typeface used to render text.
Returns
true if the player was found; otherwise, false.

Definition at line 127 of file FontManager.cs.

Property Documentation

◆ Instance

FontManager Gondwana.Rendering.Text.FontManager.Instance
staticget

Gets the singleton instance of the FontManager.

Definition at line 20 of file FontManager.cs.

◆ Keys

IReadOnlyCollection<string> Gondwana.Rendering.Text.FontManager.Keys
get

Gets all currently registered font keys.

Definition at line 211 of file FontManager.cs.