stringMetrics method

PdfFontMetrics stringMetrics(
  1. String s, {
  2. double letterSpacing = 0,
})

Calculate the PdfFontMetrics for this string

Implementation

PdfFontMetrics stringMetrics(String s, {double letterSpacing = 0}) {
  if (s.isEmpty) {
    return PdfFontMetrics.zero;
  }

  try {
    final chars = latin1.encode(s);
    final metrics = chars.map(glyphMetrics);
    return PdfFontMetrics.append(metrics, letterSpacing: letterSpacing);
  } catch (_) {
    assert(() {
      print(_cannotDecodeMessage);
      return true;
    }());

    rethrow;
  }
}