Bug 52280 - PDF font substitution error, libcairo 1.12
Summary: PDF font substitution error, libcairo 1.12
Status: RESOLVED NOTABUG
Alias: None
Product: cairo
Classification: Unclassified
Component: pdf backend (show other bugs)
Version: 1.12.0
Hardware: x86 (IA32) Linux (All)
: medium major
Assignee: Adrian Johnson
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-19 21:56 UTC by Michael Adams
Modified: 2012-07-21 01:05 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Test PDF (83.55 KB, application/pdf)
2012-07-20 22:42 UTC, Michael Adams
Details

Description Michael Adams 2012-07-19 21:56:11 UTC
Original report: https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/1026338

When using pdftocairo 0.20.x from http://packages.ubuntu.com/quantal/poppler-utils , embedded custom encoded Helvetica fonts are not carried over from original to new PDFs: it gets substituted as NimbusSanL . Using pdftocairo 0.18.4 with libcairo 1.12, the error remains; restoring libcairo 1.10 reverts the error.

I have successfully compiled poppler-tools 0.20.2 against libcairo 1.10: the font substitution error does not occur with it.
Comment 1 Adrian Johnson 2012-07-19 22:42:21 UTC
Can you attach the pdf file that reproduces the bug.
Comment 2 Michael Adams 2012-07-20 22:42:01 UTC
Created attachment 64470 [details]
Test PDF

Test contract from the production system we use; this was saved via Adobe Reader X.
Comment 3 Adrian Johnson 2012-07-21 01:05:33 UTC
The original pdf contains the following fonts:

$ pdffonts bug52280.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
Arial,Bold                           CID TrueType      Identity-H       no  no  no     103  0
Arial                                CID TrueType      Identity-H       no  no  no     104  0
Arial-BoldMT                         TrueType          WinAnsi          no  no  no     105  0
ArialMT                              TrueType          WinAnsi          no  no  no     106  0
Helvetica-Bold                       Type 1            Custom           no  no  no       2  0
Helvetica                            Type 1            Custom           no  no  no       4  0
Helvetica                            Type 1            Custom           no  no  no     154  0
Helvetica                            Type 1            Custom           no  no  no     150  0


None of the fonts are embedded. So poppler will substitute the fonts. The substituted fonts are:

$ pdffonts -subst bug52280.pdf 
name                                 object ID substitute font                      substitute font file
------------------------------------ --------- ------------------------------------ ------------------------------------
Arial,Bold                              103  0 Liberation Sans Bold                 /usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf
Arial                                   104  0 Liberation Sans                      /usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf
Arial-BoldMT                            105  0 Liberation Sans Bold                 /usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf
ArialMT                                 106  0 Liberation Sans                      /usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf
Helvetica-Bold                            2  0 Nimbus Sans L Bold                   /usr/share/fonts/X11/Type1/n019004l.pfb
Helvetica                                 4  0 Nimbus Sans L                        /usr/share/fonts/X11/Type1/n019003l.pfb
Helvetica                               154  0 Nimbus Sans L                        /usr/share/fonts/X11/Type1/n019003l.pfb
Helvetica                               150  0 Nimbus Sans L                        /usr/share/fonts/X11/Type1/n019003l.pfb


Poppler will substitute the Helvetica fonts with Nimbus Sans. When rendering the pdf to pdf with pdftocairo cairo will embed the substituted fonts in the output pdf. Note that cairo does not support creating pdf files with non embedded fonts.

$ pdftocairo -pdf bug52280.pdf out.pdf
$ pdfinfo out.pdf
Creator:        cairo 1.12.3 (http://cairographics.org)
Producer:       cairo 1.12.3 (http://cairographics.org)
Tagged:         no
Pages:          1
Encrypted:      no
Page size:      612 x 1008 pts
File size:      47914 bytes
Optimized:      no
PDF version:    1.5
$ pdffonts out.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
JWYQNF+LiberationSans-Bold           TrueType          WinAnsi          yes yes yes      5  0
FQNIOC+LiberationSans                TrueType          WinAnsi          yes yes yes      6  0
EXPAHP+NimbusSanL-Bold               Type 1            WinAnsi          yes yes yes      7  0
BKHCZG+NimbusSanL-Regu               Type 1            WinAnsi          yes yes yes      8  0

This is all working correctly. The output pdf displays correctly in acroread and evince. The three identical Nimbus fonts have been merged into one.

Testing with cairo 1.10.2:

$ pdftocairo -pdf bug52280.pdf out.pdf
$ pdfinfo out.pdf
Creator:        cairo 1.10.2 (http://cairographics.org)
Producer:       cairo 1.10.2 (http://cairographics.org)
Tagged:         no
Pages:          1
Encrypted:      no
Page size:      612 x 1008 pts
File size:      91922 bytes
Optimized:      no
PDF version:    1.5
$ pdffonts out.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
JWYQNF+LiberationSans-Bold           CID TrueType      Identity-H       yes yes yes      5  0
FMRFXL+LiberationSans                CID TrueType      Identity-H       yes yes yes      6  0
VGBHBI+NimbusSansL                   Type 1            Builtin          yes yes yes      7  0
LBBITE+NimbusSansL                   Type 1            Builtin          yes yes yes      8  0

Again the Nimbus Sans fonts are embedded. The difference in encoding is due to a change in the way cairo 1.12 does the font subsetting. There is no difference in the rendering of the 1.10 output in acroread or evince compared to 1.12.

The missing '-Bold' and '-Regular' from the Nimbus Sans font names is due to a change in how cairo extracts the font name from Type 1 fonts. In cairo 1.10 it was using the family name. In cairo 1.12 it uses the full name.


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.