@@ -107,8 +107,8 @@ public class PdfType3Font extends PdfSimpleFont<Type3Font> {
107
107
*/
108
108
PdfType3Font (PdfDocument document , String fontName , String fontFamily , boolean colorized ) {
109
109
this (document , colorized );
110
- ((Type3Font )fontProgram ).setFontName (fontName );
111
- ((Type3Font )fontProgram ).setFontFamily (fontFamily );
110
+ ((Type3Font ) fontProgram ).setFontName (fontName );
111
+ ((Type3Font ) fontProgram ).setFontFamily (fontFamily );
112
112
}
113
113
114
114
/**
@@ -157,7 +157,7 @@ public class PdfType3Font extends PdfSimpleFont<Type3Font> {
157
157
* @param fontName the PostScript name of the font, shall not be null or empty.
158
158
*/
159
159
public void setFontName (String fontName ) {
160
- ((Type3Font )fontProgram ).setFontName (fontName );
160
+ ((Type3Font ) fontProgram ).setFontName (fontName );
161
161
}
162
162
163
163
/**
@@ -166,7 +166,7 @@ public void setFontName(String fontName) {
166
166
* @param fontFamily a preferred font family name.
167
167
*/
168
168
public void setFontFamily (String fontFamily ) {
169
- ((Type3Font )fontProgram ).setFontFamily (fontFamily );
169
+ ((Type3Font ) fontProgram ).setFontFamily (fontFamily );
170
170
}
171
171
172
172
/**
@@ -175,7 +175,7 @@ public void setFontFamily(String fontFamily) {
175
175
* @param fontWeight integer form 100 to 900. See {@link FontWeights}.
176
176
*/
177
177
public void setFontWeight (int fontWeight ) {
178
- ((Type3Font )fontProgram ).setFontWeight (fontWeight );
178
+ ((Type3Font ) fontProgram ).setFontWeight (fontWeight );
179
179
}
180
180
181
181
/**
@@ -186,7 +186,7 @@ public void setFontWeight(int fontWeight) {
186
186
* @param italicAngle in counter-clockwise degrees from the vertical
187
187
*/
188
188
public void setItalicAngle (int italicAngle ) {
189
- ((Type3Font )fontProgram ).setItalicAngle (italicAngle );
189
+ ((Type3Font ) fontProgram ).setItalicAngle (italicAngle );
190
190
}
191
191
192
192
/**
@@ -195,17 +195,17 @@ public void setItalicAngle(int italicAngle) {
195
195
* @param fontWidth {@link FontStretches}.
196
196
*/
197
197
public void setFontStretch (String fontWidth ) {
198
- ((Type3Font )fontProgram ).setFontStretch (fontWidth );
198
+ ((Type3Font ) fontProgram ).setFontStretch (fontWidth );
199
199
}
200
200
201
201
/**
202
202
* Sets Font descriptor flags.
203
- * @see FontDescriptorFlags
204
203
*
205
204
* @param flags font descriptor flags.
205
+ * @see FontDescriptorFlags
206
206
*/
207
207
public void setPdfFontFlags (int flags ) {
208
- ((Type3Font )fontProgram ).setPdfFontFlags (flags );
208
+ ((Type3Font ) fontProgram ).setPdfFontFlags (flags );
209
209
}
210
210
211
211
@@ -232,6 +232,15 @@ public void setFontMatrix(double[] fontMatrix) {
232
232
this .fontMatrix = fontMatrix ;
233
233
}
234
234
235
+ /**
236
+ * Gets count of glyphs in Type 3 font.
237
+ *
238
+ * @return number of glyphs.
239
+ */
240
+ public int getGlyphsCount () {
241
+ return ((Type3Font ) getFontProgram ()).getGlyphsCount ();
242
+ }
243
+
235
244
/**
236
245
* Defines a glyph. If the character was already defined it will return the same content
237
246
*
@@ -293,6 +302,32 @@ public boolean containsGlyph(int unicode) {
293
302
&& getFontProgram ().getGlyph (fontEncoding .getUnicodeDifference (unicode )) != null ;
294
303
}
295
304
305
+ @ Override
306
+ public void flush () {
307
+ ensureUnderlyingObjectHasIndirectReference ();
308
+ if (((Type3Font ) getFontProgram ()).getGlyphsCount () < 1 ) {
309
+ throw new PdfException ("no.glyphs.defined.fo r.type3.font" );
310
+ }
311
+
312
+ PdfDictionary charProcs = new PdfDictionary ();
313
+ for (int i = 0 ; i < 256 ; i ++) {
314
+ if (fontEncoding .canDecode (i )) {
315
+ Type3Glyph glyph = getType3Glyph (fontEncoding .getUnicode (i ));
316
+ if (glyph != null ) {
317
+ charProcs .put (new PdfName (fontEncoding .getDifference (i )), glyph .getContentStream ());
318
+ glyph .getContentStream ().flush ();
319
+ }
320
+ }
321
+ }
322
+
323
+ getPdfObject ().put (PdfName .CharProcs , charProcs );
324
+ getPdfObject ().put (PdfName .FontMatrix , new PdfArray (getFontMatrix ()));
325
+ getPdfObject ().put (PdfName .FontBBox , new PdfArray (fontProgram .getFontMetrics ().getBbox ()));
326
+
327
+ super .flushFontData (fontProgram .getFontNames ().getFontName (), PdfName .Type3 );
328
+ super .flush ();
329
+ }
330
+
296
331
@ Override
297
332
protected PdfDictionary getFontDescriptor (String fontName ) {
298
333
if (fontName != null && fontName .length () > 0 ) {
@@ -332,31 +367,6 @@ protected PdfDocument getDocument() {
332
367
return getPdfObject ().getIndirectReference ().getDocument ();
333
368
}
334
369
335
- @ Override
336
- public void flush () {
337
- ensureUnderlyingObjectHasIndirectReference ();
338
- if (((Type3Font ) getFontProgram ()).getGlyphsCount () < 1 ) {
339
- throw new PdfException ("no.glyphs.defined.fo r.type3.font" );
340
- }
341
-
342
- PdfDictionary charProcs = new PdfDictionary ();
343
- for (int i = 0 ; i < 256 ; i ++) {
344
- if (fontEncoding .canDecode (i )) {
345
- Type3Glyph glyph = getType3Glyph (fontEncoding .getUnicode (i ));
346
- if (glyph != null ) {
347
- charProcs .put (new PdfName (fontEncoding .getDifference (i )), glyph .getContentStream ());
348
- glyph .getContentStream ().flush ();
349
- }
350
- }
351
- }
352
-
353
- getPdfObject ().put (PdfName .CharProcs , charProcs );
354
- getPdfObject ().put (PdfName .FontMatrix , new PdfArray (getFontMatrix ()));
355
- getPdfObject ().put (PdfName .FontBBox , new PdfArray (fontProgram .getFontMetrics ().getBbox ()));
356
-
357
- super .flushFontData (fontProgram .getFontNames ().getFontName (), PdfName .Type3 );
358
- super .flush ();
359
- }
360
370
361
371
/**
362
372
* Gets first empty code, that could use with {@see addSymbol()}
0 commit comments