Skip to main content
Version: 1.0.0-preview.33

Velaptor.Content.Fonts.FontLoader

Velaptor

Velaptor.Content.Fonts

FontLoader Class

Loads font content for rendering text.

public sealed class FontLoader :
Velaptor.Content.ILoader<Velaptor.Content.Fonts.IFont>

Inheritance System.Object → FontLoader

Implements Velaptor.Content.ILoader<IFont>

Constructors

FontLoader() Constructor

Initializes a new instance of the FontLoader class.

public FontLoader();

Methods

Load(string)

Loads font content from the application's content directory or directly using a full file path.

public Velaptor.Content.Fonts.IFont Load(string contentPathOrName);

Parameters

contentPathOrName System.String

The name or full file path to the font with metadata.

Implements Load(string)

Returns

IFont
The loaded font.

Exceptions

System.ArgumentNullException
Occurs when the contentPathOrName argument is null or empty.

CachingMetaDataException
Occurs if the metadata is invalid.

System.IO.FileNotFoundException
Occurs if the font file does not exist.

Example

// Valid Example 1  
ContentLoader.Load("my-font|size:12");
<br/>
// Valid Example 2
ContentLoader.Load("my-font");
<br/>
// Valid Example 3
ContentLoader.Load("my-font.ttf");
<br/>
// Valid Example 4
ContentLoader.Load(@"C:\fonts\my-font.ttf|size:12");
<br/>
// Invalid Example 1
ContentLoader.Load("my-font|size:12");
<br/>
// Invalid Example 2
ContentLoader.Load("my-font|size:12");
<br/>
// Invalid Example 3
ContentLoader.Load("my-font|size12");

Remarks

If a path is used, it must be a fully qualified file path.

Directory paths are not valid.

If no metadata is provided, then a default font size of 12 will be used.

Unload(string)

Unloads the data with the given contentPathOrName.

public void Unload(string contentPathOrName);

Parameters

contentPathOrName System.String

The name of the content item to unload.

Implements Unload(string)