List of usage examples for org.apache.pdfbox.pdmodel.font PDCIDFont getFontDescriptor
@Override
public PDFontDescriptor getFontDescriptor()
From source file:org.apache.fop.render.pdf.pdfbox.FOPPDFMultiByteFont.java
License:Apache License
private InputStream readFontFile(PDFont font) throws IOException { PDFontDescriptor fd = font.getFontDescriptor(); if (font instanceof PDType0Font) { PDCIDFont cidFont = ((PDType0Font) font).getDescendantFont(); fd = cidFont.getFontDescriptor(); }/*from w w w . j ava 2 s .c o m*/ PDStream ff = fd.getFontFile3(); if (ff == null) { ff = fd.getFontFile2(); if (ff == null) { ff = fd.getFontFile(); } } if (ff == null) { throw new IOException(font.getName() + " no fontfile"); } InputStream is = ff.createInputStream(); return new ByteArrayInputStream(IOUtils.toByteArray(is)); }
From source file:org.fit.pdfdom.PDFBoxTree.java
License:Open Source License
private void processFontResources(PDResources resources, FontTable table) throws IOException { String fontNotSupportedMessage = "Font: {} skipped because type '{}' is not supported."; for (COSName key : resources.getFontNames()) { PDFont font = resources.getFont(key); if (font instanceof PDTrueTypeFont) { table.addEntry(font.getName(), font.getFontDescriptor()); log.debug("Font: " + font.getName() + " TTF"); } else if (font instanceof PDType0Font) { PDCIDFont descendantFont = ((PDType0Font) font).getDescendantFont(); if (descendantFont instanceof PDCIDFontType2) table.addEntry(font.getName(), descendantFont.getFontDescriptor()); else/*from w ww. j av a2s .co m*/ log.warn(fontNotSupportedMessage, font.getName(), font.getClass().getSimpleName()); } else if (font instanceof PDType1CFont) table.addEntry(font.getName(), font.getFontDescriptor()); else log.warn(fontNotSupportedMessage, font.getName(), font.getClass().getSimpleName()); } for (COSName name : resources.getXObjectNames()) { PDXObject xobject = resources.getXObject(name); if (xobject instanceof PDFormXObject) { PDFormXObject xObjectForm = (PDFormXObject) xobject; PDResources formResources = xObjectForm.getResources(); if (formResources != null) processFontResources(formResources, table); } } }