Bug 692687 - Converting attached PS file to PDF and back to PS gives broken fonts
Summary: Converting attached PS file to PDF and back to PS gives broken fonts
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PS Writer (show other bugs)
Version: 9.04
Hardware: PC Linux
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-16 11:34 UTC by Till Kamppeter
Modified: 2011-11-21 11:26 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
lp891074.ps (1.52 MB, application/postscript)
2011-11-16 11:34 UTC, Till Kamppeter
Details
PDF file to exhibit the issue (82.20 KB, application/pdf)
2011-11-17 16:07 UTC, Ken Sharp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Till Kamppeter 2011-11-16 11:34:11 UTC
Created attachment 8117 [details]
lp891074.ps

Original bug report is

https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/891074

The attached file lp891074.ps is the file d00043-001 attached as comment #3 there.

I can reproduce the bug by running the following two commands:

ps2pdf lp891074.ps
pdf2ps lp891074.pdf lp891074-broken.ps

The file lp891074.pdf coming out of the first command looks OK when displaying on the screen with evince or Ghostscript. The file lp891074-broken.ps resulting of the second command shows a lot of broken characters.

Problem occurs with Ghostscript 9.04 of Ubuntu Oneiric (11.10). The fix for the similar bug 692626 and also the fix for bug 692679 are already applied. The problem also occurs without applying the fixes, so these fixes are not a regression.
Comment 1 Ken Sharp 2011-11-17 16:07:13 UTC
Created attachment 8123 [details]
PDF file to exhibit the issue

The attached PDF file was created by running the original PostScript to PDF using pdfwrite, then removing most of the content. The remaining content (7 glyphs), when converted to PostScript using ps2write, produces the wrong rewsult for all but one of the glyphs.

I'm assuming its the ps2write step which is causing the problem, since the PDF renders correctly in Acrobat and Ghostscript
Comment 2 Ken Sharp 2011-11-21 08:19:39 UTC
The problem was in the handling of format 4 CMAP subtables in TrueType fonts. 

These are used to map character codes to Glyph IDs so that the proper GLYF program can be found. Format 4 is used for discontinuous ranges of mappings, but the ps2write header was treating them as continuous, and starting from 0. So for example, if a range contained a single character code 0x2 which mapped to GID 0x102 the existing code would have mapped character code 0x0 to GID 0x102 instead.

This caused many glyphs to be incorrectly mapped, often to the .notdef glyph.

Fixed in Git commit: cd8f3973ac735480fcd02de9e0214de80ea79e94

Regression testing exhibits several useful progressions in the test suite.
Comment 3 Till Kamppeter 2011-11-21 11:26:36 UTC
I applied the patch to the GS package of Ubuntu Oneiric and it works. Thank you very much for the quick fix.