Bug 103249

Summary: pdftocairo PDF output breaks embedded fonts
Product: cairo Reporter: Stephen E. <bhs2007>
Component: pdf backendAssignee: Adrian Johnson <ajohnson>
Status: RESOLVED FIXED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium CC: bhs2007
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Input file with embedded fonts
Before and After Comparison

Description Stephen E. 2017-10-12 23:40:04 UTC
Created attachment 134819 [details]
Input file with embedded fonts

Steps to reproduce:

1. Save the attached file (EmbeddedFont.pdf)
2. Run: pdftocairo -pdf EmbeddedFont.pdf out.pdf

Expected:

- Output has same appearance as input (a serif font).

Actual:

- Output falls back to a system font (sans serif) because fonts are no longer embedded.

Notes:

- The other output formats (PNG, JPEG, SVG) appear to produce the correct/desired appearance. Only the PDF output is affected.
Comment 1 Stephen E. 2017-10-12 23:41:22 UTC
Created attachment 134820 [details]
Before and After Comparison

Screenshot comparing the input and output files using Evince
Comment 2 Adrian Johnson 2017-10-13 09:25:23 UTC
The font family name in the embedded font contained > 3000 chars of garbage. As a result the font name was truncated and missing the closing delimiter.

Prevent long strings from being truncated in PDF file:

https://cgit.freedesktop.org/cairo/commit/?id=202a9ed64e3d164307defddb41a9f8cf9e9b751b

Sanity check the font name length and ignore it if too long:

https://cgit.freedesktop.org/cairo/commit/?id=bb10bd10138a262759b37281135b5199e334f392
Comment 3 Stephen E. 2017-10-14 00:28:34 UTC
Interesting finding! Thank you for the explanation and fast fix.

I'm assuming if I now build libcairo from master and then re-run pdftocairo, I should see a different result?
Comment 4 Adrian Johnson 2017-10-14 01:39:14 UTC
Yes, it works for me now. The missing delimiter caused viewers to fail to parse the font and as a result substitute it with something else.

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.