Bug 695506 - Multiple EPS files with Type42 fonts are changing glyphs
Summary: Multiple EPS files with Type42 fonts are changing glyphs
Status: RESOLVED DUPLICATE of bug 694537
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 9.14
Hardware: PC Windows 7
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-22 18:35 UTC by Nick Phillips
Modified: 2014-09-23 16:47 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
minimal.ps and 3 eps files (282.83 KB, application/octet-stream)
2014-09-22 18:35 UTC, Nick Phillips
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Phillips 2014-09-22 18:35:37 UTC
Created attachment 11177 [details]
minimal.ps and 3 eps files

We have a problem with some EPS files using Type42 subset fonts.

I've hacked them down a bit into a smaller test case, attached.

The problem seems to be that the subset fonts in the 3 EPS files have the same names. I'm not sure if this should be an issue though as I thought the state would restore after each EPS. Renaming them fixes the problem though (as far as I can see).

Regardless, I am seeing some odd behaviour that might be interesting. Adobe Distiller seems to produce correct output, as expected since Acrobat created the EPS files.

If I include all 3 files the top left text reads 'KEHL' then 'KEYN'.

If I comment out the 2nd file 'eps2', the 'KEHL' changes to 'KEYL'.

Narrowing this down, if I include the second file, and comment out the '(+E@M)show' command, this has the same effect.

If I revert this, and instead comment out the '(@)show' in 'eps3' which displays the 'Y' character down the bottom, we also get 'KEYL' and 'KEYN' at the top.

There are other similar changes with side effects too. It seems that displaying certain characters in a certain order will change the glyphs used.
Comment 1 Ken Sharp 2014-09-23 00:20:30 UTC
(In reply to Nick Phillips from comment #0)

> I've hacked them down a bit into a smaller test case, attached.
> 
> The problem seems to be that the subset fonts in the 3 EPS files have the
> same names. I'm not sure if this should be an issue though as I thought the
> state would restore after each EPS. Renaming them fixes the problem though
> (as far as I can see).

You are correct about the source of the problem, and no there isn't much we cna do about it. Although the interpreter returns to the same state, the PDF output code clearly cannot, otherwise you would get three different output PDF files.

For obvious reasons we don't change the names of the fonts, so multiple fonts with the same name cause name clashes.
 
> There are other similar changes with side effects too. It seems that
> displaying certain characters in a certain order will change the glyphs used.

The existing bug report here has information on the problem:

http://bugs.ghostscript.com/show_bug.cgi?id=694537

The way to address this is to first convert all your EPS files to PDF, then process all the PDF files. When embeddding subset fonts we use an MD5 hash of the font contents to generate the prefix, which is reasonably unique even when fonts have the same name. So the 3 PDF files should then include fonts which have the same base name, but different subset prefixes.

You could, of course, always use Ghostscript to create your EPS files too, then this problem wouldn't arise.

*** This bug has been marked as a duplicate of bug 694537 ***
Comment 2 Nick Phillips 2014-09-23 16:47:17 UTC
Thanks Ken. I found that bug but didn't realise it applied - multiple EPS in one file seemed different to multiple separate PDFs. But it makes sense now you've explained about the issue being with pdfwrite.

Having a warning would be nice but it'd probably over-complicate things.

Processing each file EPS->PDF->EPS fixed the problem as you suggested. I'll see if we can bypass Acrobat entirely.