Bug 691345

Summary: Undefined in findresource for Arial and Adobe
Product: Ghostscript Reporter: jlamanna
Component: PDF InterpreterAssignee: Till Kamppeter <till.kamppeter>
Status: RESOLVED WORKSFORME    
Severity: normal CC: ant
Priority: P4    
Version: 8.71   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: test

Description jlamanna 2010-05-28 14:48:34 UTC
I get the following errors trying to convert a PDF file to tiff.
It seems to be related to the Arial font, which I do have installed on my machine, so I'm not sure what the problem is.
This is ghostscript 8.71 on Ubuntu.

# ls -la /usr/share/fonts/truetype/msttcorefonts/Arial.ttf
-rw-r--r-- 1 root root 275572 2000-05-11 11:45 /usr/share/fonts/truetype/msttcorefonts/Arial.ttf

Font Path:
   . : /usr/share/ghostscript/8.71/Resource/Init :
   /usr/share/ghostscript/8.71/lib :
   /usr/share/ghostscript/8.71/Resource/Font :
   /usr/share/ghostscript/fonts : /var/lib/defoma/gs.d/dirs/fonts :
   /usr/share/cups/fonts : /usr/share/ghostscript/fonts :
   /usr/local/lib/ghostscript/fonts : /usr/share/fonts

Command and error:

/usr/bin/gs -q -sDEVICE=tiff24nc -dNOPAUSE -dSAFER=true -sPAPERSIZE=letter -dBATCH -r203.29x196 -sOutputFile=doc.pdf.1 -dFIXEDMEDIA docq/doc87400.pdf

