Bug 692010 - CID font render issues, specific to ghostscript
Summary: CID font render issues, specific to ghostscript
Status: RESOLVED WORKSFORME
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: 8.71
Hardware: PC Linux
: P4 major
Assignee: Alex Cherepanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-02 05:22 UTC by ant
Modified: 2011-03-02 08:37 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
example of the bad font rendering using CID -> ttf replacement (company logos and contact details removed). (68.29 KB, image/png)
2011-03-02 05:22 UTC, ant
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ant 2011-03-02 05:22:44 UTC
Created attachment 7305 [details]
example of the bad font rendering using CID -> ttf replacement (company logos and contact details removed).

Hi,

This is a followup to http://bugs.ghostscript.com/show_bug.cgi?id=691345

I have taken the advice listed there, done much research and comparison and have come to the conclusion that I am facing a new issue that does exist in ghostscript, and thus I have opened this issue.

For the example I am using the gs command line interpreter. I run it on this pdf with the font substitution for CID font Ariel 



[ant@ant pdf]$ gs fax_doc-01.pdf 
GPL Ghostscript 8.71 (2010-02-10)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Loading a TT font from /usr/share/fonts/truetype/arial.ttf to emulate a CID font Arial ... Done.
>>showpage, press <return> to continue<<

So, immediate thoughts are there is an issue with this pdf encoder.

However, I have read up on the standard, and compared. These tools do all open the pdf and render the font correctly with no warnings:

adobe acrobat reader 9.4.2 (linux)
evince document viewer on fedora linux 14 v2.32.0
pdftk v1.41 can output the text as an ascii stream correctly

The pdfanalyser demo downloadable from the top of this page:
http://www.pdfanalyzer.com/demo.php
does not report font issues.

It appears to me that this problem only appears on ghostscript (tested with GPL Ghostscript 8.71 on fedora 14).

This line has been added to /usr/share/ghostscript/8.71/Resource/Init/cidfmap.GS

/Arial << /SubfontID 0 /CSI [(Artifex) (Unicode) 0] /Path (/usr/share/fonts/truetype/arial.ttf) /FileType /TrueType >> ;

Perhaps I need to specify an alternate encoding here? Although the other viewers were able to work without any manual intervention.

If I remove the substitution line I get this output:

[ant@ant pdf]$ gs fax_doc-01.pdf 
GPL Ghostscript 8.71 (2010-02-10)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Can't find CID font "Arial".
Substituting CID font /Adobe-Identity for /Arial, see doc/Use.htm#CIDFontSubstitution.
The substitute CID font "Adobe-Identity" is not provided either. Will exit with error.
Error: /undefined in findresource
Operand stack:
   --dict:6/15(L)--   F9   9.96   --dict:6/6(L)--   --dict:6/6(L)--   Arial   --dict:10/12(ro)(G)--   --nostringval--   CIDFontObject   --dict:8/8(L)--   --dict:8/8(L)--   Adobe-Identity
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1878   1   3   %oparray_pop   1877   1   3   %oparray_pop   1861   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1   1   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %loop_continue
Dictionary stack:
   --dict:1150/1684(ro)(G)--   --dict:1/20(G)--   --dict:75/200(L)--   --dict:75/200(L)--   --dict:108/127(ro)(G)--   --dict:288/300(ro)(G)--   --dict:23/25(L)--   --dict:6/8(L)--   --dict:21/40(L)--   --dict:6/15(L)--
Current allocation mode is local
Last OS error: 2
GPL Ghostscript 8.71: Unrecoverable error, exit code 1

<some time later>

I just updated to 9.01, with the same results. With the font remapping:

[ant@ant pdf]$ gs fax_doc-01.pdf 
GPL Ghostscript 9.01 (2011-02-07)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Loading a TT font from /usr/share/fonts/truetype/arial.ttf to emulate a CID font Arial ... Done.
>>showpage, press <return> to continue<<

The document renders but the text is corrupted. 

Any ideas? How can these other tools render this text correctly or why cant ghostscript?

Thanks!
Comment 1 Ken Sharp 2011-03-02 08:32:25 UTC
The supplied example doesn't seem to be the same file as supplied for bug #691345 which makes it difficult to compare. However the first thing I would do is alter the (Unicode) to (Identity) in cidfmap. Note however that both work for me with the current version of GS and the file from bug #691345.

My cidfmap entry is:

/Arial <<
/FileType /TrueType
/SubfontID 0
/Path (/windows/fonts/arial.ttf)
/CSI [(Identity) 0]
>> ;

Which works apparently corectly with the only file I have to test against.

Note; the use of a TrueType font on disk as a substitute for a missing CIDFont is not guaranteed (the two font technologies haev differences), though it does often produce acceptable results. Much better to embed the font in the first place.
Comment 2 ant 2011-03-02 08:37:39 UTC
Hi Ken, I tested with your cidfmap line (but with the linux path to the font of course) and ghostscript 9.01 behaves correctly.

/Arial << /FileType /TrueType /SubfontID 0 /Path (/usr/share/fonts/truetype/arial.ttf) /CSI [(Identity) 0] >> ;

Now if only everyone on the internet was to check this bug for detail instead of the other million wrong versions out there!

Thanks again, closed.