[cairo] Problem with pdfs containing fonts with 0x7fff glyphs or more

Adrian Johnson ajohnson at redneon.com
Sun May 13 07:33:40 PDT 2007


Eugeniy Meshcheryakov wrote:
> Hello,
> 
> While testing my program (uses cairo) with large font files, I found that
> sometimes text in created pdfs cannot be displayed with kpdf or xpdf. gv
> works for some of the pdfs, but gives errors for others. I do not know
> if this is an error in cairo, or in those pdf viewers.
> 
> I used fntsample ( http://sf.net/projects/fntsample ) with CODE2000
> font (CFF outlines). I start getting problems when try to generate pdf

This font is a TrueType font. For some reason the TrueType subsetting
has failed and a CFF/Type2 fallback font has been embedded.

> with the following command:
> 
>        fntsample -f CODE2000.TTF -o 1.pdf -i 0x0000-0x8fbc
>    (creates pdf with characters in range U+0000-U+8BC,
>     file available at http://people.debian.org/~eugen/bad-pdfs/1.pdf)
> 
> Fontforge shows that embedded font contains exactly 0x7FFF glyphs. gv is
> still able to display this file. Both xpdf and kpdf can display file
> with characters in range U+0000-U+8BB
> (http://people.debian.org/~eugen/bad-pdfs/2.pdf). kpdf, xpdf and gv
> cannot display file that contains all encoded characters from the font
> (fntsample without -i, http://people.debian.org/~eugen/bad-pdfs/3.pdf).

All three of these files appear to display correctly in xpdf 3.02 and
kpdf 0.5.5 and ghostscript 8.56, and acroread 7. Can you provide a
screenshot or more detail about what the problem is as these files look
fine to me.

The last file, 3.pdf, fails with a /stackoverflow error in ghostscript
versions prior to 8.56. I did some further testing with this font
and fntsample and creating a pdf with characters in the range
0x0000-0xf000 works with all version of ghostscript. Creating a pdf with
 characters in the range 0x0000-0xff00 fails with ghostscript versions
prior to 8.56. Creating a pdf with characters in the range 0x1000-0xffff
works with all versions.

One possible workaround, if you want to limit the number of glyphs
per embedded font, is to create multiple cairo_font_face_t faces for
each font.

For example:

face = cairo_ft_font_face_create_for_ft_face (ft_face, 0);
cairo_set_font_face(cr, face);
  ... show some glyphs
face = cairo_ft_font_face_create_for_ft_face (ft_face, 0);
cairo_set_font_face(cr, face);
  ... show some more glyphs

Each time a cairo_font_face_t is created from
cairo_ft_font_face_create_for_ft_face(), a separate font will be
embedded for all glyphs shown with that face. I'm not sure if this is a
bug or a feature.

> Does anyone know, if this is problem in cairo code or in those viewers?
> 
> Versions of programs:
>   cairo 1.4.6
>   kpdf 3.5.6
>   xpdf 3.02
>   gv 3.6.2
>   gs-esp 8.15.3
> 
> Regards,
> Eugeniy Meshcheryakov
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo



More information about the cairo mailing list