setFont method

void setFont(
  1. PdfFont font,
  2. double size, {
  3. double? charSpace,
  4. double? wordSpace,
  5. double? scale,
  6. PdfTextRenderingMode mode = PdfTextRenderingMode.fill,
  7. double? rise,
})

Set the current font and size

Implementation

void setFont(
  PdfFont font,
  double size, {
  double? charSpace,
  double? wordSpace,
  double? scale,
  PdfTextRenderingMode mode = PdfTextRenderingMode.fill,
  double? rise,
}) {
  var o = 0;
  assert(() {
    if (_page.pdfDocument.settings.verbose) {
      o = _buf.offset;
      _buf.putString(' ' * (_indent));
    }
    return true;
  }());

  _page.addFont(font);

  _buf.putString('${font.name} ');
  PdfNum(size).output(_page, _buf);
  _buf.putString(' Tf ');
  if (charSpace != null) {
    PdfNum(charSpace).output(_page, _buf);
    _buf.putString(' Tc ');
  }
  if (wordSpace != null) {
    PdfNum(wordSpace).output(_page, _buf);
    _buf.putString(' Tw ');
  }
  if (scale != null) {
    PdfNum(scale * 100).output(_page, _buf);
    _buf.putString(' Tz ');
  }
  if (rise != null) {
    PdfNum(rise).output(_page, _buf);
    _buf.putString(' Ts ');
  }
  if (mode != PdfTextRenderingMode.fill) {
    _buf.putString('${mode.index} Tr ');
  }

  assert(() {
    if (_page.pdfDocument.settings.verbose) {
      _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
      _buf.putComment(
          'setFont(${font.ref()}, size: $size, charSpace: $charSpace, wordSpace: $wordSpace, scale: $scale, mode: ${mode.name}, rise: $rise)');
    }
    return true;
  }());
}