Skip to content

Commit bb82281

Browse files
committed
Update javadoc in FontProgramFactory and PdfFontFactory
1 parent 957b0c3 commit bb82281

File tree

2 files changed

+46
-43
lines changed

2 files changed

+46
-43
lines changed

io/src/main/java/com/itextpdf/io/font/FontProgramFactory.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private FontProgramFactory() {
7373
* Creates a new standard Helvetica font program file.
7474
*
7575
* @return a {@link FontProgram} object with Helvetica font description
76-
* @throws java.io.IOException
76+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
7777
*/
7878
public static FontProgram createFont() throws java.io.IOException {
7979
return createFont(StandardFonts.HELVETICA);
@@ -92,7 +92,7 @@ public static FontProgram createFont() throws java.io.IOException {
9292
*
9393
* @param fontProgram the name of the font or its location on file
9494
* @return returns a new {@link FontProgram}. This font program may come from the cache
95-
* @throws java.io.IOException
95+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
9696
*/
9797
public static FontProgram createFont(String fontProgram) throws java.io.IOException {
9898
return createFont(fontProgram, null, DEFAULT_CACHED);
@@ -112,7 +112,7 @@ public static FontProgram createFont(String fontProgram) throws java.io.IOExcept
112112
* @param fontProgram the name of the font or its location on file
113113
* @param cached whether to to cache this font program after it has been loaded
114114
* @return returns a new {@link FontProgram}. This font program may come from the cache
115-
* @throws java.io.IOException
115+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
116116
*/
117117
public static FontProgram createFont(String fontProgram, boolean cached) throws java.io.IOException {
118118
return createFont(fontProgram, null, cached);
@@ -131,7 +131,7 @@ public static FontProgram createFont(String fontProgram, boolean cached) throws
131131
*
132132
* @param fontProgram the byte contents of the font program
133133
* @return returns a new {@link FontProgram}. This font program may come from the cache
134-
* @throws java.io.IOException
134+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
135135
*/
136136
public static FontProgram createFont(byte[] fontProgram) throws java.io.IOException {
137137
return createFont(null, fontProgram, DEFAULT_CACHED);
@@ -151,7 +151,7 @@ public static FontProgram createFont(byte[] fontProgram) throws java.io.IOExcept
151151
* @param fontProgram the byte contents of the font program
152152
* @param cached whether to to cache this font program
153153
* @return returns a new {@link FontProgram}. This font program may come from the cache
154-
* @throws java.io.IOException
154+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
155155
*/
156156
public static FontProgram createFont(byte[] fontProgram, boolean cached) throws java.io.IOException {
157157
return createFont(null, fontProgram, cached);
@@ -256,7 +256,7 @@ private static FontProgram createFont(String name, byte[] fontProgram, boolean c
256256
* @param afm the contents of the AFM or PFM metrics file
257257
* @param pfb the contents of the PFB file
258258
* @return created {@link FontProgram} instance
259-
* @throws java.io.IOException
259+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
260260
*/
261261
public static FontProgram createType1Font(byte[] afm, byte[] pfb) throws java.io.IOException {
262262
return createType1Font(afm, pfb, DEFAULT_CACHED);
@@ -269,7 +269,7 @@ public static FontProgram createType1Font(byte[] afm, byte[] pfb) throws java.io
269269
* @param pfb the contents of the PFB file
270270
* @param cached specifies whether to cache the created {@link FontProgram} or not
271271
* @return created {@link FontProgram} instance
272-
* @throws java.io.IOException
272+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
273273
*/
274274
public static FontProgram createType1Font(byte[] afm, byte[] pfb, boolean cached) throws java.io.IOException {
275275
return createType1Font(null, null, afm, pfb, cached);
@@ -281,7 +281,7 @@ public static FontProgram createType1Font(byte[] afm, byte[] pfb, boolean cached
281281
* @param metricsPath path to the AFM or PFM metrics file
282282
* @param binaryPath path to the contents of the PFB file
283283
* @return created {@link FontProgram} instance
284-
* @throws java.io.IOException
284+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
285285
*/
286286
public static FontProgram createType1Font(String metricsPath, String binaryPath) throws java.io.IOException {
287287
return createType1Font(metricsPath, binaryPath, DEFAULT_CACHED);
@@ -294,7 +294,7 @@ public static FontProgram createType1Font(String metricsPath, String binaryPath)
294294
* @param binaryPath path to the contents of the PFB file
295295
* @param cached specifies whether to cache the created {@link FontProgram} or not
296296
* @return created {@link FontProgram} instance
297-
* @throws java.io.IOException
297+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
298298
*/
299299
public static FontProgram createType1Font(String metricsPath, String binaryPath, boolean cached) throws java.io.IOException {
300300
return createType1Font(metricsPath, binaryPath, null, null, cached);
@@ -309,7 +309,7 @@ public static FontProgram createType1Font(String metricsPath, String binaryPath,
309309
* the cache if new, false if the font is always created new
310310
* @return returns a new {@link FontProgram} instance. This font may come from the cache but only if cached
311311
* is true, otherwise it will always be created new
312-
* @throws java.io.IOException
312+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
313313
*/
314314
public static FontProgram createFont(String ttc, int ttcIndex, boolean cached) throws java.io.IOException {
315315
FontCacheKey fontCacheKey = FontCacheKey.create(ttc, ttcIndex);
@@ -332,7 +332,7 @@ public static FontProgram createFont(String ttc, int ttcIndex, boolean cached) t
332332
* the cache if new, false if the font is always created new
333333
* @return returns a new {@link FontProgram} instance. This font may come from the cache but only if cached
334334
* is true, otherwise it will always be created new
335-
* @throws java.io.IOException
335+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
336336
*/
337337
public static FontProgram createFont(byte[] ttc, int ttcIndex, boolean cached) throws java.io.IOException {
338338
FontCacheKey fontKey = FontCacheKey.create(ttc, ttcIndex);
@@ -356,7 +356,7 @@ public static FontProgram createFont(byte[] ttc, int ttcIndex, boolean cached) t
356356
* {@link FontStyles#BOLDITALIC}, {@link FontStyles#UNDEFINED}
357357
* @param cached whether to try to get the font program from cache
358358
* @return created {@link FontProgram}
359-
* @throws java.io.IOException
359+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
360360
*/
361361
public static FontProgram createRegisteredFont(String fontName, int style, boolean cached) throws java.io.IOException {
362362
return fontRegisterProvider.getFont(fontName, style, cached);
@@ -371,7 +371,7 @@ public static FontProgram createRegisteredFont(String fontName, int style, boole
371371
* See {@link FontStyles#BOLD}, {@link FontStyles#ITALIC}, {@link FontStyles#NORMAL},
372372
* {@link FontStyles#BOLDITALIC}, {@link FontStyles#UNDEFINED}
373373
* @return created {@link FontProgram}
374-
* @throws java.io.IOException
374+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file
375375
*/
376376
public static FontProgram createRegisteredFont(String fontName, int style) throws java.io.IOException {
377377
return fontRegisterProvider.getFont(fontName, style);
@@ -383,7 +383,7 @@ public static FontProgram createRegisteredFont(String fontName, int style) throw
383383
* @param fontName either a font alias, if the font file has been registered with an alias,
384384
* or just a font name otherwise
385385
* @return created {@link FontProgram}
386-
* @throws java.io.IOException
386+
* @throws java.io.IOException exception is thrown in case an I/O error occurs when reading the file2
387387
*/
388388
public static FontProgram createRegisteredFont(String fontName) throws java.io.IOException {
389389
return fontRegisterProvider.getFont(fontName, FontStyles.UNDEFINED);
@@ -496,6 +496,9 @@ private static FontCacheKey createFontCacheKey(String name, byte[] fontProgram)
496496

497497
public static void clearRegisteredFonts() { fontRegisterProvider.clearRegisteredFonts(); }
498498

499+
/**
500+
* Clears registered font cache
501+
*/
499502
public static void clearRegisteredFontFamilies() { fontRegisterProvider.clearRegisteredFontFamilies(); }
500503

501504
static byte[] readFontBytesFromPath(String path) throws java.io.IOException {

kernel/src/main/java/com/itextpdf/kernel/font/PdfFontFactory.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ This file is part of the iText (R) project.
6161

6262
/**
6363
* This class provides helpful methods for creating fonts ready to be used in a {@link PdfDocument}
64-
*
64+
* <p>
6565
* Note, just created {@link PdfFont} is almost empty until it will be flushed,
6666
* because it is impossible to fulfill font data until flush.
6767
*/
@@ -95,12 +95,12 @@ public static PdfFont createFont() throws IOException {
9595

9696
/**
9797
* Creates a {@link PdfFont} by already existing font dictionary.
98-
*
98+
* <p>
9999
* Note, the font won't be added to any document,
100100
* until you add it to {@link com.itextpdf.kernel.pdf.canvas.PdfCanvas}.
101101
* While adding to {@link com.itextpdf.kernel.pdf.canvas.PdfCanvas}, or to
102102
* {@link com.itextpdf.kernel.pdf.PdfResources} the font will be made indirect implicitly.
103-
*
103+
* <p>
104104
* {@link PdfDocument#getFont} method is strongly recommended if you want to get PdfFont by both
105105
* existing font dictionary, or just created and hasn't flushed yet.
106106
*
@@ -290,7 +290,7 @@ public static PdfFont createFont(FontProgram fontProgram) {
290290
* Created a {@link PdfFont} instance by the bytes of the underlying font program.
291291
*
292292
* @param fontProgram the bytes of the underlying font program
293-
* @param encoding
293+
* @param encoding the encoding of the font to be created. See {@link PdfEncodings}
294294
* @return created {@link PdfFont} instance
295295
* @throws IOException signals that an I/O exception has occurred.
296296
*/
@@ -365,12 +365,12 @@ public static PdfType3Font createType3Font(PdfDocument document, String fontName
365365
/**
366366
* Creates {@link PdfFont} based on registered {@link FontProgram}'s.
367367
*
368-
* @param fontName
369-
* @param encoding
370-
* @param embedded
371-
* @param style
372-
* @param cached
373-
* @throws IOException
368+
* @param fontName Path to font file or Standard font name
369+
* @param encoding Font encoding from {@link PdfEncodings}.
370+
* @param embedded if true font will be embedded. Note, standard font won't be embedded in any case.
371+
* @param style Font style from {@link FontStyles}.
372+
* @param cached If true font will be cached for another PdfDocument
373+
* @throws IOException exception is thrown in case an I/O error occurs when reading the file
374374
* @see PdfFontFactory#register(String)
375375
* @see PdfFontFactory#register(String, String)
376376
* @see PdfFontFactory#registerFamily(String, String, String)
@@ -387,11 +387,11 @@ public static PdfFont createRegisteredFont(String fontName, String encoding, boo
387387
/**
388388
* Creates {@link PdfFont} based on registered {@link FontProgram}'s.
389389
*
390-
* @param fontName
391-
* @param encoding
392-
* @param embedded
393-
* @param cached
394-
* @throws IOException
390+
* @param fontName Path to font file or Standard font name
391+
* @param encoding Font encoding from {@link PdfEncodings}.
392+
* @param embedded if true font will be embedded. Note, standard font won't be embedded in any case.
393+
* @param cached If true font will be cached for another PdfDocument
394+
* @throws IOException exception is thrown in case an I/O error occurs when reading the file
395395
* @see PdfFontFactory#register(String)
396396
* @see PdfFontFactory#register(String, String)
397397
* @see PdfFontFactory#registerFamily(String, String, String)
@@ -407,10 +407,10 @@ public static PdfFont createRegisteredFont(String fontName, String encoding, boo
407407
/**
408408
* Creates {@link PdfFont} based on registered {@link FontProgram}'s.
409409
*
410-
* @param fontName
411-
* @param encoding
412-
* @param embedded
413-
* @throws IOException
410+
* @param fontName Path to font file or Standard font name
411+
* @param encoding Font encoding from {@link PdfEncodings}.
412+
* @param embedded if true font will be embedded. Note, standard font won't be embedded in any case.
413+
* @throws IOException exception is thrown in case an I/O error occurs when reading the file
414414
* @see PdfFontFactory#register(String)
415415
* @see PdfFontFactory#register(String, String)
416416
* @see PdfFontFactory#registerFamily(String, String, String)
@@ -426,11 +426,11 @@ public static PdfFont createRegisteredFont(String fontName, String encoding, boo
426426
/**
427427
* Creates {@link PdfFont} based on registered {@link FontProgram}'s.
428428
*
429-
* @param fontName
430-
* @param encoding
431-
* @param embedded
432-
* @param style
433-
* @throws IOException
429+
* @param fontName Path to font file or Standard font name
430+
* @param encoding Font encoding from {@link PdfEncodings}.
431+
* @param embedded if true font will be embedded. Note, standard font won't be embedded in any case.
432+
* @param style Font style from {@link FontStyles}.
433+
* @throws IOException exception is thrown in case an I/O error occurs when reading the file
434434
* @see PdfFontFactory#register(String)
435435
* @see PdfFontFactory#register(String, String)
436436
* @see PdfFontFactory#registerFamily(String, String, String)
@@ -446,9 +446,9 @@ public static PdfFont createRegisteredFont(String fontName, String encoding, boo
446446
/**
447447
* Creates {@link PdfFont} based on registered {@link FontProgram}'s.
448448
*
449-
* @param fontName
450-
* @param encoding
451-
* @throws IOException
449+
* @param fontName Path to font file or Standard font name
450+
* @param encoding Font encoding from {@link PdfEncodings}.
451+
* @throws IOException exception is thrown in case an I/O error occurs when reading the file
452452
* @see PdfFontFactory#register(String)
453453
* @see PdfFontFactory#register(String, String)
454454
* @see PdfFontFactory#registerFamily(String, String, String)
@@ -464,8 +464,8 @@ public static PdfFont createRegisteredFont(String fontName, String encoding) thr
464464
/**
465465
* Creates {@link PdfFont} based on registered {@link FontProgram}'s.
466466
*
467-
* @param fontName
468-
* @throws IOException
467+
* @param fontName Path to font file or Standard font name
468+
* @throws IOException exception is thrown in case an I/O error occurs when reading the file
469469
* @see PdfFontFactory#register(String)
470470
* @see PdfFontFactory#register(String, String)
471471
* @see PdfFontFactory#registerFamily(String, String, String)

0 commit comments

Comments
 (0)