Example usage for com.lowagie.text.pdf BaseFont getFullFontName

List of usage examples for com.lowagie.text.pdf BaseFont getFullFontName

Introduction

In this page you can find the example usage for com.lowagie.text.pdf BaseFont getFullFontName.

Prototype

public abstract String[][] getFullFontName();

Source Link

Document

Gets the full name of the font.

Usage

From source file:jgnash.ui.report.FontRegistry.java

License:Open Source License

private void registerFont(final String path) {
    try {/*from ww  w  . j a v  a  2  s .  c o m*/
        if (path.toLowerCase().endsWith(".ttf") || path.toLowerCase().endsWith(".otf")
                || path.toLowerCase().indexOf(".ttc,") > 0) {
            Object allNames[] = BaseFont.getAllFontNames(path, BaseFont.WINANSI, null);

            String[][] names = (String[][]) allNames[2]; //full name
            for (String[] name : names) {
                registeredFontMap.put(name[3].toLowerCase(), path);
            }

        } else if (path.toLowerCase().endsWith(".ttc")) {
            String[] names = BaseFont.enumerateTTCNames(path);
            for (int i = 0; i < names.length; i++) {
                registerFont(path + "," + i);
            }
        } else if (path.toLowerCase().endsWith(".afm") || path.toLowerCase().endsWith(".pfm")) {
            BaseFont bf = BaseFont.createFont(path, BaseFont.CP1252, false);
            String fullName = bf.getFullFontName()[0][3].toLowerCase();
            registeredFontMap.put(fullName, path);
        }
    } catch (DocumentException | IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.pentaho.reporting.libraries.fonts.itext.BaseFontSupport.java

License:Open Source License

private String getFontName(final BaseFont font) {
    final String[][] names = font.getFullFontName();
    final int nameCount = names.length;
    if (nameCount == 1) {
        return names[0][3];
    }// www.ja  v a2s  . c o m

    String nameExtr = null;
    for (int k = 0; k < nameCount; ++k) {
        final String[] name = names[k];
        // Macintosh language english
        if ("1".equals(name[0]) && "0".equals(name[1])) {
            nameExtr = name[3];
        }
        // Microsoft language code for US-English ...
        else if ("1033".equals(name[2])) {
            nameExtr = name[3];
            break;
        }
    }

    if (nameExtr != null) {
        return nameExtr;
    }
    return names[0][3];
}

From source file:org.xhtmlrenderer.pdf.TrueTypeUtil.java

License:Open Source License

private static IdentValue guessStyle(BaseFont font) {
    String[][] names = font.getFullFontName();
    for (int i = 0; i < names.length; i++) {
        String name[] = names[i];
        String lower = name[3].toLowerCase();
        if (lower.indexOf("italic") != -1) {
            return IdentValue.ITALIC;
        } else if (lower.indexOf("oblique") != -1) {
            return IdentValue.OBLIQUE;
        }//from  ww  w.  j  a va  2 s  .  c  om
    }

    return IdentValue.NORMAL;
}