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 Daniel Noll <da...@nuix.com> on 2007/05/29 07:38:09 UTC

Font substitution

Hi all.

I've just remembered something I was going to ask a long time ago.  Sorry to 
wake an old and potentially dead topic. ;-)

Vincent Hennebert said a few months ago:
> Actually both the PDF renderer and the Java2D one do the same thing,
> that is fall back to default fonts.  It's just that for PDF those default
> fonts are the well-known base 14 fonts, which support only a limited
> subset of Unicode (the latin range, basically).  For Java2D those are the
> Lucida fonts with a larger range of glyphs.

I have been wondering, is it possible to modify the PDF renderer so that it 
does fall back to the Lucida fonts instead of the generic base 14 fonts?

I'm not particularly fussed about the creation of bloated PDF files as we 
already have that right now and it's a better problem to have than the text 
simply not rendering. :-)

The ultimate goal is that regardless of what font happens to be declared in 
the FO file, if it can't render a given character I want some other font I 
can control the existence of to render that character instead.

Daniel


-- 
Daniel Noll
Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia    Ph: +61 2 9280 0699
Web: http://nuix.com/                               Fax: +61 2 9212 6902

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


Re: Font substitution

Posted by Vincent Hennebert <vi...@anyware-tech.com>.
Hi Daniel,

Daniel Noll a écrit :
> On Wednesday 30 May 2007 16:55:36 Vincent Hennebert wrote:
>> Or if you are sure that the Lucida font contains all the characters you
>> need, you can directly specify this font for the whole FO document:
>>
>> <fo:page-sequence font-family="Lucida"...
>>
>> for each page-sequence, plus you setup the Lucida font as usual in your
>> config file:
>> http://xmlgraphics.apache.org/fop/0.93/fonts.html#custom
>>
>> That way every character will appear in Lucida, you have both a
>> consistent and working result.
>> Is that what you need?
> 
> I'm not sure that will solve the problem because there may be an element 
> further in with font-family="something" that sets it back to some other font 
> which may not have that character.  And since our FO file tends to indirectly 
> come from HTML+CSS, it's highly likely that there are custom fonts somewhere.

Ah, I see your problem. Then you can redefine the fallback font to
Lucida in the config file. For example:
    <renderer mime="application/pdf">
      <fonts>
        <font kerning="yes" metrics-url="Lucida.xml"
          embed-url="Ludica.ttf">
	    <font-triplet name="any" style="normal" weight="normal"/>
	</font>
        ...
and do the same for the various combinations of bold and italic. That
way if some non-configured fonts appear in the FO file the Lucida one
will be used as a fallback.


> I guess I could do per-character substitution using a custom XML filter of 
> some sort to mangle the FO input.

Yes, if you want a finer-grain control (only some characters not
available in a font, as Jeremias wrote).

HTH,
Vincent


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


Re: Font substitution

Posted by Daniel Noll <da...@nuix.com>.
On Wednesday 30 May 2007 16:55:36 Vincent Hennebert wrote:
> Or if you are sure that the Lucida font contains all the characters you
> need, you can directly specify this font for the whole FO document:
>
> <fo:page-sequence font-family="Lucida"...
>
> for each page-sequence, plus you setup the Lucida font as usual in your
> config file:
> http://xmlgraphics.apache.org/fop/0.93/fonts.html#custom
>
> That way every character will appear in Lucida, you have both a
> consistent and working result.
> Is that what you need?

I'm not sure that will solve the problem because there may be an element 
further in with font-family="something" that sets it back to some other font 
which may not have that character.  And since our FO file tends to indirectly 
come from HTML+CSS, it's highly likely that there are custom fonts somewhere.

I guess I could do per-character substitution using a custom XML filter of 
some sort to mangle the FO input.

Daniel


-- 
Daniel Noll
Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia    Ph: +61 2 9280 0699
Web: http://nuix.com/                               Fax: +61 2 9212 6902

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


Re: Font substitution

Posted by Vincent Hennebert <vi...@anyware-tech.com>.
Jeremias Maerki a écrit :
> The fallback that is currently implemented in FOP only addresses the
> case where a whole font is not available. What you want is the fallback
> per character. And that's not implemented just by hacking the PDF
> renderer. So the ultimate goal is to implement:
> http://www.w3.org/TR/xsl11/#font-selection-strategy

Or if you are sure that the Lucida font contains all the characters you
need, you can directly specify this font for the whole FO document:

<fo:page-sequence font-family="Lucida"...

for each page-sequence, plus you setup the Lucida font as usual in your
config file:
http://xmlgraphics.apache.org/fop/0.93/fonts.html#custom

That way every character will appear in Lucida, you have both a
consistent and working result.
Is that what you need?

<snip/>


Vincent


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


Re: Font substitution

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
The fallback that is currently implemented in FOP only addresses the
case where a whole font is not available. What you want is the fallback
per character. And that's not implemented just by hacking the PDF
renderer. So the ultimate goal is to implement:
http://www.w3.org/TR/xsl11/#font-selection-strategy

See also:
http://wiki.apache.org/xmlgraphics-fop/FontSelectionStrategy

On 29.05.2007 07:38:09 Daniel Noll wrote:
> Hi all.
> 
> I've just remembered something I was going to ask a long time ago.  Sorry to 
> wake an old and potentially dead topic. ;-)
> 
> Vincent Hennebert said a few months ago:
> > Actually both the PDF renderer and the Java2D one do the same thing,
> > that is fall back to default fonts.  It's just that for PDF those default
> > fonts are the well-known base 14 fonts, which support only a limited
> > subset of Unicode (the latin range, basically).  For Java2D those are the
> > Lucida fonts with a larger range of glyphs.
> 
> I have been wondering, is it possible to modify the PDF renderer so that it 
> does fall back to the Lucida fonts instead of the generic base 14 fonts?
> 
> I'm not particularly fussed about the creation of bloated PDF files as we 
> already have that right now and it's a better problem to have than the text 
> simply not rendering. :-)
> 
> The ultimate goal is that regardless of what font happens to be declared in 
> the FO file, if it can't render a given character I want some other font I 
> can control the existence of to render that character instead.
> 
> Daniel
> 
> 
> -- 
> Daniel Noll
> Nuix Pty Ltd
> Suite 79, 89 Jones St, Ultimo NSW 2007, Australia    Ph: +61 2 9280 0699
> Web: http://nuix.com/                               Fax: +61 2 9212 6902


Jeremias Maerki


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