SpriteFont constructor
SpriteFont({})
Implementation
SpriteFont({
required this.source,
required this.size,
required this.ascent,
required List<Glyph> glyphs,
double? defaultCharWidth,
}) : _data = <int, _Chain>{} {
for (final glyph in glyphs) {
var data = _data;
for (var i = 0; i < glyph.char.length - 1; i++) {
final j = glyph.char.codeUnitAt(i);
data = (data[j] ??= _Chain()).followOn ??= <int, _Chain>{};
}
final j = glyph.char.codeUnitAt(glyph.char.length - 1);
final chain = data[j] ??= _Chain();
assert(
chain.glyph == null,
'Duplicate definition for glyph "${glyph.char}"',
);
glyph.initialize(defaultCharWidth ?? size, size);
chain.glyph = glyph;
}
}