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/02/01 00:24:37 UTC

Re: Embedding font triplets w/ a single TTF file

Vincent Hennebert wrote:
> So if I were you, I wouldn't try to derive a bold typeface from a normal
> one ;-) Like Jeremias said I would rather find a naturally bold font.

Are there even any fonts which both support a large subset of unicode 
and have bold and italic variants?  I went searching a while back and 
found nothing.

The underlying problem here is that FOP's PDF renderer can't substitute 
fonts when the specified font doesn't exist (the Java2D renderer does 
this automatically as a side-effect of Java.)  As a result of this 
limitation, developers get forced to include some huge font like "Arial 
Unicode MS", even though there are enough fonts on their operating 
system that they don't need to use this font in any other application.

FOP could use bits of AWT to figure out how to substitute, the problem 
as I understand it is that there is no trivial way to map a Font object 
to a TTF file.

It's possible though... in a roundabout and non-portable way.

   sun.font.FontManager.getFontPath(false);  => "C:\\Windows\\Fonts"

 From that we would then open every TTF file, which gives us the name 
and style for each TTF file.  Reversing that map would give us a mapping 
from font family and style back to the TTF file which needs to be embedded.

It would cause a hell of a lot more than an extra 2 seconds startup 
time, however... :-/

I did consider doing this at the XSL-FO level somehow, running it 
through some Java code to automatically insert an <fo:inline> where 
fonts need substituting.

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

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.

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


Re: Embedding font triplets w/ a single TTF file

Posted by Daniel Noll <da...@nuix.com>.
Vincent Hennebert wrote:
> I doubt you will find any free font with both large Unicode support and
> several variants. You might want to give a try to FreeFont
> (http://www.nongnu.org/freefont/), which have a fairly reasonable
> support of Unicode, although not identical among the variants. I guess
> you can find commercial fonts, too.

Putting it side by side with Arial Unicode, it only lacks one or two 
scripts (for one given test page.)  Funny how Arial Unicode is some 10 
times bigger in file size, and yet only includes one typeface and one 
variant, whereas FreeFont includes three typefaces and all four variants 
for each...

(I wonder why Arial Unicode is so big, actually... maybe it contains 
explicit bitmap versions of the font for smaller sizes, to make the 
characters look more crisp.  I noticed that FreeFont looked blurry even 
at size 8.)

Unfortunately though, the licence makes it as easy to distribute as 
Arial Unicode... except for people lucky enough to be working on an 
application which is already GPL.

> Otherwise it should be rather easy to build a large Unicode support from
> several different fonts, each one supporting some given subset (say, a
> latin one, a cyrillic, a japanese, etc.). If you stick to Times-like
> shapes you should end up with a not too non-uniform set.

Yeah, I was thinking if I could pre-process the FO I could insert heaps 
of <fo:inline> elements to automatically change the font for each 
fragment to one which supports all the characters in the fragment.

> 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.

Java also has a configured list of fonts to use for different languages, 
although I've never been sure whether those were also used for fallback.

This does bring up a thought though... the JDK ships with the Lucida 
fonts so we could potentially use those instead of Arial and we then 
wouldn't need to ship with anything.  The only drawback would be that 
Lucida looks slightly (but only slightly) worse than Arial.

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

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.

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


Re: Embedding font triplets w/ a single TTF file

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


> Are there even any fonts which both support a large subset of unicode
> and have bold and italic variants?  I went searching a while back and
> found nothing.

I doubt you will find any free font with both large Unicode support and
several variants. You might want to give a try to FreeFont
(http://www.nongnu.org/freefont/), which have a fairly reasonable
support of Unicode, although not identical among the variants. I guess
you can find commercial fonts, too.

Otherwise it should be rather easy to build a large Unicode support from
several different fonts, each one supporting some given subset (say, a
latin one, a cyrillic, a japanese, etc.). If you stick to Times-like
shapes you should end up with a not too non-uniform set.


> The underlying problem here is that FOP's PDF renderer can't substitute
> fonts when the specified font doesn't exist (the Java2D renderer does
> this automatically as a side-effect of Java.)  As a result of this
> limitation, developers get forced to include some huge font like "Arial
> Unicode MS", even though there are enough fonts on their operating
> system that they don't need to use this font in any other application.

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.


> FOP could use bits of AWT to figure out how to substitute, the problem
> as I understand it is that there is no trivial way to map a Font object
> to a TTF file.

Exactly. AWT doesn't give access to the TTF file, which prevents
embedding the font in the PDF file.


> It's possible though... in a roundabout and non-portable way.
> 
>   sun.font.FontManager.getFontPath(false);  => "C:\\Windows\\Fonts"
> 
> From that we would then open every TTF file, which gives us the name and
> style for each TTF file.  Reversing that map would give us a mapping
> from font family and style back to the TTF file which needs to be embedded.
> 
> It would cause a hell of a lot more than an extra 2 seconds startup
> time, however... :-/

Well that's an idea. Anyway the whole font stuff would benefit from some
(major) improvements. But that's a complex area which involves a number
of standards (Type1, TrueType, Unicode...) and requires quite an amount
of knowledge... but wait, that's also very interesting! ;-)

Vincent

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