RasterTerminalRenderer constructor

RasterTerminalRenderer({
  1. required RasterFont font,
  2. RasterRenderOptions options = const RasterRenderOptions(),
})

Creates an offscreen renderer with fixed font and color policy.

Implementation

RasterTerminalRenderer({
  required this.font,
  this.options = const RasterRenderOptions(),
}) : _palette = options.palette == null
         ? null
         : List.unmodifiable(options.palette!) {
  _validateOptions();
  _cellWidth =
      options.cellWidth ??
      font._regular
          .getAdvanceWidth(font._regular.getGlyphId(32)!, options.fontSize)
          .ceil();
  _cellHeight =
      options.cellHeight ??
      font._regular.metrics.lineHeightAt(options.fontSize).ceil();
  _baseline = font._regular.metrics
      .baselineOffsetAt(options.fontSize)
      .round();
  if (_cellWidth <= 0 || _cellHeight <= 0) {
    throw ArgumentError('Font metrics produce an empty cell');
  }
}