InputStream is = ttf.getOriginalData(); Set<Integer> glyphIdsToAdd = null; try
/** * Creates a new TrueType font for embedding. */ TrueTypeEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, boolean embedSubset) throws IOException { this.document = document; this.embedSubset = embedSubset; this.ttf = ttf; fontDescriptor = createFontDescriptor(ttf); if (!isEmbeddingPermitted(ttf)) { throw new IOException("This font does not permit embedding"); } if (!embedSubset) { // full embedding PDStream stream = new PDStream(document, ttf.getOriginalData(), COSName.FLATE_DECODE); stream.getCOSObject().setLong(COSName.LENGTH1, ttf.getOriginalDataSize()); fontDescriptor.setFontFile2(stream); } dict.setName(COSName.BASE_FONT, ttf.getName()); // choose a Unicode "cmap" cmap = ttf.getUnicodeCmap(); cmapLookup = ttf.getUnicodeCmapLookup(); }
try (InputStream is = ttf.getOriginalData())
/** * Creates a new TrueType font for embedding. */ TrueTypeEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, boolean embedSubset) throws IOException { this.document = document; this.embedSubset = embedSubset; this.ttf = ttf; fontDescriptor = createFontDescriptor(ttf); if (!isEmbeddingPermitted(ttf)) { throw new IOException("This font does not permit embedding"); } if (!embedSubset) { // full embedding PDStream stream = new PDStream(document, ttf.getOriginalData(), COSName.FLATE_DECODE); stream.getCOSObject().setLong(COSName.LENGTH1, ttf.getOriginalDataSize()); fontDescriptor.setFontFile2(stream); } dict.setName(COSName.BASE_FONT, ttf.getName()); // choose a Unicode "cmap" cmap = ttf.getUnicodeCmap(); }
InputStream is = ttf.getOriginalData();
/** * Creates a new TrueType font for embedding. */ TrueTypeEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, boolean embedSubset) throws IOException { this.document = document; this.embedSubset = embedSubset; this.ttf = ttf; fontDescriptor = createFontDescriptor(ttf); if (!isEmbeddingPermitted(ttf)) { throw new IOException("This font does not permit embedding"); } if (!embedSubset) { // full embedding PDStream stream = new PDStream(document, ttf.getOriginalData(), COSName.FLATE_DECODE); stream.getCOSObject().setLong(COSName.LENGTH1, ttf.getOriginalDataSize()); fontDescriptor.setFontFile2(stream); } dict.setName(COSName.BASE_FONT, ttf.getName()); // choose a Unicode "cmap" cmap = ttf.getUnicodeCmap(); cmapLookup = ttf.getUnicodeCmapLookup(); }
/** * Tries to load the original full font from the system */ public PDFont loadOriginal(PDDocument document) { String lookupName = fontName.replace("-", " "); LOG.debug("Searching the system for a font matching name '{}'", lookupName); FontMapping<TrueTypeFont> fontMapping = FontMappers.instance().getTrueTypeFont(lookupName, null); if (fontMapping != null && fontMapping.getFont() != null && !fontMapping.isFallback()) { TrueTypeFont mappedFont = fontMapping.getFont(); try { LOG.debug("Original font available on the system: {}", fontName); return PDType0Font.load(document, mappedFont.getOriginalData()); } catch (IOException ioe) { LOG.warn("Failed to load font from system", ioe); try { mappedFont.close(); } catch (IOException e) { LOG.warn("Failed closing font", e); } } } return null; }
/** * Tries to load the original full font from the system */ public PDFont loadOriginal(PDDocument document) { String lookupName = fontName.replace("-", " "); LOG.debug("Searching the system for a font matching name '{}'", lookupName); FontMapping<TrueTypeFont> fontMapping = FontMappers.instance().getTrueTypeFont(lookupName, null); if (fontMapping != null && fontMapping.getFont() != null && !fontMapping.isFallback()) { TrueTypeFont mappedFont = fontMapping.getFont(); try { LOG.debug("Original font available on the system: {}", fontName); return PDType0Font.load(document, mappedFont.getOriginalData()); } catch (IOException ioe) { LOG.warn("Failed to load font from system", ioe); try { mappedFont.close(); } catch (IOException e) { LOG.warn("Failed closing font", e); } } } return null; }
InputStream is = ttf.getOriginalData(); try
InputStream is = ttf.getOriginalData(); Set<Integer> glyphIdsToAdd = null; try
InputStream is = ttf.getOriginalData(); Set<Integer> glyphIdsToAdd = null; try
try (InputStream is = ttf.getOriginalData())
InputStream is = ttf.getOriginalData();
InputStream is = ttf.getOriginalData();
return PDType0Font.load(document, mappedFont.getOriginalData()); } catch (IOException ioe) { LOG.warn("Failed to load font from system", ioe);
return PDType0Font.load(document, mappedFont.getOriginalData()); } catch (IOException ioe) { LOG.warn("Failed to load font from system", ioe);