Example usage for com.itextpdf.text.pdf BaseFont enumerateTTCNames

List of usage examples for com.itextpdf.text.pdf BaseFont enumerateTTCNames

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf BaseFont enumerateTTCNames.

Prototype

public static String[] enumerateTTCNames(byte ttcArray[]) throws DocumentException, IOException 

Source Link

Document

Enumerates the postscript font names present inside a True Type Collection.

Usage

From source file:jdbreport.model.io.pdf.itext5.ReportFontMapper.java

License:Apache License

public int insertDirectory(String dir) {
    File file = new File(dir);
    if (!file.exists() || !file.isDirectory())
        return 0;
    File files[] = file.listFiles();
    if (files == null)
        return 0;
    int count = 0;
    for (File file1 : files) {
        file = file1;//from w  ww.ja  v a  2 s .  co  m
        if (file.isDirectory()) {
            count += insertDirectory(file.getPath());
        } else {
            String name = file.getPath().toLowerCase();
            try {
                if (name.endsWith(".ttf") || name.endsWith(".otf") || name.endsWith(".afm")) {
                    Object allNames[] = BaseFont.getAllFontNames(file.getPath(), BaseFont.IDENTITY_H, null);
                    insertNames(allNames, file.getPath());
                    ++count;
                } else if (name.endsWith(".ttc")) {
                    String ttcs[] = BaseFont.enumerateTTCNames(file.getPath());
                    for (int j = 0; j < ttcs.length; ++j) {
                        String nt = file.getPath() + "," + j;
                        Object allNames[] = BaseFont.getAllFontNames(nt, BaseFont.IDENTITY_H, null);
                        insertNames(allNames, nt);
                    }
                    ++count;
                }
            } catch (Exception ignore) {
            }
        }
    }
    return count;
}