Skip to content

Commit 9fadebf

Browse files
author
Artyom Yanchevsky
committed
Expose some font utility API for public usage
DEVSIX-5101
1 parent 21c9b38 commit 9fadebf

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ This file is part of the iText (R) project.
5858
import org.slf4j.Logger;
5959
import org.slf4j.LoggerFactory;
6060

61-
class DocTrueTypeFont extends TrueTypeFont implements IDocFontProgram {
61+
public class DocTrueTypeFont extends TrueTypeFont implements IDocFontProgram {
6262

6363
private static final long serialVersionUID = 4611535787920619829L;
6464

65-
private PdfStream fontFile;
65+
private PdfStream fontFile;
6666
private PdfName fontFileName;
6767
private PdfName subtype;
6868
private int missingWidth = 0;

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,19 @@ This file is part of the iText (R) project.
6363
import org.slf4j.Logger;
6464
import org.slf4j.LoggerFactory;
6565

66-
class FontUtil {
66+
public class FontUtil {
6767

6868
private static final HashMap<String, CMapToUnicode> uniMaps = new HashMap<>();
6969

70+
public static String addRandomSubsetPrefixForFontName(final String fontName) {
71+
final StringBuilder newFontName = new StringBuilder(fontName.length() + 7);
72+
for (int k = 0; k < 6; ++k) {
73+
newFontName.append((char) (Math.random() * 26 + 'A'));
74+
}
75+
newFontName.append('+').append(fontName);
76+
return newFontName.toString();
77+
}
78+
7079
static CMapToUnicode processToUnicode(PdfObject toUnicode) {
7180
CMapToUnicode cMapToUnicode = null;
7281
if (toUnicode instanceof PdfStream) {

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,7 @@ protected boolean isWrappedObjectMustBeIndirect() {
492492
*/
493493
protected static String updateSubsetPrefix(String fontName, boolean isSubset, boolean isEmbedded) {
494494
if (isSubset && isEmbedded) {
495-
StringBuilder s = new StringBuilder(fontName.length() + 7);
496-
for (int k = 0; k < 6; ++k) {
497-
s.append((char) (Math.random() * 26 + 'A'));
498-
}
499-
return s.append('+').append(fontName).toString();
495+
return FontUtil.addRandomSubsetPrefixForFontName(fontName);
500496
}
501497
return fontName;
502498
}

0 commit comments

Comments
 (0)