Error: /undefined in findresource
Operand stack:
   --dict:8/17(L)--   1   10   F0   8   --dict:6/6(L)--   --dict:6/6(L)--   Arial   --dict:9/12(ro)(G)--   --nostringval--   CIDFontObject   --dict:7/7(L)--   --dict:7/7(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--   3   1   2   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   136601   --nostringval--   1826   4   11   %oparray_pop   --nostringval--   false   1   %stopped_push   1825   4   11   %oparray_pop   --nostringval--   (gstatetype)   --dict:0/0(L)--   --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:1157/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:22/25(L)--   --dict:6/8(L)--   --dict:27/40(L)--   --dict:1/1(ro)(G)--   --dict:10/15(L)--
Comment 1 Ken Sharp 2010-05-28 15:04:04 UTC
(In reply to comment #0)
> I get the following errors trying to convert a PDF file to tiff.
> It seems to be related to the Arial font, which I do have installed on my
> machine, so I'm not sure what the problem is.

Without a sample file its impossible for us to tell either ;-)
Please attach a file that exhibits the problem, so we can reproduce it.


> Error: /undefined in findresource
> Operand stack:
>    --dict:8/17(L)--   1   10   F0   8   --dict:6/6(L)--   --dict:6/6(L)--  
> Arial   --dict:9/12(ro)(G)--   --nostringval--   CIDFontObject  
> --dict:7/7(L)--   --dict:7/7(L)--   Adobe-Identity

This is looking for a *CIDFont* called Adobe-Identity. This is the 'fallback' font when a CIDFont can't be found, similar to using Courier when a regular font is missing. 

I would expect that the problem is that the file uses a CIDFont which is not embedded in the document. From your comment above I would guess the font is Arial. Although you may have Arial installed, you probably have it installed as a Font (in gs/Resource/Init/Fontmap.GS or some other font map file). You need to install it as a CIDFont (in gs/Resource/Init/cidfmap) if you want to use it as a CIDFont.
Comment 2 jlamanna 2010-05-28 15:27:23 UTC
Unfortunately at the moment it is difficult to post the offending PDF because it contains sensitive information, I will try and get a cleaned copy.

Also, I do not appear to have a cidfmap file on Ubuntu, so I guess I need to create a new one?
Comment 3 Ken Sharp 2010-05-28 15:38:43 UTC
(In reply to comment #2)
> Unfortunately at the moment it is difficult to post the offending PDF because
> it contains sensitive information, I will try and get a cleaned copy.

Files can be marked private, which will only allow Artifex employees, and contractors with an NDA in place, to access the file.

 
> Also, I do not appear to have a cidfmap file on Ubuntu, so I guess I need to
> create a new one?

You should have one, but of course I don't know what Ubuntu might have done, if GS was packaged with the OS. The default installation includes a cidfmap which has no CIDFonts installed (unsurprisingly) but does have comments containing instructions on adding CIDFonts.
Comment 4 Hin-Tak Leung 2010-05-30 22:03:07 UTC
(In reply to comment #0)
> This is ghostscript 8.71 on Ubuntu.
> 
> # ls -la /usr/share/fonts/truetype/msttcorefonts/Arial.ttf
> -rw-r--r-- 1 root root 275572 2000-05-11 11:45
> /usr/share/fonts/truetype/msttcorefonts/Arial.ttf
> 
> Font Path:
>    . : /usr/share/ghostscript/8.71/Resource/Init :
>    /usr/share/ghostscript/8.71/lib :
>    /usr/share/ghostscript/8.71/Resource/Font :
>    /usr/share/ghostscript/fonts : /var/lib/defoma/gs.d/dirs/fonts :
>    /usr/share/cups/fonts : /usr/share/ghostscript/fonts :
>    /usr/local/lib/ghostscript/fonts : /usr/share/fonts

(In reply to comment #2)
> Also, I do not appear to have a cidfmap file on Ubuntu, so I guess I need to
> create a new one?

This is really a Ubuntu packaging issue, so re-assign to Till (Ubuntu maintainer of ghostcript package) to contact the appropriate Ubuntu font package maintainers. There are really two issues here - (1) the lack of an appropriate cidmap file, and (2) also the font file itself is not on the font path.

Each of Fedora's font packages put a cidmap file per font package inside
/usr/share/ghostscript/conf.d/, which is on the font path. Perhaps Ubuntu can copy this design?
Comment 5 Till Kamppeter 2010-05-31 10:32:18 UTC
Corresponding Ubuntu bug:

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

In this bug we handle the problem of the MS TT Core Fonts package.

Closing this bug report as it is not a Ghostscript bug.
Comment 6 jlamanna 2010-06-01 01:15:57 UTC
(In reply to comment #5)
> Corresponding Ubuntu bug:
> 
> https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/321932
> 
> In this bug we handle the problem of the MS TT Core Fonts package.
> 
> Closing this bug report as it is not a Ghostscript bug.

Uh, not sure how removing the MS TT Core Fonts helps my problem at all, which is what that Ubuntu bug resolution is doing. So I guess I need to bug the Ubuntu people to fix their MS TT Core Fonts package then?
Because after following that Ubuntu bug, I'm left with the following error:

Error: /undefined in findresource
Operand stack:
   --dict:8/17(L)--   1   10   F0   8   --dict:6/6(L)--   --dict:6/6(L)--   Arial   --dict:9/12(ro)(G)--   --nostringval--   CIDFontObject   --dict:7/7(L)--   --dict:7/7(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--   3   1   2   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   136601   --nostringval--   1826   4   11   %oparray_pop   --nostringval--   false   1   %stopped_push   1825   4   11   %oparray_pop   --nostringval--   (gstatetype)   --dict:0/0(L)--   --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:1157/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:22/25(L)--   --dict:6/8(L)--   --dict:27/40(L)--   --dict:1/1(ro)(G)--   --dict:10/15(L)--
Current allocation mode is local
Last OS error: 2
GPL Ghostscript 8.71: Unrecoverable error, exit code 1
Comment 7 jlamanna 2010-06-01 01:38:34 UTC
Created attachment 6342 [details]
test
Comment 8 jlamanna 2010-06-01 01:47:45 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > Corresponding Ubuntu bug:
> > 
> > https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/321932
> > 
> > In this bug we handle the problem of the MS TT Core Fonts package.
> > 
> > Closing this bug report as it is not a Ghostscript bug.

I've reinstalled msttcorefonts and adding the following to a 
/usr/share/ghostscript/8.71/Resource/Init/cidfmap file:

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

And now I am left with the error below.
Also, I do not see the option to mark an attachment as private so I can upload this file.

Error: /typecheck in findresource
Operand stack:
   --dict:8/17(L)--   1   10   F0   8   --dict:6/6(L)--   --dict:6/6(L)--   Arial   --dict:9/12(ro)(G)--   --nostringval--   CIDFontObject   --dict:7/7(L)--   --dict:7/7(L)--   Arial   CIDFont   true   Arial   false   Arial   --dict:23/26(G)--   --dict:23/26(G)--   (.Unicode)   (\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000)   (\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000)   Unicode   (\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000)
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--   3   1   2   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   136601   --nostringval--   1826   4   11   %oparray_pop   --nostringval--   false   1   %stopped_push   1825   4   11   %oparray_pop   --nostringval--   (gstatetype)   --dict:0/0(L)--   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %loop_continue   --nostringval--   --nostringval--   1829   15   11   %oparray_pop   findresource   %errorexec_pop   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1157/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:22/25(L)--   --dict:6/8(L)--   --dict:27/40(L)--   --dict:1/1(ro)(G)--   --dict:10/15(L)--   --dict:20/26(ro)(G)--
Current allocation mode is global
Comment 9 jlamanna 2010-06-01 19:03:58 UTC
I am reopening this.
After creating my own cidfmap (working around any Ubuntu packaging bugs I believe), I am still having the errors below (see Comment #8).

And please let me know how I can upload a PDF as private. I do not see the option.
Comment 10 Ken Sharp 2010-06-01 19:08:28 UTC
(In reply to comment #9)
> After creating my own cidfmap (working around any Ubuntu packaging bugs I
> believe), I am still having the errors below (see Comment #8).

Please attach a PDF file, and also quote changes made to cidfmap (or attach that too).

 
> And please let me know how I can upload a PDF as private. I do not see the
> option.

First attach the file, then mark it as private immediately afterwards. The option appears next to the uploaded file in Bugzilla.
Comment 11 jlamanna 2010-06-01 19:11:35 UTC
Created attachment 6344 [details]
Document showing PDF conversion errors

Current cidfmap:

/Arial << /FileType /TrueType /Path (/usr/share/fonts/truetype/msttcorefonts/Arial.ttf) /SubfontID 0 /CSI [/Artifex /Unicode 0] >> ;
Comment 12 jlamanna 2010-06-01 19:13:28 UTC
(In reply to comment #11)
> Created an attachment (id=6344) [details]
> Document showing PDF conversion errors
> 
> Current cidfmap:
> 
> /Arial << /FileType /TrueType /Path
> (/usr/share/fonts/truetype/msttcorefonts/Arial.ttf) /SubfontID 0 /CSI [/Artifex
> /Unicode 0] >> ;

I do not have an option to make this PDF private!
Can someone please do that for me. I don't know why it is missing on my account...
Comment 13 Ken Sharp 2010-06-01 19:17:58 UTC
(In reply to comment #12)
> (In reply to comment #11)
> > Created an attachment (id=6344) [details] [details]
> > Document showing PDF conversion errors
> > 
> > Current cidfmap:
> > 
> > /Arial << /FileType /TrueType /Path
> > (/usr/share/fonts/truetype/msttcorefonts/Arial.ttf) /SubfontID 0 /CSI [/Artifex
> > /Unicode 0] >> ;
> 
> I do not have an option to make this PDF private!
> Can someone please do that for me. I don't know why it is missing on my
> account...

You press the 'Details' link then check the 'Private' check box, I've done it for you though.
Comment 14 Ken Sharp 2010-06-02 08:23:07 UTC
(In reply to comment #11)
> Created an attachment (id=6344) [details]
> Document showing PDF conversion errors
> 
> Current cidfmap:
> 
> /Arial << /FileType /TrueType /Path
> (/usr/share/fonts/truetype/msttcorefonts/Arial.ttf) /SubfontID 0 /CSI [/Artifex
> /Unicode 0] >> ;

Aha, I believe you've used the wrong syntax in cidfmap. The CSI array entries need to be strings, not names, I used this:

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


which worked well for me. Note that the CSI entries are enclosed in parentheses (which makes them string types in PostScript), not introduced with a '/' which makes them name types in PostScript.

I think I'll change the default cidfmap to make that clearer.
Comment 15 Ken Sharp 2010-06-02 08:42:29 UTC
revision 11348 and 11349 change the comments in cidfmap to make it plain that
the Ordering and (if present) Registry values need to be strings, the comments also now contain a reference to the CIDFont documentation in use.htm.
Comment 16 jlamanna 2010-06-02 14:50:19 UTC
Hmm, changing my cidfmap to the following:

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

I get:

# /usr/bin/gs -q -sDEVICE=tiff24nc -dNOPAUSE -dSAFER=true -sPAPERSIZE=letter -dBATCH -r203.29x196 -sOutputFile=doc.pdf.1 -dFIXEDMEDIA doc87400.pdf

Can't find CMap Identity-UTF16-H building a CIDDecoding resource. 
Error: /undefinedresource in findresource
Operand stack:
   --dict:8/17(L)--   1   10   F0   8   --dict:6/6(L)--   --dict:6/6(L)--   Arial   --dict:9/12(ro)(G)--   --nostringval--   CIDFontObject   --dict:7/7(L)--   --dict:7/7(L)--   Arial   CIDFont   true   Arial   false   Arial   --dict:23/26(G)--   Unicode.Unicode   CIDDecoding   true   Unicode.Unicode   --dict:28/48(ro)(G)--   Identity-UTF16-H
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--   3   1   2   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   136601   --nostringval--   1826   4   11   %oparray_pop   --nostringval--   false   1   %stopped_push   1825   4   11   %oparray_pop   --nostringval--   (gstatetype)   --dict:0/0(L)--   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %loop_continue   --nostringval--   --nostringval--   1829   15   11   %oparray_pop   findresource   %errorexec_pop   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %loop_continue   --nostringval--   --nostringval--   --nostringval--   1829   22   12   %oparray_pop   findresource   %errorexec_pop   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--
Dictionary stack:
   --dict:1157/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:22/25(L)--   --dict:6/8(L)--   --dict:27/40(L)--   --dict:1/1(ro)(G)--   --dict:10/15(L)--   --dict:20/26(ro)(G)--   --dict:18/25(ro)(G)--   --dict:16/25(ro)(G)--
Current allocation mode is global
Last OS error: 2
GPL Ghostscript 8.71: Unrecoverable error, exit code 1
Comment 17 Ken Sharp 2010-06-02 14:59:27 UTC
(In reply to comment #16)
> Hmm, changing my cidfmap to the following:
> 
> /Arial << /SubfontID 0 /CSI [(Artifex) (Unicode) 0] /Path
> (/usr/share/fonts/truetype/msttcorefonts/Arial.ttf) /FileType /TrueType >> ;
> 
> I get:
> 
> # /usr/bin/gs -q -sDEVICE=tiff24nc -dNOPAUSE -dSAFER=true -sPAPERSIZE=letter
> -dBATCH -r203.29x196 -sOutputFile=doc.pdf.1 -dFIXEDMEDIA doc87400.pdf
> 
> Can't find CMap Identity-UTF16-H building a CIDDecoding resource.

That CMap is a part of the standard distribution, you should find it present in gs/Resource/CMap/Identity-UTF16-H

Its present in my copy of the distribution, which is probably why it works for me. You may need to get the absolute latest snapshot rather than the last release, I can't remember when that support was added.
Comment 18 jlamanna 2010-06-02 15:26:48 UTC
(In reply to comment #17)
> (In reply to comment #16)
> > Hmm, changing my cidfmap to the following:
> > 
> > /Arial << /SubfontID 0 /CSI [(Artifex) (Unicode) 0] /Path
> > (/usr/share/fonts/truetype/msttcorefonts/Arial.ttf) /FileType /TrueType >> ;
> > 
> > I get:
> > 
> > # /usr/bin/gs -q -sDEVICE=tiff24nc -dNOPAUSE -dSAFER=true -sPAPERSIZE=letter
> > -dBATCH -r203.29x196 -sOutputFile=doc.pdf.1 -dFIXEDMEDIA doc87400.pdf
> > 
> > Can't find CMap Identity-UTF16-H building a CIDDecoding resource.
> 
> That CMap is a part of the standard distribution, you should find it present in
> gs/Resource/CMap/Identity-UTF16-H
> 
> Its present in my copy of the distribution, which is probably why it works for
> me. You may need to get the absolute latest snapshot rather than the last
> release, I can't remember when that support was added.

Ah ok. Looks like the Ubuntu 8.71 package is missing that as well.
Comment 19 ant 2011-03-01 06:15:40 UTC
Thanks to this bug report I was able to solve this issue on my system. I'd just like to give additional details.

Firstly, here was the error message:

]# pdf2ps  doc-01.pdf test.ps
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:1152/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

I knew ghostscript often has trouble with fonts, and doesnt seem to try a best guess substitution, so I read between the lines that "Error: /undefined in findresource" and "Arial" in the next line probably indicated a problem with the Arial font. This made sense, as this is on a linux machine :)

So, I found an rpm of the ms core fonts. I found one here, but I know they can be sourced all over the net:

ftp://ftp.gwdg.de/pub/linux/misc/suser-jengelh/AnyDistro/noarch/MicrosoftFonts-1-jen14.noarch.rpm

Then I edited /usr/share/ghostscript/8.71/Resource/Init/cidfmap.GS (fedora 14) and added:

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

And the pdf converted successfully. Thanks those who helped with the fix.

Feature requests:

1) Could the error message be modified so that after the stack dump, something like "Unable to find font Ariel, or fall back font Adobe-Identity" (that was about the gist of it I think?).

2) Could ghostscript be modified to try harder to use a font of about the expected size for the unknown font scenario by default, so rather than break, a best-as-possible rendering is produced?

For reference, pdfinfo tells me this is the format of my source file:

# pdfinfo  doc-01.pdf 
Title:          Creditor Purchase Order
Subject:        <removed> SMARTExport Document Generator
Keywords:       Version 2.0 Build 2060 - Patch ID#206038 (010509)
Author:         <removed>
Creator:        <removed>
Producer:       Amyuni PDF Converter version 4.0.1.0
CreationDate:   Mon Feb 26 14:54:50 2011
ModDate:        Mon Feb 26 12:54:51 2011
Tagged:         no
Pages:          1
Encrypted:      yes (print:yes copy:yes change:no addNotes:no)
Page size:      595.25 x 841.9 pts (A4)
File size:      79142 bytes
Optimized:      yes
PDF version:    1.4

Thanks!
Comment 20 Ken Sharp 2011-03-01 08:42:03 UTC
(In reply to comment #19)

> Feature requests:
> 
> 1) Could the error message be modified so that after the stack dump, something
> like "Unable to find font Ariel, or fall back font Adobe-Identity" (that was
> about the gist of it I think?).

There are already warning messages *before* the error and stack dump that Ghostscript was unable to find the CIDFont, and was unable to find the fallback.

You can't have messages after the error because the error handling flushes the context.

 
> 2) Could ghostscript be modified to try harder to use a font of about the
> expected size for the unknown font scenario by default, so rather than break, a
> best-as-possible rendering is produced?

Basically, no. There is no way for Ghostscript to know what the characteristics of the missing font are when the input is PostScript. When the input is PDF there are some clues, but then we don't know what the characteristics of the available fonts are (size, weight, italic/upright, script, serif, symbol, the list of possibilities goes on).

Also, Ghostscript is intended for printing, and in that scenario it is better to produce an error than something which is 'as close as possible', because you can (eg) end up producing a run of 10,000 flyers which the customer won't accept because their corporate font isn't correct.

In future we may use Multiple Master fonts to substitute for missing (regular) fonts, but there is no way to do this for missing CIDFonts. If a CIDFont is missing and no appropriately named substitute is available, then you will get an error because that really is the best we can do.

You can define a 'generic' substitute font in cidfmap. When GS can't find a CIDFont it looks for a font whose name is generated from the CIDSystemInfo, the reasons for this are based on the internals of CIDFonts so I won't attempt to explain why this is the case. In the cases given (and in general in fact for PDF files) the Registry is Adobe, and the Ordering is Identity. This means GS looks for a font called 'Adobe-Identity'

If you define a CIDFont with that name then GS will use it for all missing CIDFonts with the same Ordering and Registry. That's about as good as it gets with CIDFonts.
Comment 21 ant 2011-03-02 00:38:41 UTC
(In reply to comment #20)
> (In reply to comment #19)
> 
> > Feature requests:
> > 
> > 1) Could the error message be modified so that after the stack dump, something
> > like "Unable to find font Ariel, or fall back font Adobe-Identity" (that was
> > about the gist of it I think?).
> 
> There are already warning messages *before* the error and stack dump that
> Ghostscript was unable to find the CIDFont, and was unable to find the
> fallback.

The output I posted is verbatum from the cli command until the prompt returned. I think for this pdf the font error message was skipped. 

> You can't have messages after the error because the error handling flushes the
> context.

Makes sense. 

> 
> > 2) Could ghostscript be modified to try harder to use a font of about the
> > expected size for the unknown font scenario by default, so rather than break, a
> > best-as-possible rendering is produced?
> 
> Basically, no. There is no way for Ghostscript to know what the characteristics
> of the missing font are when the input is PostScript. When the input is PDF
> there are some clues, but then we don't know what the characteristics of the
> available fonts are (size, weight, italic/upright, script, serif, symbol, the
> list of possibilities goes on).
> 
> Also, Ghostscript is intended for printing, and in that scenario it is better
> to produce an error than something which is 'as close as possible', because you
> can (eg) end up producing a run of 10,000 flyers which the customer won't
> accept because their corporate font isn't correct.

I do understand this, but perhaps non-default behaviour with a command switch to enable it? We are using it for faxing on an automated system so for this scenario bombing out with an error when we are accepting pdfs from many different broken or brain dead pdf encoders is worse than best attempt. 

> In future we may use Multiple Master fonts to substitute for missing (regular)
> fonts, but there is no way to do this for missing CIDFonts. If a CIDFont is
> missing and no appropriately named substitute is available, then you will get
> an error because that really is the best we can do.
> 
> You can define a 'generic' substitute font in cidfmap. When GS can't find a
> CIDFont it looks for a font whose name is generated from the CIDSystemInfo, the
> reasons for this are based on the internals of CIDFonts so I won't attempt to
> explain why this is the case. In the cases given (and in general in fact for
> PDF files) the Registry is Adobe, and the Ordering is Identity. This means GS
> looks for a font called 'Adobe-Identity'
> 
> If you define a CIDFont with that name then GS will use it for all missing
> CIDFonts with the same Ordering and Registry. That's about as good as it gets
> with CIDFonts.

I'll read up on CIDfonts, I'd never heard of them before I ran in to this.

Thanks for the reply.
Comment 22 ant 2011-03-02 00:50:40 UTC
(In reply to comment #21)
> (In reply to comment #20)
> > (In reply to comment #19)
> >In the cases given (and in general in fact for
> > PDF files) the Registry is Adobe, and the Ordering is Identity. This means GS
> > looks for a font called 'Adobe-Identity'
> > 
> > If you define a CIDFont with that name then GS will use it for all missing
> > CIDFonts with the same Ordering and Registry. That's about as good as it gets
> > with CIDFonts.

Hate to reply to myself, but in digesting this info it just clicked that this is the solution for part one of my issue, so please disregard the feature request. 

Thanks!
Comment 23 Ken Sharp 2011-03-02 08:09:11 UTC
(In reply to comment #21)

> > There are already warning messages *before* the error and stack dump that
> > Ghostscript was unable to find the CIDFont, and was unable to find the
> > fallback.
> 
> The output I posted is verbatum from the cli command until the prompt returned.
> I think for this pdf the font error message was skipped. 

This does not happen for me using a release build of the current version of Ghostscript (9.01). Possibly this was added after the release of 8.71 which you seem to be using. When I run the file through Ghostscript I get the expected messages:

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
...
<Standard incomprehensible stack dump>
...
Comment 24 ant 2011-03-02 08:17:21 UTC
Hi Ken,

Yes, ive been studying this problem and CID Fonts in general today. Im still having trouble, and believe there is an issue in ghostscript but I have opened a new bug as I have gone beyond the scope of this bug. I have verified the new issue is happening also on 9.01.

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