I'm struggling with getting flying saucer to utilize a secondary font for the characters that are not included in my main font.
The Java code I am currently using looks something like this:
String result = getPrintHtmlContent(urlString);
result = CharacterConverter.replaceInvalidCharacters(result);
ITextRenderer renderer = new ITextRenderer();
renderer.getFontResolver();
renderer.getFontResolver().addFont(FONTS_DIR_PATH + "ARIALUNI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.getFontResolver().addFont(FONTS_DIR_PATH + "droidsans/DroidSans.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.getFontResolver().addFont(FONTS_DIR_PATH + "droidsans/DroidSansBold.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.setDocumentFromString(result, "http://" + frontendHost + ":" + frontendPort + frontendContextRoot);
renderer.layout();
renderer.createPDF(os);
Additionally, here is the CSS snippet:
body {
font-family: "Droid Sans", "Arial Unicode MS";
}
In the CSS, I have also added the fonts through the @font-face
rule.
I have been successful in using either one of the fonts individually; hence, it appears that there are no issues regarding finding the fonts or rendering the CSS correctly by flying saucer.
However, when attempting to use both fonts as shown above, the resulting PDF exclusively uses Droid Sans...
My question is whether it is feasible to employ a "fallback font" in flying saucer, akin to how it's done on websites?