|
23 | 23 | import java.io.IOException; |
24 | 24 | import java.io.InputStream; |
25 | 25 | import java.nio.charset.StandardCharsets; |
| 26 | +import java.util.ArrayList; |
26 | 27 | import java.util.HashSet; |
27 | 28 | import java.util.List; |
28 | 29 | import java.util.Map; |
@@ -53,6 +54,24 @@ abstract class TrueTypeEmbedder implements Subsetter |
53 | 54 | private static final int OBLIQUE = 512; |
54 | 55 | private static final String BASE25 = "BCDEFGHIJKLMNOPQRSTUVWXYZ"; |
55 | 56 |
|
| 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 | + |
56 | 75 | private final PDDocument document; |
57 | 76 | protected TrueTypeFont ttf; |
58 | 77 | protected PDFontDescriptor fontDescriptor; |
@@ -311,13 +330,8 @@ public void subset() throws IOException |
311 | 330 | throw new IllegalStateException("Subsetting is disabled"); |
312 | 331 | } |
313 | 332 |
|
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 | | - |
319 | 333 | // set the GIDs to subset |
320 | | - TTFSubsetter subsetter = new TTFSubsetter(ttf, tables); |
| 334 | + TTFSubsetter subsetter = new TTFSubsetter(ttf, TABLES); |
321 | 335 | subsetter.addAll(subsetCodePoints); |
322 | 336 | subsetter.forceInvisible('\u200B'); // ZWSP |
323 | 337 | subsetter.forceInvisible('\u200C'); // ZWNJ |
|
0 commit comments