Summary: | crash in Document Viewer | ||
---|---|---|---|
Product: | poppler | Reporter: | Carlos Garcia Campos <carlosgc> |
Component: | general | Assignee: | poppler-bugs <poppler-bugs> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | medium | CC: | davidben |
Version: | unspecified | ||
Hardware: | Other | ||
OS: | All | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: | Maintain Type0 fonts when using embedded font type |
Description
Carlos Garcia Campos
2008-08-21 11:55:50 UTC
Created attachment 29058 [details] [review] Maintain Type0 fonts when using embedded font type This patch should fix the bug. As I understand, the PDF is malformed. The font with object number 58 has type /Type0 has a descendant font (57 0 R) whose font descriptor (56 0 R) points to (via /FontFile3) embedded font program 71 0 R. Object 71 has type /Type1C, which, from table 5.23, can only appear in Type1 or MMType1 fonts. This is where the "Mismatch between font type and embedded font file" is coming from. Poppler uses the embedded font's type when the types do not match. However, it blindly sets the type, ignoring the fact that Type0 fonts get a different class (GfxCIDFont instead of Gfx8BitFont) and a different set of types (fontCIDType*). Later, when the font is used, we downcast by reinterpreting the pointer based on the type. When the type is wrong, a GfxCIDFont is interpreted as a Gfx8BitFont and Bad Things happen. Assuming I did this right, the patch should fix this. When we set the type from a mismatch, we check if the font is CID and pick the equivalent font type from CID set and vice versa. Also, a helpful warning is displayed. (Disclaimer: I don't actually understand PDF fonts... skimmed the spec for relevant-looking bits to implement this. It does successfully render the PDF without extra warnings, which is a good sign.) The patch makes sense, i've been trying to find out a simple solution for the problem and yours seems okaish, just wondering why did you decide to "fallback" to a specific type and not other, not saying it's wrong just that i'd like to know your rationale :-) I'm in process of regtest it, will commit it in a few days if everything works as expected. Commited (Oh hey, I never added myself to the CC list for this bug, so I only just saw this.) The original code already fell back to the embedded font's format. (And this PDF file spews out a ton of errors if you pick the type specified in the font dictionary. And I guess it makes sense that the type nearest the font data is most accurate.) As far as exactly which type, my impression is that there's a correspondence between the CID and the non-CID types, so I just picked the one that matched. |
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.