Showing
1 changed file
with
15 additions
and
4 deletions
@@ -60,9 +60,7 @@ class Font { | @@ -60,9 +60,7 @@ class Font { | ||
60 | 60 | ||
61 | final Type1Fonts font; | 61 | final Type1Fonts font; |
62 | 62 | ||
63 | - @protected | ||
64 | - PdfFont buildFont(PdfDocument pdfDocument) { | ||
65 | - const Map<Type1Fonts, String> type1Map = <Type1Fonts, String>{ | 63 | + static const Map<Type1Fonts, String> _type1Map = <Type1Fonts, String>{ |
66 | Type1Fonts.courier: 'Courier', | 64 | Type1Fonts.courier: 'Courier', |
67 | Type1Fonts.courierBold: 'Courier-Bold', | 65 | Type1Fonts.courierBold: 'Courier-Bold', |
68 | Type1Fonts.courierBoldOblique: 'Courier-BoldOblique', | 66 | Type1Fonts.courierBoldOblique: 'Courier-BoldOblique', |
@@ -79,7 +77,10 @@ class Font { | @@ -79,7 +77,10 @@ class Font { | ||
79 | Type1Fonts.zapfDingbats: 'ZapfDingbats' | 77 | Type1Fonts.zapfDingbats: 'ZapfDingbats' |
80 | }; | 78 | }; |
81 | 79 | ||
82 | - final String fontName = type1Map[font]; | 80 | + String get fontName => _type1Map[font]; |
81 | + | ||
82 | + @protected | ||
83 | + PdfFont buildFont(PdfDocument pdfDocument) { | ||
83 | final PdfFont existing = pdfDocument.fonts.firstWhere( | 84 | final PdfFont existing = pdfDocument.fonts.firstWhere( |
84 | (PdfFont font) => font.subtype == '/Type1' && font.fontName == fontName, | 85 | (PdfFont font) => font.subtype == '/Type1' && font.fontName == fontName, |
85 | orElse: () => null, | 86 | orElse: () => null, |
@@ -132,14 +133,24 @@ class Font { | @@ -132,14 +133,24 @@ class Font { | ||
132 | 133 | ||
133 | return _pdfFont; | 134 | return _pdfFont; |
134 | } | 135 | } |
136 | + | ||
137 | + @override | ||
138 | + String toString() => '<Type1 Font "$fontName">'; | ||
135 | } | 139 | } |
136 | 140 | ||
137 | class TtfFont extends Font { | 141 | class TtfFont extends Font { |
138 | TtfFont(this.data); | 142 | TtfFont(this.data); |
139 | 143 | ||
140 | final ByteData data; | 144 | final ByteData data; |
145 | + | ||
141 | @override | 146 | @override |
142 | PdfFont buildFont(PdfDocument pdfDocument) { | 147 | PdfFont buildFont(PdfDocument pdfDocument) { |
143 | return PdfTtfFont(pdfDocument, data); | 148 | return PdfTtfFont(pdfDocument, data); |
144 | } | 149 | } |
150 | + | ||
151 | + @override | ||
152 | + String toString() { | ||
153 | + final TtfParser font = TtfParser(data); | ||
154 | + return '<TrueType Font "${font.fontName}">'; | ||
155 | + } | ||
145 | } | 156 | } |
-
Please register or login to post a comment