Search in sources :

Example 1 with TrueTypeFontProcessor

use of com.tom_roush.fontbox.ttf.TrueTypeCollection.TrueTypeFontProcessor in project PdfBox-Android by TomRoush.

the class FileSystemFontProvider method addTrueTypeCollection.

/**
 * Adds a TTC or OTC to the file cache. To reduce memory, the parsed font is not cached.
 */
private void addTrueTypeCollection(final File ttcFile) throws IOException {
    TrueTypeCollection ttc = null;
    try {
        ttc = new TrueTypeCollection(ttcFile);
        ttc.processAllFonts(new TrueTypeFontProcessor() {

            @Override
            public void process(TrueTypeFont ttf) throws IOException {
                addTrueTypeFontImpl(ttf, ttcFile);
            }
        });
    } catch (// TTF parser is buggy
    NullPointerException e) {
        Log.e("PdfBox-Android", "Could not load font file: " + ttcFile, e);
    } catch (IOException e) {
        Log.e("PdfBox-Android", "Could not load font file: " + ttcFile, e);
    } finally {
        if (ttc != null) {
            ttc.close();
        }
    }
}
Also used : TrueTypeFont(com.tom_roush.fontbox.ttf.TrueTypeFont) TrueTypeCollection(com.tom_roush.fontbox.ttf.TrueTypeCollection) IOException(java.io.IOException) TrueTypeFontProcessor(com.tom_roush.fontbox.ttf.TrueTypeCollection.TrueTypeFontProcessor)

Aggregations

TrueTypeCollection (com.tom_roush.fontbox.ttf.TrueTypeCollection)1 TrueTypeFontProcessor (com.tom_roush.fontbox.ttf.TrueTypeCollection.TrueTypeFontProcessor)1 TrueTypeFont (com.tom_roush.fontbox.ttf.TrueTypeFont)1 IOException (java.io.IOException)1