use of org.apache.fontbox.ttf.OTFParser in project pdfbox by apache.
the class FileSystemFontProvider method getOTFFont.
private OpenTypeFont getOTFFont(String postScriptName, File file) {
try {
// todo JH: we don't yet support loading CFF fonts from OTC collections
OTFParser parser = new OTFParser(false, true);
OpenTypeFont otf = parser.parse(file);
if (LOG.isDebugEnabled()) {
LOG.debug("Loaded " + postScriptName + " from " + file);
}
return otf;
} catch (IOException e) {
LOG.error("Could not load font file: " + file, e);
}
return null;
}
use of org.apache.fontbox.ttf.OTFParser in project pdfbox by apache.
the class FileSystemFontProvider method addTrueTypeFont.
/**
* Adds an OTF or TTF font to the file cache. To reduce memory, the parsed font is not cached.
*/
private void addTrueTypeFont(File ttfFile) throws IOException {
try {
if (ttfFile.getPath().toLowerCase().endsWith(".otf")) {
OTFParser parser = new OTFParser(false, true);
OpenTypeFont otf = parser.parse(ttfFile);
addTrueTypeFontImpl(otf, ttfFile);
} else {
TTFParser parser = new TTFParser(false, true);
TrueTypeFont ttf = parser.parse(ttfFile);
addTrueTypeFontImpl(ttf, ttfFile);
}
} catch (IOException e) {
LOG.warn("Could not load font file: " + ttfFile, e);
}
}
Aggregations