Skip to content

Commit 59e73bb

Browse files
committed
Merge branch 'develop' into layoutsharp2
Conflicts: layout/src/main/java/com/itextpdf/layout/ElementPropertyContainer.java layout/src/main/java/com/itextpdf/layout/IPropertyContainer.java layout/src/main/java/com/itextpdf/layout/RootElement.java layout/src/main/java/com/itextpdf/layout/element/AbstractElement.java layout/src/main/java/com/itextpdf/layout/element/BlockElement.java layout/src/main/java/com/itextpdf/layout/element/Cell.java layout/src/main/java/com/itextpdf/layout/element/Image.java layout/src/main/java/com/itextpdf/layout/element/List.java layout/src/main/java/com/itextpdf/layout/element/Paragraph.java layout/src/main/java/com/itextpdf/layout/element/Text.java layout/src/main/java/com/itextpdf/layout/property/Property.java layout/src/main/java/com/itextpdf/layout/renderer/AbstractRenderer.java layout/src/main/java/com/itextpdf/layout/renderer/AreaBreakRenderer.java layout/src/main/java/com/itextpdf/layout/renderer/IRenderer.java layout/src/main/java/com/itextpdf/layout/renderer/ParagraphRenderer.java layout/src/main/java/com/itextpdf/layout/renderer/TextRenderer.java
2 parents a34feaa + 1965698 commit 59e73bb

File tree

119 files changed

+1383
-1050
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1383
-1050
lines changed

