}
}
// try to determine triplet information from font file
CustomFont customFont = null;
if (fontUrl.toExternalForm().endsWith(".ttc")) {
// Get a list of the TTC Font names
List ttcNames = null; //List<String>
String fontFileURI = fontUrl.toExternalForm().trim();
InputStream in = null;
try {
in = FontLoader.openFontUri(resolver, fontFileURI);
TTFFile ttf = new TTFFile();
FontFileReader reader = new FontFileReader(in);
ttcNames = ttf.getTTCnames(reader);
} catch (Exception e) {
if (this.eventListener != null) {
this.eventListener.fontLoadingErrorAtAutoDetection(this, fontFileURI, e);
}
return null;
} finally {
IOUtils.closeQuietly(in);
}
List/*<EmbedFontInfo>*/ embedFontInfoList
= new java.util.ArrayList/*<EmbedFontInfo>*/();
// For each font name ...
//for (String fontName : ttcNames) {
Iterator ttcNamesIterator = ttcNames.iterator();
while (ttcNamesIterator.hasNext()) {
String fontName = (String)ttcNamesIterator.next();
if (log.isDebugEnabled()) {
log.debug("Loading " + fontName);
}
try {
TTFFontLoader ttfLoader = new TTFFontLoader(
fontFileURI, fontName, true, EncodingMode.AUTO, true, 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 (EmbedFontInfo[])embedFontInfoList.toArray(
new EmbedFontInfo[embedFontInfoList.size()]);
} else {
// The normal case
try {
customFont = FontLoader.loadFont(fontUrl, null, true, EncodingMode.AUTO, resolver);
if (this.eventListener != null) {
customFont.setEventListener(this.eventListener);
}
} catch (Exception e) {
if (fontCache != null) {
fontCache.registerFailedFont(embedUrl, fileLastModified);
}