}
}
// try to determine triplet information from font file
CustomFont customFont = null;
if (fontURL.toExternalForm().toLowerCase().endsWith(".ttc")) {
// Get a list of the TTC Font names
List<String> ttcNames = null;
String fontFileURL = fontURL.toExternalForm().trim();
InputStream in = null;
try {
in = FontLoader.openFontUri(resolver, fontFileURL);
TTFFile ttf = new TTFFile(false, false);
FontFileReader reader = new FontFileReader(in);
ttcNames = ttf.getTTCnames(reader);
} catch (Exception e) {
if (this.eventListener != null) {
this.eventListener.fontLoadingErrorAtAutoDetection(this, fontFileURL, e);
}
return null;
} finally {
IOUtils.closeQuietly(in);
}
List<EmbedFontInfo> embedFontInfoList = new java.util.ArrayList<EmbedFontInfo>();
// For each font name ...
for (String fontName : ttcNames) {
if (log.isDebugEnabled()) {
log.debug("Loading " + fontName);
}
try {
TTFFontLoader ttfLoader = new TTFFontLoader(
fontFileURL, fontName, true, EmbeddingMode.AUTO, EncodingMode.AUTO,
useKerning, useAdvanced, resolver);
customFont = ttfLoader.getFont();
if (this.eventListener != null) {
customFont.setEventListener(this.eventListener);
}
} catch (Exception e) {
if (fontCache != null) {
fontCache.registerFailedFont(embedURL, fileLastModified);
}
if (this.eventListener != null) {
this.eventListener.fontLoadingErrorAtAutoDetection(this, embedURL, e);
}
continue;
}
EmbedFontInfo fi = getFontInfoFromCustomFont(fontURL, customFont, fontCache);
if (fi != null) {
embedFontInfoList.add(fi);
}
}
return embedFontInfoList.toArray(
new EmbedFontInfo[embedFontInfoList.size()]);
} else {
// The normal case
try {
customFont = FontLoader.loadFont(fontURL, null, true, EmbeddingMode.AUTO,
EncodingMode.AUTO, resolver);
if (this.eventListener != null) {
customFont.setEventListener(this.eventListener);
}
} catch (Exception e) {
if (fontCache != null) {
fontCache.registerFailedFont(embedURL, fileLastModified);
}