/** * Adds a TTC or OTC to the file cache. To reduce memory, the parsed font is not cached. */ private void addTrueTypeCollection(final File ttcFile) throws IOException { try (TrueTypeCollection ttc = new TrueTypeCollection(ttcFile)) { ttc.processAllFonts(new TrueTypeFontProcessor() { @Override public void process(TrueTypeFont ttf) throws IOException { addTrueTypeFontImpl(ttf, ttcFile); } }); } catch (NullPointerException | IOException e) { // NPE due to TTF parser being buggy LOG.error("Could not load font file: " + ttcFile, e); } }
private TrueTypeFont readTrueTypeFont(String postScriptName, File file) throws IOException { if (file.getName().toLowerCase().endsWith(".ttc")) { TrueTypeCollection ttc = new TrueTypeCollection(file); TrueTypeFont ttf = ttc.getFontByName(postScriptName); if (ttf == null) { ttc.close(); throw new IOException("Font " + postScriptName + " not found in " + file); } return ttf; } else { TTFParser ttfParser = new TTFParser(false, true); return ttfParser.parse(file); } }
PDFont font = PDType0Font.load(document, new TrueTypeCollection(new File("c:/windows/fonts/MSGothic.ttc")).getFontByName().get("MS-Gothic"), true);
/** * Add fonts using a .ttc TrueTypeCollection */ public void addFontCollection(File file, final String fontFamilyNameOverride, final Integer fontWeightOverride, final IdentValue fontStyleOverride, final boolean subset) throws IOException { TrueTypeCollection collection = new TrueTypeCollection(file); addFontCollection(collection, fontFamilyNameOverride, fontWeightOverride, fontStyleOverride, subset); }
/** * Add fonts using a .ttc TrueTypeCollection */ public void addFontCollection(File file, final String fontFamilyNameOverride, final Integer fontWeightOverride, final IdentValue fontStyleOverride, final boolean subset) throws IOException { TrueTypeCollection collection = new TrueTypeCollection(file); addFontCollection(collection, fontFamilyNameOverride, fontWeightOverride, fontStyleOverride, subset); }
/** * Adds a TTC or OTC to the file cache. To reduce memory, the parsed font is not cached. */ private void addTrueTypeCollection(final File ttcFile) throws IOException { try (TrueTypeCollection ttc = new TrueTypeCollection(ttcFile)) { ttc.processAllFonts(new TrueTypeFontProcessor() { @Override public void process(TrueTypeFont ttf) throws IOException { addTrueTypeFontImpl(ttf, ttcFile); } }); } catch (NullPointerException | IOException e) { // NPE due to TTF parser being buggy LOG.error("Could not load font file: " + ttcFile, e); } }
/** * Add fonts using a .ttc TrueTypeCollection */ public void addFontCollection(FSSupplier<InputStream> supplier, final String fontFamilyNameOverride, final Integer fontWeightOverride, final IdentValue fontStyleOverride, final boolean subset) throws IOException { InputStream inputStream = supplier.supply(); try { TrueTypeCollection collection = new TrueTypeCollection(inputStream); addFontCollection(collection, fontFamilyNameOverride, fontWeightOverride, fontStyleOverride, subset); } finally { inputStream.close(); } }
/** * Add fonts using a .ttc TrueTypeCollection */ public void addFontCollection(FSSupplier<InputStream> supplier, final String fontFamilyNameOverride, final Integer fontWeightOverride, final IdentValue fontStyleOverride, final boolean subset) throws IOException { InputStream inputStream = supplier.supply(); try { TrueTypeCollection collection = new TrueTypeCollection(inputStream); addFontCollection(collection, fontFamilyNameOverride, fontWeightOverride, fontStyleOverride, subset); } finally { inputStream.close(); } }
private TrueTypeFont readTrueTypeFont(String postScriptName, File file) throws IOException { if (file.getName().toLowerCase().endsWith(".ttc")) { TrueTypeCollection ttc = new TrueTypeCollection(file); TrueTypeFont ttf = ttc.getFontByName(postScriptName); if (ttf == null) { ttc.close(); throw new IOException("Font " + postScriptName + " not found in " + file); } return ttf; } else { TTFParser ttfParser = new TTFParser(false, true); return ttfParser.parse(file); } }
try ttc = new TrueTypeCollection(ttcFile); ttc.processAllFonts(new TrueTypeFontProcessor()
private TrueTypeFont readTrueTypeFont(String postScriptName, File file) throws IOException { if (file.getName().toLowerCase().endsWith(".ttc")) { TrueTypeCollection ttc = new TrueTypeCollection(file); TrueTypeFont ttf = ttc.getFontByName(postScriptName); if (ttf == null) { ttc.close(); throw new IOException("Font " + postScriptName + " not found in " + file); } return ttf; } else { TTFParser ttfParser = new TTFParser(false, true); return ttfParser.parse(file); } }
TrueTypeCollection collection = new TrueTypeCollection(fontEntry.file); collection.processAllFonts(new TrueTypeCollection.TrueTypeFontProcessor() { @Override