Search in sources :

Example 1 with OTFParser

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);
    }
}
Also used : TrueTypeFont(com.tom_roush.fontbox.ttf.TrueTypeFont) OTFParser(com.tom_roush.fontbox.ttf.OTFParser) OpenTypeFont(com.tom_roush.fontbox.ttf.OpenTypeFont) IOException(java.io.IOException) TTFParser(com.tom_roush.fontbox.ttf.TTFParser)

Aggregations

OTFParser (com.tom_roush.fontbox.ttf.OTFParser)1 OpenTypeFont (com.tom_roush.fontbox.ttf.OpenTypeFont)1 TTFParser (com.tom_roush.fontbox.ttf.TTFParser)1 TrueTypeFont (com.tom_roush.fontbox.ttf.TrueTypeFont)1 IOException (java.io.IOException)1