putText method

  1. @override
void putText(
  1. PdfStream stream,
  2. String text
)
override

Draw some text

Implementation

@override
void putText(PdfStream stream, String text) {
  if (!_useType0) {
    // Without the return the simple encoding is emitted and then the hex CID
    // string is appended on top of it, corrupting the text.
    return super.putText(stream, text);
  }

  final runes = text.runes;

  stream.putByte(0x3c);
  for (final rune in runes) {
    var char = unicodeCMap.cmap.indexOf(rune);
    if (char == -1) {
      char = unicodeCMap.cmap.length;
      unicodeCMap.cmap.add(rune);
    }

    stream.putBytes(latin1.encode(char.toRadixString(16).padLeft(4, '0')));
  }
  stream.putByte(0x3e);
}