barcodes/src/main/java/com/itextpdf/barcodes/Barcode1D.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public abstract class Barcode1D {
145145
*/
146146
protected String altText;
147147

148-
public Barcode1D(PdfDocument document) {
148+
protected Barcode1D(PdfDocument document) {
149149
this.document = document;
150150
}
151151

barcodes/src/main/java/com/itextpdf/barcodes/Barcode2D.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ public abstract class Barcode2D {
5454

5555
protected static final float DEFAULT_MODULE_SIZE = 1;
5656

57-
public Barcode2D() {
58-
}
59-
6057
/**
6158
* Gets the maximum area that the barcode and the text, if
6259
* any, will occupy. The lower left corner is always (0, 0).

forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ This file is part of the iText (R) project.
4444
*/
4545
package com.itextpdf.forms.fields;
4646

47+
import com.itextpdf.io.image.ImageDataFactory;
4748
import com.itextpdf.kernel.PdfException;
4849
import com.itextpdf.kernel.color.Color;
4950
import com.itextpdf.kernel.color.DeviceCmyk;
@@ -74,7 +75,6 @@ This file is part of the iText (R) project.
7475
import com.itextpdf.io.font.FontConstants;
7576
import com.itextpdf.io.font.PdfEncodings;
7677
import com.itextpdf.io.image.ImageData;
77-
import com.itextpdf.io.image.ImageFactory;
7878
import com.itextpdf.io.source.PdfTokenizer;
7979
import com.itextpdf.io.source.RandomAccessFileOrArray;
8080
import com.itextpdf.io.source.RandomAccessSourceFactory;
@@ -914,7 +914,7 @@ public PdfFormField setValue(String value, boolean generateAppearance) {
914914
} else if (PdfName.Btn.equals(formType)) {
915915
if ((getFieldFlags() & PdfButtonFormField.FF_PUSH_BUTTON) != 0) {
916916
try {
917-
img = ImageFactory.getImage(Base64.decode(value));
917+
img = ImageDataFactory.create(Base64.decode(value));
918918
} catch (Exception e) {
919919
text = value;
920920
}

io/src/main/java/com/itextpdf/io/LogMessageConstant.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ This file is part of the iText (R) project.
4747
/**
4848
* Class containing constants to be used in logging.
4949
*/
50-
public class LogMessageConstant {
50+
public final class LogMessageConstant {
5151

5252
/**
5353
* Log message.
@@ -173,4 +173,6 @@ public class LogMessageConstant {
173173
public static final String WRITER_ENCRYPTION_IS_IGNORED_APPEND = "Writer encryption will be ignored, because append mode is used. Document will preserve the original encryption (or will stay unencrypted)";
174174

175175
public static final String WRITER_ENCRYPTION_IS_IGNORED_PRESERVE = "Writer encryption will be ignored, because preservation of encryption is enabled. Document will preserve the original encryption (or will stay unencrypted)";
176+
177+
public static final String EXCEPTION_WHILE_UPDATING_XMPMETADATA = "Exception while updating XmpMetadata";
176178
}

io/src/main/java/com/itextpdf/io/font/FontFactory.java renamed to io/src/main/java/com/itextpdf/io/font/FontProgramFactory.java

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ This file is part of the iText (R) project.
5353
/**
5454
* Provides methods for creating various types of fonts.
5555
*/
56-
public class FontFactory {
56+
public final class FontProgramFactory {
57+
58+
private FontProgramFactory() {
59+
}
5760

5861
private static FontRegisterProvider fontRegisterProvider = new FontRegisterProvider();
5962

@@ -203,7 +206,7 @@ public static FontProgram createFont(String font, boolean cached) throws java.io
203206
*
204207
* @param font the true type font or the afm in a byte array
205208
* an exception if the font is not recognized. Note that even if true an exception may be thrown in some circumstances.
206-
* This parameter is useful for FontFactory that may have to check many invalid font names before finding the right one
209+
* This parameter is useful for FontProgramFactory that may have to check many invalid font names before finding the right one
207210
* @return returns a new font. This font may come from the cache but only if cached
208211
* is true, otherwise it will always be created new
209212
*/
@@ -470,18 +473,17 @@ public static FontProgram createRegisteredFont(String fontName) throws java.io.I
470473
* @param fullName the font name
471474
* @param path the font path
472475
*/
473-
public static void registerFamily(String familyName, String fullName, String path) {
474-
fontRegisterProvider.registerFamily(familyName, fullName, path);
476+
public static void registerFontFamily(String familyName, String fullName, String path) {
477+
fontRegisterProvider.registerFontFamily(familyName, fullName, path);
475478
}
476479

477480
/**
478481
* Register a ttf- or a ttc-file.
479482
*
480483
* @param path the path to a ttf- or ttc-file
481484
*/
482-
483-
public static void register(String path) {
484-
register(path, null);
485+
public static void registerFont(String path) {
486+
registerFont(path, null);
485487
}
486488

487489
/**
@@ -490,9 +492,8 @@ public static void register(String path) {
490492
* @param path the path to a font file
491493
* @param alias the alias you want to use for the font
492494
*/
493-
494-
public static void register(String path, String alias) {
495-
fontRegisterProvider.register(path, alias);
495+
public static void registerFont(String path, String alias) {
496+
fontRegisterProvider.registerFont(path, alias);
496497
}
497498

498499
/**
@@ -501,8 +502,8 @@ public static void register(String path, String alias) {
501502
* @param dir the directory
502503
* @return the number of fonts registered
503504
*/
504-
public static int registerDirectory(String dir) {
505-
return fontRegisterProvider.registerDirectory(dir);
505+
public static int registerFontDirectory(String dir) {
506+
return fontRegisterProvider.registerFontDirectory(dir);
506507
}
507508

508509
/**
@@ -511,16 +512,15 @@ public static int registerDirectory(String dir) {
511512
*
512513
* @return the number of fonts registered
513514
*/
514-
public static int registerSystemDirectories() {
515-
return fontRegisterProvider.registerSystemDirectories();
515+
public static int registerSystemFontDirectories() {
516+
return fontRegisterProvider.registerSystemFontDirectories();
516517
}
517518

518519
/**
519520
* Gets a set of registered font names.
520521
*
521522
* @return a set of registered fonts
522523
*/
523-
524524
public static Set<String> getRegisteredFonts() {
525525
return fontRegisterProvider.getRegisteredFonts();
526526
}
@@ -530,20 +530,8 @@ public static Set<String> getRegisteredFonts() {
530530
*
531531
* @return a set of registered font families
532532
*/
533-
534-
public static Set<String> getRegisteredFamilies() {
535-
return fontRegisterProvider.getRegisteredFamilies();
536-
}
537-
538-
/**
539-
* Gets a set of registered font names.
540-
*
541-
* @param fontname of a font that may or may not be registered
542-
* @return true if a given font is registered
543-
*/
544-
545-
public static boolean contains(String fontname) {
546-
return fontRegisterProvider.isRegistered(fontname);
533+
public static Set<String> getRegisteredFontFamilies() {
534+
return fontRegisterProvider.getRegisteredFontFamilies();
547535
}
548536

549537
/**
@@ -552,8 +540,7 @@ public static boolean contains(String fontname) {
552540
* @param fontname the name of the font that has to be checked.
553541
* @return true if the font is found
554542
*/
555-
556-
public static boolean isRegistered(String fontname) {
557-
return fontRegisterProvider.isRegistered(fontname);
543+
public static boolean isRegisteredFont(String fontname) {
544+
return fontRegisterProvider.isRegisteredFont(fontname);
558545
}
559546
}

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ protected FontProgram getFontProgram(String fontName, boolean cached) throws jav
184184
fontName = fontNames.get(fontName.toLowerCase());
185185
// the font is not registered as truetype font
186186
if (fontName != null) {
187-
fontProgram = FontFactory.createFont(fontName, cached);
187+
fontProgram = FontProgramFactory.createFont(fontName, cached);
188188
}
189189
if (fontProgram == null) {
190190
try {
191191
// the font is a type 1 font or CJK font
192-
fontProgram = FontFactory.createFont(fontName, cached);
192+
fontProgram = FontProgramFactory.createFont(fontName, cached);
193193
} catch (IOException ignored) {
194194
}
195195
}
@@ -204,7 +204,7 @@ protected FontProgram getFontProgram(String fontName, boolean cached) throws jav
204204
* @param fullName the font name
205205
* @param path the font path
206206
*/
207-
public void registerFamily(String familyName, String fullName, String path) {
207+
public void registerFontFamily(String familyName, String fullName, String path) {
208208
if (path != null)
209209
fontNames.put(fullName, path);
210210
List<String> tmp;
@@ -246,8 +246,8 @@ public void registerFamily(String familyName, String fullName, String path) {
246246
* @param path the path to a ttf- or ttc-file
247247
*/
248248

249-
public void register(String path) {
250-
register(path, null);
249+
public void registerFont(String path) {
250+
registerFont(path, null);
251251
}
252252

253253
/**
@@ -257,10 +257,10 @@ public void register(String path) {
257257
* @param alias the alias you want to use for the font
258258
*/
259259

260-
public void register(String path, String alias) {
260+
public void registerFont(String path, String alias) {
261261
try {
262262
if (path.toLowerCase().endsWith(".ttf") || path.toLowerCase().endsWith(".otf") || path.toLowerCase().indexOf(".ttc,") > 0) {
263-
FontProgram fontProgram = FontFactory.createFont(path);
263+
FontProgram fontProgram = FontProgramFactory.createFont(path);
264264
Object[] allNames = new Object[]{fontProgram.getFontNames().getFontName(), fontProgram.getFontNames().getFamilyName(), fontProgram.getFontNames().getFullName()};
265265
fontNames.put(((String) allNames[0]).toLowerCase(), path);
266266
if (alias != null) {
@@ -281,7 +281,7 @@ public void register(String path, String alias) {
281281
saveCopyOfRegularFont(lcName, path);
282282
}
283283
}
284-
String fullName = null;
284+
String fullName;
285285
String familyName = null;
286286
names = (String[][]) allNames[1]; //family name
287287
for (int k = 0; k < TTFamilyOrder.length; k += 3) {
@@ -303,7 +303,7 @@ public void register(String path, String alias) {
303303
if (fullName.equals(lastName))
304304
continue;
305305
lastName = fullName;
306-
registerFamily(familyName, fullName, null);
306+
registerFontFamily(familyName, fullName, null);
307307
break;
308308
}
309309
}
@@ -315,14 +315,14 @@ public void register(String path, String alias) {
315315
}
316316
TrueTypeCollection ttc = new TrueTypeCollection(path, PdfEncodings.WINANSI);
317317
for (int i = 0; i < ttc.getTTCSize(); i++) {
318-
register(path + "," + i);
318+
registerFont(path + "," + i);
319319
}
320320
} else if (path.toLowerCase().endsWith(".afm") || path.toLowerCase().endsWith(".pfm")) {
321-
FontProgram fontProgram = FontFactory.createFont(path, false);
321+
FontProgram fontProgram = FontProgramFactory.createFont(path, false);
322322
String fullName = fontProgram.getFontNames().getFullName()[0][3].toLowerCase();
323323
String familyName = fontProgram.getFontNames().getFamilyName()[0][3].toLowerCase();
324324
String psName =fontProgram.getFontNames().getFontName().toLowerCase();
325-
registerFamily(familyName, fullName, null);
325+
registerFontFamily(familyName, fullName, null);
326326
fontNames.put(psName, path);
327327
fontNames.put(fullName, path);
328328
}
@@ -351,8 +351,8 @@ protected boolean saveCopyOfRegularFont(String regularFontName, String path) {
351351
* @param dir the directory
352352
* @return the number of fonts registered
353353
*/
354-
public int registerDirectory(String dir) {
355-
return registerDirectory(dir, false);
354+
public int registerFontDirectory(String dir) {
355+
return registerFontDirectory(dir, false);
356356
}
357357

358358
/**
@@ -362,7 +362,7 @@ public int registerDirectory(String dir) {
362362
* @param scanSubdirectories recursively scan subdirectories if <code>true</true>
363363
* @return the number of fonts registered
364364
*/
365-
public int registerDirectory(String dir, boolean scanSubdirectories) {
365+
public int registerFontDirectory(String dir, boolean scanSubdirectories) {
366366
LOGGER.debug(MessageFormat.format("Registering directory {0}, looking for fonts", dir));
367367
int count = 0;
368368
try {
@@ -376,11 +376,11 @@ public int registerDirectory(String dir, boolean scanSubdirectories) {
376376
/* Only register Type 1 fonts with matching .pfb files */
377377
String pfb = file.substring(0, file.length() - 4) + ".pfb";
378378
if (FileUtil.fileExists(pfb)) {
379-
register(file, null);
379+
registerFont(file, null);
380380
++count;
381381
}
382382
} else if (".ttf".equals(suffix) || ".otf".equals(suffix) || ".ttc".equals(suffix)) {
383-
register(file, null);
383+
registerFont(file, null);
384384
++count;
385385
}
386386
} catch (Exception e) {
@@ -399,7 +399,7 @@ public int registerDirectory(String dir, boolean scanSubdirectories) {
399399
*
400400
* @return the number of fonts registered
401401
*/
402-
public int registerSystemDirectories() {
402+
public int registerSystemFontDirectories() {
403403
int count = 0;
404404
String[] withSubDirs = {
405405
FileUtil.getFontsDir(),
@@ -410,15 +410,15 @@ public int registerSystemDirectories() {
410410
"/usr/X11R6/lib/X11/fonts"
411411
};
412412
for (String directory : withSubDirs) {
413-
count += registerDirectory(directory, true);
413+
count += registerFontDirectory(directory, true);
414414
}
415415

416416
String[] withoutSubDirs = {
417417
"/Library/Fonts",
418418
"/System/Library/Fonts"
419419
};
420420
for (String directory : withoutSubDirs) {
421-
count += registerDirectory(directory, false);
421+
count += registerFontDirectory(directory, false);
422422
}
423423

424424
return count;
@@ -440,7 +440,7 @@ public Set<String> getRegisteredFonts() {
440440
* @return a set of registered font families
441441
*/
442442

443-
public Set<String> getRegisteredFamilies() {
443+
public Set<String> getRegisteredFontFamilies() {
444444
return fontFamilies.keySet();
445445
}
446446

@@ -449,7 +449,7 @@ public Set<String> getRegisteredFamilies() {
449449
* @param fontname the name of the font that has to be checked.
450450
* @return true if the font is found
451451
*/
452-
public boolean isRegistered(String fontname) {
452+
public boolean isRegisteredFont(String fontname) {
453453
return fontNames.containsKey(fontname.toLowerCase());
454454
}
455455
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ public FontProgram getFontByTccIndex(int ttcIndex) throws java.io.IOException {
9090
}
9191

9292
if (ttcPath != null) {
93-
return FontFactory.createFont(ttcPath, ttcIndex, cached);
93+
return FontProgramFactory.createFont(ttcPath, ttcIndex, cached);
9494
} else {
95-
return FontFactory.createFont(ttc, ttcIndex, cached);
95+
return FontProgramFactory.createFont(ttc, ttcIndex, cached);
9696
}
9797
}
9898

io/src/main/java/com/itextpdf/io/font/otf/ContextualSubTable.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ This file is part of the iText (R) project.
4747
import java.util.List;
4848

4949
public abstract class ContextualSubTable {
50+
5051
protected OpenTypeFontTableReader openReader;
5152
protected int lookupFlag;
5253

0 commit comments

Comments
 (0)