@@ -130,9 +130,13 @@ public class PdfType3Font extends PdfSimpleFont<Type3Font> {
130
130
} else {
131
131
fontProgram .getFontMetrics ().setBbox (0 , 0 , 0 , 0 );
132
132
}
133
- PdfNumber firstCharNumber = fontDictionary .getAsNumber (PdfName .FirstChar );
134
- int firstChar = firstCharNumber != null ? Math .max (firstCharNumber .intValue (), 0 ) : 0 ;
133
+ int firstChar = normalizeFirstLastChar (fontDictionary .getAsNumber (PdfName .FirstChar ), 0 );
134
+ int lastChar = normalizeFirstLastChar (fontDictionary .getAsNumber (PdfName .LastChar ), 255 );
135
+ for (int i = firstChar ; i <= lastChar ; i ++) {
136
+ shortTag [i ] = 1 ;
137
+ }
135
138
int [] widths = FontUtil .convertSimpleWidthsArray (fontDictionary .getAsArray (PdfName .Widths ), firstChar , 0 );
139
+
136
140
double [] fontMatrix = new double [6 ];
137
141
for (int i = 0 ; i < fontMatrixArray .size (); i ++) {
138
142
fontMatrix [i ] = ((PdfNumber ) fontMatrixArray .get (i )).getValue ();
@@ -177,7 +181,7 @@ public void setFontWeight(int fontWeight) {
177
181
}
178
182
179
183
/**
180
- * Sets the PostScript italic angel .
184
+ * Sets the PostScript italic angle .
181
185
* <br/>
182
186
* Italic angle in counter-clockwise degrees from the vertical. Zero for upright text, negative for text that leans to the right (forward).
183
187
*
@@ -370,7 +374,6 @@ protected PdfDocument getDocument() {
370
374
return getPdfObject ().getIndirectReference ().getDocument ();
371
375
}
372
376
373
-
374
377
/**
375
378
* Gets first empty code, that could use with {@see addSymbol()}
376
379
*
@@ -386,7 +389,6 @@ private int getFirstEmptyCode() {
386
389
return -1 ;
387
390
}
388
391
389
-
390
392
private void fillFontDescriptor (PdfDictionary fontDesc ) {
391
393
if (fontDesc == null ) {
392
394
return ;
@@ -415,4 +417,10 @@ private void fillFontDescriptor(PdfDictionary fontDesc) {
415
417
setFontFamily (fontFamily .getValue ());
416
418
}
417
419
}
420
+
421
+ private int normalizeFirstLastChar (PdfNumber firstLast , int defaultValue ) {
422
+ if (firstLast == null ) return defaultValue ;
423
+ int result = firstLast .intValue ();
424
+ return result < 0 || result > 255 ? defaultValue : result ;
425
+ }
418
426
}
0 commit comments