}
}
}
boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true);
EmbedFontInfo fontInfo = null;
Configuration[] tripletCfg = fontCfg.getChildren("font-triplet");
// no font triplet info
if (tripletCfg.length == 0) {
LogUtil.handleError(log, "font without font-triplet", strict);
// if not strict try to determine font info from the embed/metrics url
File fontFile = CachedFontInfo.getFileFromUrls(new String[] {embedUrl, metricsUrl});
URL fontUrl;
try {
fontUrl = fontFile.toURI().toURL();
} catch (MalformedURLException e) {
// Should never happen
log.debug("Malformed Url: " + e.getMessage());
return null;
}
if (fontFile != null) {
FontInfoFinder finder = new FontInfoFinder();
return finder.find(fontUrl, fontResolver, fontCache);
} else {
return null;
}
} else {
List tripleList = new java.util.ArrayList();
for (int j = 0; j < tripletCfg.length; j++) {
try {
String name = tripletCfg[j].getAttribute("name");
if (name == null) {
LogUtil.handleError(log, "font-triplet without name", strict);
continue;
}
String weightStr = tripletCfg[j].getAttribute("weight");
if (weightStr == null) {
LogUtil.handleError(log, "font-triplet without weight", strict);
continue;
}
int weight = FontUtil.parseCSS2FontWeight(weightStr);
String style = tripletCfg[j].getAttribute("style");
if (style == null) {
LogUtil.handleError(log, "font-triplet without style", strict);
continue;
}
tripleList.add(FontInfo.createFontKey(name, style, weight));
} catch (ConfigurationException e) {
LogUtil.handleException(log, e, strict);
}
}
fontInfo = new EmbedFontInfo(metricsUrl, useKerning, tripleList, embedUrl);
if (fontCache != null) {
if (!fontCache.containsFont(fontInfo)) {
fontCache.addFont(fontInfo);
}
}
if (log.isDebugEnabled()) {
log.debug("Adding font " + fontInfo.getEmbedFile()
+ ", metric file " + fontInfo.getMetricsFile());
for (int j = 0; j < tripleList.size(); ++j) {
FontTriplet triplet = (FontTriplet) tripleList.get(j);
log.debug(" Font triplet "
+ triplet.getName() + ", "
+ triplet.getStyle() + ", "