Bug 10849 - PDF Font Embedding Bug with some OpenType Fonts and some PDF viewers
Summary: PDF Font Embedding Bug with some OpenType Fonts and some PDF viewers
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: pdf backend (show other bugs)
Version: 1.4.6
Hardware: x86 (IA32) Mac OS X (All)
: medium normal
Assignee: Adrian Johnson
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-03 12:01 UTC by Robert Ricci
Modified: 2007-09-28 16:17 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Inconsolata.otf test (12.98 KB, application/pdf)
2007-05-04 06:25 UTC, Adrian Johnson
Details
inode_xdsl.pdf (307.79 KB, application/pdf)
2007-06-28 11:29 UTC, Mark-André Hopf
Details
Fix font embedding problem with Apple PDF Viewer (6.98 KB, patch)
2007-07-04 04:26 UTC, Adrian Johnson
Details | Splinter Review
Fix a bug that would cause truetype subsetting to fail on valid fonts. (10.24 KB, patch)
2007-07-09 05:57 UTC, Adrian Johnson
Details | Splinter Review
Fix for cairo 1.4.10 (575 bytes, patch)
2007-09-28 16:16 UTC, Adrian Johnson
Details | Splinter Review

Description Robert Ricci 2007-05-03 12:01:05 UTC
The "Incolsolata" OpenType Font does not seem to embed properly in PDFs created
by Cairo 1.4.6. The PDFs display properly in some viewers, but in others, 
characters are rendered as empty rectangles. Cairo 1.4.0 embedded this font into 
PDFs just fine. 

I've created a minimal PDF showing this problem, which you can get here:
http://www.flux.utah.edu/users/ricci/font-embed.pdf

It displays fine in Adobe Reader 8.0.0, xpdf 3.0.2, and KPDF 3.5.4, but not
in Apple Preview 3.0.9 .

Incolsolata is in OpenType format, and released under the OFL - you can get it
here:
http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=OFL_fonts

The pdffonts command has this to say about the embedding:
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
Inconsolata                          CID Type 0C       yes no  yes     10  0
Comment 1 Adrian Johnson 2007-05-04 06:25:27 UTC
Created attachment 9860 [details]
Inconsolata.otf test

