Bug 689037 - PDF font woes
Summary: PDF font woes
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: 8.54
Hardware: PC Linux
: P4 normal
Assignee: Default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-05 17:22 UTC by Lee Howard
Modified: 2008-12-19 08:31 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
problem PDF sample (408.42 KB, application/pdf)
2007-01-09 16:25 UTC, Lee Howard
Details
patch (638 bytes, patch)
2007-01-09 19:02 UTC, Alex Cherepanov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lee Howard 2007-01-05 17:22:51 UTC
Hello.

I have a PDF that references a non-embedded Adobe font...

gs -sPAPERSIZE=a4 -dBATCH -dNOPAUSE -sDEVICE=faxg3 -sOutputFile=foo.tif
foo.pdf

> Error: /invalidfont in /AGaramond-Regular
> Operand stack:
>    --dict:8/8(L)--   0.999997   --dict:8/8(L)--   1   AGaramond-Regular   10
> Execution stack:
>    %interp_exit   .runexec2   --nostringval--   --nostringval--  
--nostringval--   2   %stopped_push   --nostringval--   --nostringval--  
--nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3  
%oparray_pop   1   3   %oparray_pop   --nostringval--   --nostringval--   3   1
  2   --nostringval--   %for_pos_int_continue   --nostringval--  
--nostringval--   --nostringval--   %array_continue   --nostringval--  
--nostringval--   --nostringval--   --nostringval--   --nostringval--   5   11 
 %oparray_pop   --nostringval--   false   1   %stopped_push   5   11  
%oparray_pop   --nostringval--   (gstatetype)   --dict:0/0(L)--  
--nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue 
 --nostringval--
> Dictionary stack:
>    --dict:1133/1686(ro)(G)--   --dict:2/20(G)--   --dict:75/200(L)--  
--dict:75/200(L)--   --dict:105/127(ro)(G)--   --dict:253/347(ro)(G)--  
--dict:21/24(L)--   --dict:4/6(L)--   --dict:21/32(L)--   --dict:19/21(L)--  
--dict:6/8(L)--
> Current allocation mode is local
> GPL Ghostscript 8.54: Unrecoverable error, exit code 1



So I figured that I could simply create an alias for it in the
Fontmap.GS file:

/AGaramond-Regular      /NimbusRomNo9L-MediItal   ;

But sadly, this didn't change anything you see above although findfont
seems to work from the gs interpreter:

> # gs
> GPL Ghostscript 8.54 (2006-05-17)
> Copyright (C) 2006 artofcode LLC, Benicia, CA.  All rights reserved.
> This software comes with NO WARRANTY: see the file PUBLIC for details.
> GS>/AGaramond-Regular findfont
> Loading NimbusRomNo9L-MediItal font from
/usr/local/share/ghostscript/fonts/n021024l.pfb... 3357352 1954282 2437792
1107379 3 done.
> GS<1>



So I then tried to use -dSUBSTFONT=true ...

gs -sPAPERSIZE=a4 -dBATCH -dNOPAUSE -dSUBSTFONT=true -sDEVICE=faxg3
-sOutputFile=foo.tif foo.pdf

But again, the same result you see above.

So then I purchased Adobe's fonts and added them per the sparse
documentation that I could find out there...

> # gs
> GPL Ghostscript 8.54 (2006-05-17)
> Copyright (C) 2006 artofcode LLC, Benicia, CA.  All rights reserved.
> This software comes with NO WARRANTY: see the file PUBLIC for details.
> GS>/AGaramond-Regular findfont
> Loading AGaramondPro-Regular font from /usr/local/share/Adobe Type Basics
OpenType Ed/Fonts/AGaramondPro-Regular.otf... 2863272 1395166 1766768 469147 1 done.
> GS<1>



Same result when run in any of these manners:

   gs -sPAPERSIZE=a4 -dBATCH -dNOPAUSE -sDEVICE=faxg3
-sOutputFile=foo.tif foo.pdf
   gs -sPAPERSIZE=a4 -dBATCH -dNOPAUSE -dSUBSTFONT=true -sDEVICE=faxg3
-sOutputFile=foo.tif foo.pdf
   gs -sFONTPATH=/usr/local/share/Adobe\ Type\ Basics\ OpenType\ Ed
-sPAPERSIZE=a4 \
        -dBATCH -dNOPAUSE -sDEVICE=faxg3 -sOutputFile=foo.tif foo.pdf

If anyone could give me some advice on how to get past the /invalidfont
error I would certainly appreciate it.  The PDF does open just fine with
Adobe Acrobat Reader - even though the AGaramond-Regular font does not
exist on the system.

Thanks,

Lee.
Comment 1 Alex Cherepanov 2007-01-05 21:29:58 UTC
The file appears to contain a font thet Ghostscript cannot interpret.
That's all one can say about the problem without a sample file.

Please attach a sample file.
Comment 2 Lee Howard 2007-01-09 15:14:45 UTC
Alex, can I send this PDF to you privately?  It has information on it that I
don't want posted publicly in this forum.
Comment 3 Ray Johnston 2007-01-09 15:59:23 UTC
You can post an attachment, then "Edit" the attachment to mark it as Private.

This does not guarantee privacy, but will restrict the window during which
the general public will be able to access the file.

Only Artifex engineers and consultants (which includes Alex) can access
files marked "Private". Artifex will use care in preserving the confidentiality
of any files tagged as "Private", but without a specific NDA, we are liable
for any breach of confidentiality. Since Alex is an Artifex engineer, he also
cannot accept the file with any conditions for confidentiality.

What I suggest is that you create a file that does not contain sensitive
information, possibly by editing the original data. You may be able to use
the toolbin/pdfinflt.ps to create an non-compressed version which may allow
you to edit it without destroying the structure of the PDF (replace sensitive
text with blanks).

