David PHAM-VAN

Add Font::toString()

... ... @@ -60,9 +60,7 @@ class Font {
final Type1Fonts font;
@protected
PdfFont buildFont(PdfDocument pdfDocument) {
const Map<Type1Fonts, String> type1Map = <Type1Fonts, String>{
static const Map<Type1Fonts, String> _type1Map = <Type1Fonts, String>{
Type1Fonts.courier: 'Courier',
Type1Fonts.courierBold: 'Courier-Bold',
Type1Fonts.courierBoldOblique: 'Courier-BoldOblique',
... ... @@ -79,7 +77,10 @@ class Font {
Type1Fonts.zapfDingbats: 'ZapfDingbats'
};
final String fontName = type1Map[font];
String get fontName => _type1Map[font];
@protected
PdfFont buildFont(PdfDocument pdfDocument) {
final PdfFont existing = pdfDocument.fonts.firstWhere(
(PdfFont font) => font.subtype == '/Type1' && font.fontName == fontName,
orElse: () => null,
... ... @@ -132,14 +133,24 @@ class Font {
return _pdfFont;
}
@override
String toString() => '<Type1 Font "$fontName">';
}
class TtfFont extends Font {
TtfFont(this.data);
final ByteData data;
@override
PdfFont buildFont(PdfDocument pdfDocument) {
return PdfTtfFont(pdfDocument, data);
}
@override
String toString() {
final TtfParser font = TtfParser(data);
return '<TrueType Font "${font.fontName}">';
}
}
... ...