render method

  1. @override
void render()
override

Implementation

@override
void render() {
  _context.font = '${_font.size * _scale}px ${_font.family}, monospace';

  _display.render((x, y, glyph) {
    var char = glyph.char;

    // Fill the background.
    _context.fillStyle = glyph.back.cssColor;
    _context.fillRect(
        x * _font.charWidth * _scale,
        y * _font.lineHeight * _scale,
        _font.charWidth * _scale,
        _font.lineHeight * _scale);

    // Don't bother drawing empty characters.
    if (char == 0 || char == CharCode.space) return;

    _context.fillStyle = glyph.fore.cssColor;
    _context.fillText(
        String.fromCharCodes([char]),
        (x * _font.charWidth + _font.x) * _scale,
        (y * _font.lineHeight + _font.y) * _scale);
  });
}