public PDCIDFontType2(COSDictionary fontDictionary, PDType0Font parent) throws IOException
{
super(fontDictionary, parent);
PDFontDescriptor fd = getFontDescriptor();
PDStream ff2Stream = fd.getFontFile2();
PDStream ff3Stream = fd.getFontFile3();
TrueTypeFont ttfFont = null;
boolean fontIsDamaged = false;
if (ff2Stream != null)
{
try
{
// embedded
TTFParser ttfParser = new TTFParser(true);
ttfFont = ttfParser.parse(ff2Stream.createInputStream());
}
catch (NullPointerException e) // TTF parser is buggy
{
LOG.warn("Could not read embedded TTF for font " + getBaseFont(), e);
fontIsDamaged = true;
}
catch (IOException e)
{
LOG.warn("Could not read embedded TTF for font " + getBaseFont(), e);
fontIsDamaged = true;
}
}
else if (ff3Stream != null)
{
try
{
// embedded
OTFParser otfParser = new OTFParser(true);
OpenTypeFont otf = otfParser.parse(ff3Stream.createInputStream());
ttfFont = otf;
if (otf.isPostScript())
{
// todo: we need more abstraction to support CFF fonts here