Skip to content

Commit a190135

Browse files
committed
PDFBOX-5660: make it constant, as suggested by Andreas Lehmkühler
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1928950 13f79535-47bb-0310-9956-ffa450edef68
1 parent e6ef6c6 commit a190135

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/TrueTypeEmbedder.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.io.IOException;
2424
import java.io.InputStream;
2525
import java.nio.charset.StandardCharsets;
26+
import java.util.ArrayList;
2627
import java.util.HashSet;
2728
import java.util.List;
2829
import java.util.Map;
@@ -53,6 +54,24 @@ abstract class TrueTypeEmbedder implements Subsetter
5354
private static final int OBLIQUE = 512;
5455
private static final String BASE25 = "BCDEFGHIJKLMNOPQRSTUVWXYZ";
5556

57+
// PDF spec required tables (if present), all others will be removed
58+
private static final List<String> TABLES = new ArrayList<>(10);
59+
60+
static
61+
{
62+
TABLES.add("head");
63+
TABLES.add("hhea");
64+
TABLES.add("loca");
65+
TABLES.add("maxp");
66+
TABLES.add("cvt ");
67+
TABLES.add("prep");
68+
TABLES.add("glyf");
69+
TABLES.add("hmtx");
70+
TABLES.add("fpgm");
71+
// Windows ClearType
72+
TABLES.add("gasp");
73+
}
74+
5675
private final PDDocument document;
5776
protected TrueTypeFont ttf;
5877
protected PDFontDescriptor fontDescriptor;
@@ -311,13 +330,8 @@ public void subset() throws IOException
311330
throw new IllegalStateException("Subsetting is disabled");
312331
}
313332

314-
// PDF spec required tables (if present), all others will be removed
315-
List<String> tables = List.of("head", "hhea","loca","maxp","cvt ","prep","glyf","hmtx","fpgm",
316-
// Windows ClearType
317-
"gasp");
318-
319333
// set the GIDs to subset
320-
TTFSubsetter subsetter = new TTFSubsetter(ttf, tables);
334+
TTFSubsetter subsetter = new TTFSubsetter(ttf, TABLES);
321335
subsetter.addAll(subsetCodePoints);
322336
subsetter.forceInvisible('\u200B'); // ZWSP
323337
subsetter.forceInvisible('\u200C'); // ZWNJ

0 commit comments

Comments
 (0)