@Override
protected byte[] convertFO(File foFile, FOUserAgent ua, boolean dumpPdfFile)
throws Exception {
PrintRenderer renderer = (PrintRenderer) ua.getRendererFactory()
.createRenderer(ua, MimeConstants.MIME_PDF);
FontInfo fontInfo = new FontInfo();
renderer.setupFontInfo(fontInfo);
FontManager fontManager = ua.getFactory().getFontManager();
FontCollection[] fontCollections = new FontCollection[] {
new Base14FontCollection(fontManager.isBase14KerningEnabled()),
new CustomFontCollection(renderer.getFontResolver(), renderer.getFontList(),
ua.isComplexScriptFeaturesEnabled())
};
fontManager.setup(fontInfo, fontCollections);
FontTriplet triplet = new FontTriplet("Times", "italic",
Font.WEIGHT_NORMAL);
String internalFontKey = fontInfo.getInternalFontKey(triplet);
// Times italic should now be mapped to the 15th font (custom font)
// not the original base 14 (F6)
if (!"F15".equals(internalFontKey)) {
throw new Exception("font substitution failed :" + triplet);
}