GlyphRenderer constructor
GlyphRenderer()
Create a new GlyphRenderer using the given glyphSrc
path or URL to the
glyph sheet, a Map of character codes to glyph indices in the glyph
sheet, and the size of a single glyph in pixels. Also provide a canvas 2D
rendering context
and a scale
value for better rendering on
high-density displays (e.g., Apple Retina screens).
Implementation
GlyphRenderer(String glyphSrc, this._charToGlyphIndex, this._charSize,
html.CanvasRenderingContext2D context, int scale)
: _maxGlyphIndex = _charToGlyphIndex.values.reduce(math.max),
super(scale, context) {
// setup glyphs image loading handling
_glyphsOnLoad = _glyphs.onLoad.first;
_glyphs.onError.first.then(
(e) => throw StateError('Failed to load glyphs from ${_glyphs.src}'));
// start loading the image
_glyphs.src = glyphSrc;
print('CHAR width ${_charSize.x}, height ${_charSize.y}');
}