You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Ron Van den Branden <ro...@kantl.be> on 2017/09/12 14:44:17 UTC

struggling with "bulk font configuration"

Hi,

I'm using FOP 2.1 for a journal whose submissions may occasionally 
contain all kinds of exotic characters, such as Japanese, Ethiopian, 
etc. I've been able to fix missing glyphs by defining specific fonts in 
the FOP configuration file and referring to them by means of a list of 
"font-family" values. Yet, it's hard to know exactly what font will 
cover all glyphs for every language, and adding new fonts requires both 
expanding the FOP configuration file and the "font-family" list in the 
XSL-FO files.

Hence, I'm trying to find a more flexible solution, and I'm trying out 
the "bulk font configuration", documented at 
https://xmlgraphics.apache.org/fop/2.2/fonts.html#bulk. I don't know if 
I'm misinterpreting this "bulk font configuration" as a means to 
register a lot of fonts without having to define them separately, so 
they can be used as a pool of fallback fonts for glyphs that aren't 
supported by the standard font?

So far, I haven't been able to figure out how those "bulk-registered" 
fonts should be referred to in an XSL-FO file.

Suppose I have a "noto" subfolder next to the FOP configuration file, 
with Google's Noto fonts, such as e.g. NotoSansCJKjp-Black.otf.

In the FOP config file, I have following entry:

   <renderers>
     <renderer mime="application/pdf">
       <!-- doesn't work with relative paths? -->
       <directory recursive="true">F:\fop\noto</directory>
       </fonts>
     </renderer>
   </renderers>

(Btw, the <directory> setting apparently doesn't work with a relative path?)

Basically, I'm not sure how I can now use the NotoSansCJKjp-Black.otf font:
     -can I just specify "font-family='NotoSansCJKjp-Black'" in the 
XSL-FO file?
     -or should all fonts still be registered separately in the config 
file with a <font> definition? (In which case, what's the point of "bulk 
registration"?)

So far, I've noticed that just bulk-registrering the "noto" subfolder, 
and specifying "font-family='Arial'" (or even variants of 
"font-family='Arial,NotoSansCJKjp-Black'") doesn't make FOP fall back to 
the NotoSansCJKjp-Black.ttf font for Japanese characters that aren't 
available in Arial.

Could anyone help me out here?

Best,

Ron


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: struggling with "bulk font configuration"

Posted by Ron Van den Branden <ro...@kantl.be>.
Hi Szeak,

Thanks for the pointers. Let me clarify: I knew how to register 
individual fonts in a config file and refer to them in an XSL-FO file, 
but it wasn't clear how to refer to bulk-registered fonts. Some further 
digging has made me find the answer, so if it can help others, I'll try 
to clarify with a concrete example.

Suppose I register an additional font in a configuration file:

   <renderers>
     <renderer mime="application/pdf">
       <fonts>
         <font embed-url="fonts/noto/NotoSansCJKjp-Regular.otf">
           <font-triplet name="NotoSansCJKjp" style="normal" weight="normal"/>
         </font>
       </fonts>
     </renderer>
   </renderers>

When using this configuration file, I can refer to this font in an 
XSL-FO file as follows:

   <fo:block font-family="Helvetica,NotoSansCJKjp">
     a test character: あ
   </fo:block>

...thus making FOP select the Helvetica font for all glyphs it supports 
(the string "a test character: "), and fall back to the NotoSansCKjp 
font for displaying the "あ" character.

So far, so good. Now, suppose that instead of this single font, I'd want 
to register all Noto fonts in that folder in bulk. According to the 
documentation, this can be done with the <directory> instruction in the 
configuration file:

   <renderers>
     <renderer mime="application/pdf">
       <directory recursive="true">F:\fop\noto</directory>
     </renderer>
   </renderers>

[NOTE: despite correct <base> and <font-base> settings, <directory> 
doesn't seem to work with relative paths...]

Perhaps I have overlooked, but from the documentation it wasn't clear to 
me how these fonts should be referred to in an XSL-FO file.

Yet, it appears that the full font name should be used for the 
"font-family" attribute. So, if the XSL-FO snippet above is adjusted to:

   <fo:block font-family="Helvetica,Noto Sans CJK JP">
     a test character: あ
   </fo:block>

...it works!

Best,

Ron

Op 13/09/2017 om 11:53 schreef Szeak (Register Man):
> Hi,
>
> First of all, you may need to read:
> - "Missing Glyphs" section in 
> https://xmlgraphics.apache.org/fop/2.1/fonts.html
> - font-base configuration element in 
> https://xmlgraphics.apache.org/fop/2.1/configuration.html
> - https://xmlgraphics.apache.org/fop/2.1/fonts.html#font_substitution
> - https://xmlgraphics.apache.org/fop/2.1/fonts.html#selection
>
> I'm not sure, it can FOP configuring for auto font switching by 
> characters (glyphs), because of as a Missing Glyphs section also wrote:
> "A better way is to use a font that has all the necessary glyphs. This 
> glyph substitution is only a last resort."
> AND:
> "There are two font selection strategies: character-by-character or 
> auto. The default is auto.
> ...
> Character-by-Character is NOT yet supported!"
>
> Best regards, Szeak