Reputation: 420
It is well know that apache FOP does not support Japanese and Chinese characters. To overcome that I have used http://unifoundry.com/unifont/index.html.
However, when using external font, it seems I have to use it for all languages.
My requirement is to read the external font file only when language support is not in built.
How do I ask FOP to detect and read external font file instead of printing ##### or ????? in the pdf ?
One approach is : Since FOP throws a warning when it does not find a font, Can I convert this warning to exception and read the external font on exception ?
Upvotes: 2
Views: 534
Reputation: 8857
Font definition and selection is totally up to you and how you define them. In XSL FO you can do the same as one would do for CSS, like:
<fo:block font-family="Helvetica, Arial, Arial Unicode"> ... </fo:block>
This literally means select the font Helvetica
first, Arial
second and Arial Unicode
third to display my text.
You can combine that with either overall definition or inherited definition on how you would like the formatting engine to select the font to use. You can use "auto" which is default (in other words not defined) and would select the first font from the list of fonts that can display the most characters. Or you can set font-selection-strategy
to character-by-character
to tell the formatting engine to select the first font in the list that contains the character for each and every character.
It is unclear that FOP supports character-by-character and that is rarely used. As long as your list contains a font that can display every character, then it would always be used word by word in any text to be output.
The fact that you can use a list of fonts as well as set the strategy of how you wish those processed should get you exactly what you need. Put every font in your list in descending order of importance and let the formatting engine do the work to make sure all your characters are displayed.
You just need to also set up all those fonts in the FOP configuration.
Upvotes: 3