Unless we get a file that can demonstrate the problem we will have to close
the bug as INVALID (i.e., the bug submission is incomplete).
Comment 4 Lee Howard 2007-01-09 16:25:36 UTC
Created attachment 2673 [details]
problem PDF sample

I was able to remove the confidential parts with hexedit.  Thanks.  Here it is
now.
Comment 5 Alex Cherepanov 2007-01-09 19:02:46 UTC
Created attachment 2674 [details]
patch

The PDF file is incorrect. Tf operator refers to a font name directly instead
of
using the resource name. 

The patch assumes that an unknown resource name is a font name. This fully
recovers the given sample file and avoids a PostScript error in other possible
cases. The patch doesn't affect the normal operation.
Comment 6 Lee Howard 2007-01-09 21:42:13 UTC
Thank you.  However, now I see "Error: /undefined in --get--"

# gs -sPAPERSIZE=a4 -dBATCH -dNOPAUSE -sDEVICE=faxg3 -sOutputFile=foo.tif foo.pdf
GPL Ghostscript 8.54 (2006-05-17)
Copyright (C) 2006 artofcode LLC, Benicia, CA.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Substituting font Helvetica-Bold for X0FU12BP.
Loading NimbusSanL-Bold font from
/usr/local/share/ghostscript/fonts/n019004l.pfb... 3512016 1659623 1983264
672111 3 done.
Substituting font Helvetica-Bold for X0FU09NP.
Substituting font Times-Bold for X0GR08NP.
Loading NimbusRomNo9L-Medi font from
/usr/local/share/ghostscript/fonts/n021004l.pfb... 3553984 1812134 2084184
777137 3 done.
Substituting font Times-Bold for X0GR11NP.
Substituting font Helvetica-Bold for X0FU08BP.
Substituting font Helvetica-Bold for X0FU07NP.
Substituting font Times-Bold for X0GR18BP.
Substituting font Helvetica-Bold for X0FU10BP.
Substituting font Helvetica-Bold for X0FU10NP.
Substituting font Helvetica-BoldOblique for X0FU10VP.
Loading NimbusSanL-BoldItal font from
/usr/local/share/ghostscript/fonts/n019024l.pfb... 3587264 1913685 2427312
1103175 3 done.
Page 2
Substituting font Helvetica-Bold for X0FU12BP.
Substituting font Helvetica-Bold for X0FU09NP.
Substituting font Times-Bold for X0GR08NP.
Substituting font Times-Bold for X0GR11NP.
Substituting font Helvetica-Bold for X0FU08BP.
Substituting font Helvetica-Bold for X0FU07NP.
Substituting font Times-BoldItalic for X0GR12IP.
Loading NimbusRomNo9L-MediItal font from
/usr/local/share/ghostscript/fonts/n021024l.pfb... 3629680 2053847 2417608
1085766 3 done.
   **** Warning: Tf refers to an unknown resource name: AGaramond-Regular
Assuming it's a font name.
Can't find (or can't open) font file
/usr/local/share/ghostscript/8.54/Resource/Font/AGaramond-Regular.
Can't find (or can't open) font file AGaramond-Regular.
Querying operating system for font files...
Didn't find this font on the system!
Substituting font Palatino-Roman for AGaramond-Regular.
Loading URWPalladioL-Roma font from
/usr/local/share/ghostscript/fonts/p052003l.pfb... 3662960 2224158 2538360
1211484 3 done.
Error: /undefined in --get--
Operand stack:
   --dict:8/8(L)--   0.999997   --dict:8/8(L)--   1   MyriadPro-Regular   10  
--dict:8/8(L)--   --dict:8/8(L)--   405431   --dict:8/8(L)--   locatable  
--dict:8/13(L)--   loca
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--  
--nostringval--   2   %stopped_push   --nostringval--   --nostringval--  
--nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3  
%oparray_pop   1   3   %oparray_pop   --nostringval--   --nostringval--   3   1
  2   --nostringval--   %for_pos_int_continue   --nostringval--  
--nostringval--   --nostringval--   %array_continue   --nostringval--  
--nostringval--   --nostringval--   --nostringval--   --nostringval--   5   11 
 %oparray_pop   --nostringval--   false   1   %stopped_push   5   11  
%oparray_pop   --nostringval--   (gstatetype)   --dict:0/0(L)--  
--nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue 
 --nostringval--   --nostringval--   --nostringval--   --nostringval--  
--nostringval--   --nostringval--  --nostringval--   --nostringval--
Dictionary stack:
   --dict:1123/1686(ro)(G)--   --dict:2/20(G)--   --dict:75/200(L)--  
--dict:75/200(L)--   --dict:105/127(ro)(G)--   --dict:253/347(ro)(G)--  
--dict:21/24(L)--   --dict:4/6(L)--   --dict:21/32(L)--   --dict:19/21(L)--  
--dict:11/13(L)--   --dict:33/50(ro)(G)--   --dict:18/40(L)--
Current allocation mode is local
GPL Ghostscript 8.54: Unrecoverable error, exit code 1
Comment 7 Alex Cherepanov 2007-01-10 05:40:35 UTC
The file has another problem in an embedded TrueType font.
A work around for several TrueType issues have been added to the current
development version.

There's no packaged version that can resd the sample file.
You need to get the sources by 
  svn co http://svn.ghostscript.com:8080/ghostscript/trunk/gs
and compile.
Comment 8 Lee Howard 2007-01-10 11:50:14 UTC
Works for me now with SVN code plus the patch.  Thanks a lot!
Comment 9 Alex Cherepanov 2007-01-31 14:03:57 UTC
The patch is committed as rev. 7663.