isPdfCompatible property

bool get isPdfCompatible

Whether the font contains TrueType outlines supported by the PDF engine.

Implementation

bool get isPdfCompatible {
  try {
    final bytes = base64Decode(data);
    if (bytes.length < 12) return false;
    final view = ByteData.sublistView(bytes);
    final tableCount = view.getUint16(4);
    final tables = <String>{};
    for (var index = 0; index < tableCount; index++) {
      final offset = 12 + index * 16;
      if (offset + 16 > bytes.length) return false;
      tables.add(ascii.decode(bytes.sublist(offset, offset + 4)));
    }
    return tables.contains('glyf') && tables.contains('loca');
  } catch (_) {
    return false;
  }
}