SpriteFont class

SpriteFont contains information about a custom font stored in an asset file.

The source parameter is the Image where the font's characters are located. The layout of this image can be arbitrary, however, all characters for the font must be in the same source image.

The size property describes the font size of the sprite font. This font size must be the same for all characters in the font.

The ascent property measures the distance from the top of a character to its baseline. This property must be equal for all characters in the font.

The main information about the font is in the glyphs list of the constructor. Each Glyph in this list describes a single character (or a ligature) within the source image.

The SpriteFont can be either variable-width or monospace. For a monospace font you can pass the defaultCharWidth parameter in the constructor so that you wouldn't have to specify the width of each glyph.

Constructors

SpriteFont({required Image source, required double size, required double ascent, required List<Glyph> glyphs, double? defaultCharWidth})

Properties

ascent double
The distance from the top of every character to its baseline.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size double
The font size, i.e. the height of all characters in the font.
final
source Image
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
textToGlyphs(String text) Iterable<Glyph>
Splits the provided text into a sequence of Glyphs.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited