*/
protected static void declareFonts(Mapper fontMapper, Set<String> fontsInUse, StringBuilder result) {
for (String fontName : fontsInUse) {
PhysicalFont pf = fontMapper.get(fontName);
if (pf==null) {
log.error("Document font " + fontName + " is not mapped to a physical font!");
continue;
}
String subFontAtt = "";
if (pf.getEmbedFontInfo().getSubFontName()!=null)
subFontAtt= " sub-font=\"" + pf.getEmbedFontInfo().getSubFontName() + "\"";
result.append("<font embed-url=\"" +pf.getEmbeddedFile() + "\""+ subFontAtt +">" );
// now add the first font triplet
FontTriplet fontTriplet = (FontTriplet)pf.getEmbedFontInfo().getFontTriplets().get(0);
addFontTriplet(result, fontTriplet);
result.append("</font>" );
// bold, italic etc
PhysicalFont pfVariation = PhysicalFonts.getBoldForm(pf);
if (pfVariation==null) {
log.debug(fontName + " no bold form");
} else {
result.append("<font embed-url=\"" +pfVariation.getEmbeddedFile() + "\""+ subFontAtt +">" );
addFontTriplet(result, pf.getName(), "normal", "bold");
result.append("</font>" );
}
pfVariation = PhysicalFonts.getBoldItalicForm(pf);
if (pfVariation==null) {
log.debug(fontName + " no bold italic form");
} else {
result.append("<font embed-url=\"" +pfVariation.getEmbeddedFile() + "\""+ subFontAtt +">" );
addFontTriplet(result, pf.getName(), "italic", "bold");
result.append("</font>" );
}
pfVariation = PhysicalFonts.getItalicForm(pf);
if (pfVariation==null) {
log.debug(fontName + " no italic form");
} else {
result.append("<font embed-url=\"" +pfVariation.getEmbeddedFile() + "\""+ subFontAtt +">" );
addFontTriplet(result, pf.getName(), "italic", "normal");
result.append("</font>" );
}
}