use of com.lowagie.text.pdf.BaseFont in project jgnash by ccavanaugh.
the class FontRegistry method registerFont.
private void registerFont(final String path) {
try {
if (path.toLowerCase(Locale.ROOT).endsWith(".ttf") || path.toLowerCase(Locale.ROOT).endsWith(".otf") || path.toLowerCase(Locale.ROOT).indexOf(".ttc,") > 0) {
Object[] allNames = BaseFont.getAllFontNames(path, BaseFont.WINANSI, null);
//full name
String[][] names = (String[][]) allNames[2];
for (String[] name : names) {
registeredFontMap.put(name[3].toLowerCase(Locale.ROOT), path);
}
} else if (path.toLowerCase(Locale.ROOT).endsWith(".ttc")) {
String[] names = BaseFont.enumerateTTCNames(path);
for (int i = 0; i < names.length; i++) {
registerFont(path + "," + i);
}
} else if (path.toLowerCase(Locale.ROOT).endsWith(".afm") || path.toLowerCase(Locale.ROOT).endsWith(".pfm")) {
BaseFont bf = BaseFont.createFont(path, BaseFont.CP1252, false);
String fullName = bf.getFullFontName()[0][3].toLowerCase(Locale.ROOT);
registeredFontMap.put(fullName, path);
}
} catch (final DocumentException | IOException e) {
throw new RuntimeException(e);
}
}
Aggregations