use of com.tom_roush.fontbox.ttf.OTFParser in project PdfBox-Android by TomRoush.
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().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 (// TTF parser is buggy
NullPointerException e) {
Log.e("PdfBox-Android", "Could not load font file: " + ttfFile, e);
} catch (IOException e) {
Log.e("PdfBox-Android", "Could not load font file: " + ttfFile, e);
}
}
Aggregations