Showing
1 changed file
with
29 additions
and
18 deletions
@@ -60,26 +60,27 @@ class Font { | @@ -60,26 +60,27 @@ class Font { | ||
60 | 60 | ||
61 | final Type1Fonts font; | 61 | final Type1Fonts font; |
62 | 62 | ||
63 | + static const Map<Type1Fonts, String> _type1Map = <Type1Fonts, String>{ | ||
64 | + Type1Fonts.courier: 'Courier', | ||
65 | + Type1Fonts.courierBold: 'Courier-Bold', | ||
66 | + Type1Fonts.courierBoldOblique: 'Courier-BoldOblique', | ||
67 | + Type1Fonts.courierOblique: 'Courier-Oblique', | ||
68 | + Type1Fonts.helvetica: 'Helvetica', | ||
69 | + Type1Fonts.helveticaBold: 'Helvetica-Bold', | ||
70 | + Type1Fonts.helveticaBoldOblique: 'Helvetica-BoldOblique', | ||
71 | + Type1Fonts.helveticaOblique: 'Helvetica-Oblique', | ||
72 | + Type1Fonts.times: 'Times-Roman', | ||
73 | + Type1Fonts.timesBold: 'Times-Bold', | ||
74 | + Type1Fonts.timesBoldItalic: 'Times-BoldItalic', | ||
75 | + Type1Fonts.timesItalic: 'Times-Italic', | ||
76 | + Type1Fonts.symbol: 'Symbol', | ||
77 | + Type1Fonts.zapfDingbats: 'ZapfDingbats' | ||
78 | + }; | ||
79 | + | ||
80 | + String get fontName => _type1Map[font]; | ||
81 | + | ||
63 | @protected | 82 | @protected |
64 | PdfFont buildFont(PdfDocument pdfDocument) { | 83 | PdfFont buildFont(PdfDocument pdfDocument) { |
65 | - const Map<Type1Fonts, String> type1Map = <Type1Fonts, String>{ | ||
66 | - Type1Fonts.courier: 'Courier', | ||
67 | - Type1Fonts.courierBold: 'Courier-Bold', | ||
68 | - Type1Fonts.courierBoldOblique: 'Courier-BoldOblique', | ||
69 | - Type1Fonts.courierOblique: 'Courier-Oblique', | ||
70 | - Type1Fonts.helvetica: 'Helvetica', | ||
71 | - Type1Fonts.helveticaBold: 'Helvetica-Bold', | ||
72 | - Type1Fonts.helveticaBoldOblique: 'Helvetica-BoldOblique', | ||
73 | - Type1Fonts.helveticaOblique: 'Helvetica-Oblique', | ||
74 | - Type1Fonts.times: 'Times-Roman', | ||
75 | - Type1Fonts.timesBold: 'Times-Bold', | ||
76 | - Type1Fonts.timesBoldItalic: 'Times-BoldItalic', | ||
77 | - Type1Fonts.timesItalic: 'Times-Italic', | ||
78 | - Type1Fonts.symbol: 'Symbol', | ||
79 | - Type1Fonts.zapfDingbats: 'ZapfDingbats' | ||
80 | - }; | ||
81 | - | ||
82 | - final String fontName = type1Map[font]; | ||
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