(In reply to comment #0)
> The "Incolsolata" OpenType Font does not seem to embed properly in
> PDFs created by Cairo 1.4.6. The PDFs display properly in some viewers,
> but in others, characters are rendered as empty rectangles.

What other viewers besides Apple Preview have this problem?

I don't have a Mac so I am unable to reproduce the problem. I have made some changes to the font embedding and attached a sample pdf. Could you check if this pdf displays correctly. If Preview has a font properties dialog similar to acroread I would be interested to know what font type and encoding is displayed.

> The pdffonts command has this to say about the embedding:
> name                                 type              emb sub uni object ID
> ------------------------------------ ----------------- --- --- --- ---------
> Inconsolata                          CID Type 0C       yes no  yes     10  0

Have you seen any pdf files with this font type that does display correctly in Preview? It would be helpful for me to look a one of these pdfs to see how it differs from the cairo pdf.
Comment 2 Robert Ricci 2007-05-06 19:42:56 UTC
I have not been able to find any viewers other than Preview that have this
problem. The PDF you attached has the same display problem with Preview, which
seems, sadly, to not have a font properties dialog.

I haven't been able to find/make any other PDFs that embed this particular font
using this particular type (I'm sure this is, in part, due to my lack of
experience in this area.) For example, creating a document in Word and then
printing to a PDF embeds the font as Type 1C.
Comment 3 Mark-André Hopf 2007-06-27 15:25:26 UTC
With cairo-1.4.6 and cairo-1.4.10 under Mac OS X 1.4 I see no fonts at all (I've tried Helvetica and Comic Sans MS) using Apple's Viewer application.

Acrobat Reader 8.1 and Ghostscript have no problems. I will try cairo-1.4 tomorrow.
Comment 4 Adrian Johnson 2007-06-27 16:18:04 UTC
(In reply to comment #3)
> With cairo-1.4.6 and cairo-1.4.10 under Mac OS X 1.4 I see no fonts at all
> (I've tried Helvetica and Comic Sans MS) using Apple's Viewer application.
> 
> Acrobat Reader 8.1 and Ghostscript have no problems. I will try cairo-1.4
> tomorrow.

It would be helpful to attach a PDF test case that I can look at. The font embedding changed in 1.4.6 to CID encoding due to limitations with the non CID encoding that resulted in increased PDF size and some fonts embedded as unhinted outlines. Prior to 1.4.6 the cairo font embedding had an ugly hack to work around bugs in Apple Preview. 

If you can locate a PDF created with another application that has the same type of font embedding (see comment #1) that

  a) displays correctly: I can look at it how the font is embedded and change cairo to work the same way, or

  b) does not display correctly: then it is a bug in the Apple viewer.

If PDFs display correctly in every pdf viewer except Apple Preview it is most likely a Preview bug.
Comment 5 Mark-André Hopf 2007-06-28 11:29:40 UTC
Created attachment 10487 [details]
inode_xdsl.pdf

I did not expect to find a file but pdffont inode_xdsl.pdf prints

name                                 type         emb sub uni object ID
------------------------------------ ------------ --- --- --- ---------
XXJVAY+BlurMedium                    CID Type 0C  yes yes yes     83  0
HUHDKE+Myriad-Condensed              CID Type 0C  yes yes yes     88  0
CXSUSO+Myriad-CnBold                 CID Type 0C  yes yes yes     95  0
XVDQAY+Myriad-Bold                   CID Type 0C  yes yes yes    230  0
HXBTKE+Myriad-CnBoldItalic           CID Type 0C  yes yes yes    235  0

and the Apple Viewer displays the text.
Comment 6 Adrian Johnson 2007-07-02 02:37:45 UTC
Could you test these two files with Apple Preview.

http://annarchy.freedesktop.org/~ajohnson/bug10849/test1.pdf

http://annarchy.freedesktop.org/~ajohnson/bug10849/test2.pdf

Comment 7 Robert Ricci 2007-07-02 09:49:13 UTC
(In reply to comment #6)
> Could you test these two files with Apple Preview.
> 
> http://annarchy.freedesktop.org/~ajohnson/bug10849/test1.pdf
> 
> http://annarchy.freedesktop.org/~ajohnson/bug10849/test2.pdf
> 

test1.pdf looks identical (and I assume correct) under Apple Preview 3.0.9 (409) (which comes with OS X 10.4.10) and Adobe Reader 8.0.0 (on the same Mac).
test2.pdf appears as a blank page under both readers.
Comment 8 Adrian Johnson 2007-07-03 05:16:00 UTC
Could you test this file with Apple Preview.

http://annarchy.freedesktop.org/~ajohnson/bug10849/test3.pdf
Comment 9 Mark-André Hopf 2007-07-03 11:29:24 UTC
It says: "The quick brown fox jumps over the lazy dog"
Comment 10 Adrian Johnson 2007-07-04 04:26:33 UTC
Created attachment 10581 [details] [review]
Fix font embedding problem with Apple PDF Viewer

Here's two more test cases. test4 has an OpenType/CFF font. test5 has a TrueType font. I've also attached my patch in case anyone wants to do any further testing. It applies to 1.4.10. If these two PDFs work I will commit the patch.

http://annarchy.freedesktop.org/~ajohnson/bug10849/test4.pdf
http://annarchy.freedesktop.org/~ajohnson/bug10849/test5.pdf
Comment 11 Mark-André Hopf 2007-07-04 11:16:28 UTC
test4.pdf shows rectangles instead of "One two three four five six seven eight nine ten."
test5.pdf shows "One two three four five six seven eight nine ten."
Comment 12 Mark-André Hopf 2007-07-04 13:52:40 UTC
I've applied the patch to cairo-1.4.10 but it did not solve the problem.

The file I've generated on Mac OS X, just in case you need it, is available here:

http://mark13.org/toad/download/other/test.pdf
Comment 13 Adrian Johnson 2007-07-05 06:01:18 UTC
(In reply to comment #12)
> I've applied the patch to cairo-1.4.10 but it did not solve the problem.
> 
> The file I've generated on Mac OS X, just in case you need it, is available
> here:
> 
> http://mark13.org/toad/download/other/test.pdf

What font are you using here? The CairoFont-x-y name instead of the real font name indicates that a cairo fallback font was embedded. This is the result of either cairo not supporting subsetting of this font or the subsetting failed. In both cases cairo generates a CFF font from the font outlines.

Could you do some further testing with various truetype and opentype/cff fonts to give me some more data on what works and what doesn't. Does the patch help with truetype fonts?
Comment 14 Mark-André Hopf 2007-07-05 11:27:36 UTC
This was a TrueType font. The file

  http://mark13.org/toad/download/other/test2.pdf

contains 4 different fonts:

  futura:size=12, TrueType
  Hiragino Kaku Gothic Pro W3:size=12, OpenType PostScript.
  Comic Sans MS:size=12, TrueType
  Free Serif:size=12, TrueType (not available, the fallback is being used)

and all of them seem to use the fallback.

Apples's view can't display them, but Acrobat read can.

Now Apple's X11 comes with modified FontConfig, etc. libraries which can access Mac OS X's font system. Maybe this is the cause why the fallback is being used.
Comment 15 Adrian Johnson 2007-07-09 05:57:09 UTC
Created attachment 10631 [details] [review]
Fix a bug that would cause truetype subsetting to fail on valid fonts.

I have fixed a problem with the TrueType subsetting that would cause it to fail on some fonts.

Could you test this patch to see if it fixes the problem of using fallback on the  ttf fonts you tested.
Comment 16 Mark-André Hopf 2007-07-09 14:00:19 UTC
I have to admit, it does not help. I'm so sorry. The result is here:

  http://mark13.org/toad/download/other/test3.pdf
Comment 17 Adrian Johnson 2007-07-10 17:10:05 UTC
(In reply to comment #14)
> This was a TrueType font. The file
> 
>   http://mark13.org/toad/download/other/test2.pdf
> 
> contains 4 different fonts:
> 
>   futura:size=12, TrueType
>   Hiragino Kaku Gothic Pro W3:size=12, OpenType PostScript.
>   Comic Sans MS:size=12, TrueType
>   Free Serif:size=12, TrueType (not available, the fallback is being used)
> 
> and all of them seem to use the fallback.
> 
> Apples's view can't display them, but Acrobat read can.
> 
> Now Apple's X11 comes with modified FontConfig, etc. libraries which can access
> Mac OS X's font system. Maybe this is the cause why the fallback is being used.
> 

This is a separate bug from the problem of viewing CFF fonts in Apple Preview. I suggest filing a new bug for this. It is going to require someone with a Mac to figure out why TrueType subsetting fails on that platform.
Comment 18 Adrian Johnson 2007-09-23 15:54:41 UTC
This bug is also being discussed on this cairo list thread:

http://lists.cairographics.org/archives/cairo/2007-September/011452.html
Comment 19 Adrian Johnson 2007-09-28 16:16:45 UTC
Created attachment 11817 [details] [review]
Fix for cairo 1.4.10

This bug has been fix in the git repository. A patch for 1.4.10 is attached.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.