textToGlyphs method
Splits the provided text
into a sequence of Glyphs.
Any ligatures are consumed greedily: at every position the longest possible sequence of characters will be matched. If the text contains a character not available in this font, an error will be thrown.
Implementation
@internal
Iterable<Glyph> textToGlyphs(String text) sync* {
for (var i = 0; i < text.length; i++) {
var chain = _data[text.codeUnitAt(i)];
var iNext = i;
var resolvedGlyph = chain?.glyph;
for (var j = i + 1; j < text.length; j++) {
if (chain?.followOn == null) {
break;
}
final jCharCode = text.codeUnitAt(j);
chain = chain!.followOn![jCharCode];
if (chain?.glyph != null) {
iNext = j;
resolvedGlyph = chain?.glyph;
}
}
if (resolvedGlyph == null) {
throw ArgumentError('No glyph data for character "${text[i]}"');
} else {
i = iNext;
yield resolvedGlyph;
}
}
}