Showing
1 changed file
with
18 additions
and
0 deletions
| @@ -137,9 +137,18 @@ abstract class PdfFont extends PdfObject { | @@ -137,9 +137,18 @@ abstract class PdfFont extends PdfObject { | ||
| 137 | return PdfFontMetrics.zero; | 137 | return PdfFontMetrics.zero; |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | + try { | ||
| 140 | final Uint8List chars = latin1.encode(s); | 141 | final Uint8List chars = latin1.encode(s); |
| 141 | final Iterable<PdfFontMetrics> metrics = chars.map(glyphMetrics); | 142 | final Iterable<PdfFontMetrics> metrics = chars.map(glyphMetrics); |
| 142 | return PdfFontMetrics.append(metrics); | 143 | return PdfFontMetrics.append(metrics); |
| 144 | + } catch (e) { | ||
| 145 | + assert(false, '''\n--------------------------------------------- | ||
| 146 | +Can not decode the string to Latin1. | ||
| 147 | +This font does not support Unicode characters. | ||
| 148 | +If you want to use strings other than Latin strings, use a TrueType (TTF) font instead. | ||
| 149 | +---------------------------------------------'''); | ||
| 150 | + rethrow; | ||
| 151 | + } | ||
| 143 | } | 152 | } |
| 144 | 153 | ||
| 145 | // Use stringMetrics instead | 154 | // Use stringMetrics instead |
| @@ -155,9 +164,18 @@ abstract class PdfFont extends PdfObject { | @@ -155,9 +164,18 @@ abstract class PdfFont extends PdfObject { | ||
| 155 | String toString() => 'Font($fontName)'; | 164 | String toString() => 'Font($fontName)'; |
| 156 | 165 | ||
| 157 | PdfStream putText(String text) { | 166 | PdfStream putText(String text) { |
| 167 | + try { | ||
| 158 | return PdfStream() | 168 | return PdfStream() |
| 159 | ..putBytes(latin1.encode('(')) | 169 | ..putBytes(latin1.encode('(')) |
| 160 | ..putTextBytes(latin1.encode(text)) | 170 | ..putTextBytes(latin1.encode(text)) |
| 161 | ..putBytes(latin1.encode(')')); | 171 | ..putBytes(latin1.encode(')')); |
| 172 | + } catch (e) { | ||
| 173 | + assert(false, '''\n--------------------------------------------- | ||
| 174 | +Can not decode the string to Latin1. | ||
| 175 | +This font does not support Unicode characters. | ||
| 176 | +If you want to use strings other than Latin strings, use a TrueType (TTF) font instead. | ||
| 177 | +---------------------------------------------'''); | ||
| 178 | + rethrow; | ||
| 179 | + } | ||
| 162 | } | 180 | } |
| 163 | } | 181 | } |
-
Please register or login to post a comment