Table of Contents

Interface IFont

Namespace
BSGameLib.Game.Fonts
Assembly
BSGameLib.Game.dll

A font that text can be measured and drawn in. Fonts are created through IContentManager.

public interface IFont : IDisposable
Inherited Members

Properties

Bold

Whether the font is bold. For a TrueType font this is faked from the one file, so it is not a separate face.

bool Bold { get; }

Property Value

bool

Face

The family name of the font, as stored in the font file.

string Face { get; }

Property Value

string

FileName

The name the font was loaded with: the file path for a font loaded from a file, and the name given for a font loaded from a stream or resource.

string FileName { get; }

Property Value

string

Italic

Whether the font is italic. For a TrueType font this is faked by slanting the glyphs.

bool Italic { get; }

Property Value

bool

LineHeight

The distance in pixels from one line of text to the next.

int LineHeight { get; }

Property Value

int

Name

The name of the font. The built-in fonts do not set it, so it is null.

string Name { get; }

Property Value

string

Size

The size the font was created at, as given when it was loaded.

int Size { get; }

Property Value

int

Methods

MeasureText(string)

Returns the width and height, in pixels, that text takes up when drawn: the widest line, and LineHeight for each line. Null or empty text gives zero. Characters the font has no glyph for take no space.

Vector2 MeasureText(string text)

Parameters

text string

Returns

Vector2

Wrap(string, int)

Returns text with line breaks inserted so that lines are narrower than maxWidth pixels, where the words allow. Lines break only at spaces, and the text's own line breaks are kept. A word wider than maxWidth is not split: it gets a line to itself. Each word is followed by a space, so every line ends with one.

string Wrap(string text, int maxWidth)

Parameters

text string
maxWidth int

Returns

string