I'm having trouble getting flying saucer to use a secondary font for the glyphs/charachters which are not present in my main font.
The Java code I'm using for this purpose is more or less:
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);
And the css:
body {
font-family: "Droid Sans", "Arial Unicode MS";
}
I have also included the fonts in the css by using the @font-face
rule.
I am able to get this to work using either of the fonts separately, so there seems to be no problem with flying saucer finding the fonts or the css not rendering correctly.
If I on the other hand do as above and try to use both fonts the output PDF is only using Droid Sans...
Is it even possible to use a "fallback font" in flying saucer, as it is on websites?
I asked the same question on Flying Saucer developer community and got a reply:
https://groups.google.com/forum/#!topic/flying-saucer-dev/5p00ISwnxiw
In short the answer is NO, it is not possible to use a secondary font.