Im trying to convert a PDF-File in a Postscript File. The PDF is including a TTF-Font "Code-128". The Font ist loacted in the file "/global/appl/vera/dirk/code_128.ttf" Although Ghostscript has loaded the TTF Font successfully, it don't use the font and but does a Font-Substitution: "Substituting font Times-Roman for Code-128" In the Command-Line gs -dNOFONTMAP -dNOPAUSE -dBATCH -DDEBUG -dTTFDEBUG - sFONTPATH=/global/appl/vera/dirk/font -sDEVICE=pswrite -sOutputFile=test.ps - dCompressionMethod=0 test_neu1.pdf there is the Option -dNOFONTPATH present, so I think ghostscript shuoldn't do this Font-Substitution /FirstChar 24 /Encoding /WinAnsiEncoding /BaseFont /Code-128 /LastChar 255 /Type /Font /Subtype /Type1 /Widths 20 0 R /FontDescriptor 21 0 R /Name /X5 >> endobj %Resolving: [21 0] << /MaxWidth 502 /Ascent 998 /Flags 32 /AvgWidth 425 /Descent 0 /ItalicAngle 0 /Type /FontDescriptor /StemV 0 /CapHeight 998 /FontBBox [ 0 0 0 0 ] /FontName /Code-128 >> endobj Loading Code-128 font from /global/appl/vera/dirk/font/code_128.ttf... .loadttfont OS/2 8096 78 PCLT 8176 54 cmap 7028 622 glyf 924 5398 hdmx 8232 1864 head 220 54 hhea 276 36 hmtx 7652 444 loca 6324 448 maxp 312 32 name 344 570 post 6772 256 prep 916 8 post: format 2,0 post= [/.notdef /.null /CR /space /exclam /quotedbl /numbersign /dollar /percent /ampe rsand /quotesingle /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one /two /three /four /five /six /seven /eight /nine /colon /semi colon /less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash /bracketright /a sciicircum /underscore /grave /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar /braceright /asciitilde /acute /mu1 /Agrave /Aacute /Acircumflex /Adieresis /Egrave /Odieresis /Udieresis /germandbl s /adieresis /odieresis /udieresis] cmap: platform 0 encoding 0 cmap: platform 1 encoding 0 cmap: platform 3 encoding 1 glyphencoding: length=111 [/.notdef /.null /CR /space /exclam /quotedbl /numbersign /dollar /percent /ampe rsand /quotesingle /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one /two /three /four /five /six /seven /eight /nine /colon /semi colon /less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash /bracketright /a sciicircum /underscore /grave /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar /braceright /asciitilde /acute /mu1 /Agrave /Aacute /Acircumflex /Adieresis /Egrave /Odieresis /Udieresis /germandbl s /adieresis /odieresis /udieresis] cmap: format 4 scode=32 ecode=126 delta=0 droff=24 scode=180 ecode=181 delta=0 droff=212 scode=192 ecode=194 delta=0 droff=214 scode=196 ecode=196 delta=0 droff=218 scode=200 ecode=200 delta=0 droff=218 scode=214 ecode=214 delta=0 droff=218 scode=220 ecode=220 delta=0 droff=218 scode=223 ecode=223 delta=0 droff=218 scode=228 ecode=228 delta=0 droff=218 scode=246 ecode=246 delta=0 droff=218 scode=252 ecode=252 delta=0 droff=218 cmap: length=253 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 98 99 0 0 0 0 0 0 0 0 0 0 100 101 102 0 103 0 0 0 104 0 0 0 0 0 0 0 0 0 0 0 0 0 105 0 0 0 0 0 106 0 0 107 0 0 0 0 108 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 109 0 0 0 0 0 110] CharStrings: W 58 b 69 germandbls 107 two 21 m 80 F 41 equal 32 x 91 Q 52 bar 95 exclam 4 Egrave 104 quotesingle 10 comma 15 g 74 seven 26 r 85 K 46 backslash 63 Aacute 101 V 57 ampersand 9 a 68 one 20 l 79 E 40 less 31 w 90 P 51 braceleft 94 space 3 plus 14 f 73 six 25 q 84 J 45 bracketleft 62 acute 98 U 56 mu1 99 percent 8 Agrave 100 odieresis 109 zero 19 k 78 D 39 semicolon 30 v 89 O 50 adieresis 108 .notdef 0 Z 61 udieresis 110 asterisk 13 e 72 five 24 p 83 I 44 .null 1 at 35 T 55 grave 67 dollar 7 Odieresis 105 slash 18 j 77 C 38 colon 29 u 88 N 49 underscore 66 Adieresis 103 Y 60 parenright 12 d 71 Udieresis 106 four 23 o 82 H 43 question 34 z 93 S 54 asciitilde 97 numbersign 6 period 17 i 76 B 37 nine 28 t 87 M 48 asciicircum 65 X 59 parenleft 11 c 70 three 22 n 81 G 42 greater 33 y 92 R 53 braceright 96 quotedbl 5 CR 2 hyphen 16 h 75 A 36 eight 27 s 86 L 47 bracketright 64 Acircumflex 102 setting alias: /verticalbar to be the same as glyph: /bar setting alias: /mu to be the same as glyph: /mu1 setting alias: /spacehackarabic to be the same as glyph: /space Encoding: [/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notde f /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notd ef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.not def /.notdef /.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl /numbe rsign /dollar /percent /ampersand /quotesingle /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one /two /three /four /five /six /sev en /eight /nine /colon /semicolon /less /equal /greater /question /at /A /B /C / D /E /F /G /H /I /J /K /L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore /grave /a /b /c /d /e /f /g / h /i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar /braceri ght /asciitilde /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef / .notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notde f /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notd ef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.not def /.notdef /acute /mu1 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef / .notdef /.notdef /.notdef /.notdef /Agrave /Aacute /Acircumflex /.notdef /Adiere sis /.notdef /.notdef /.notdef /Egrave /.notdef /.notdef /.notdef /.notdef /.not def /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /Odi eresis /.notdef /.notdef /.notdef /.notdef /.notdef /Udieresis /.notdef /.notdef /germandbls /.notdef /.notdef /.notdef /.notdef /adieresis /.notdef /.notdef /. notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef / .notdef /.notdef /.notdef /.notdef /.notdef /.notdef /odieresis /.notdef /.notde f /.notdef /.notdef /.notdef /udieresis /.notdef /.notdef /.notdef] findname: 6 = (Code-128) findname: 0 = (Copyright \251 1999 Dr. Materna GmbH) findname: 1 = (Code-128) findname: 4 = (Code-128) findname: 5 = (1.0 Wed Oct 27 09:21:42 1999) head 188 54 hhea 242 36 maxp 278 32 name 310 570 prep 880 8 glyf 888 5398 loca 6286 448 post 6734 256 cmap 6990 622 hmtx 7612 444 OS/2 8056 78 [188 54 36 32 570 8 5398 448 256 622 444 78] /FontMatrix [1.0 0.0 0.0 1.0 0.0 0.0] /FontBBox [0.0 0.0 0.469696969 1.0] /FontName (Code-128) /FontInfo -dict- /XUID [107 42 -2147483647] numloca=111 2696400 1146636 14175660 12490177 3 done. %Resolving: [21 0] Substituting font Times-Roman for Code-128. %Resolving: [21 0] %Resolving: [20 0]
Please attach the PDF file and the font file for testing.
Created attachment 3854 [details] This is the PDF-File which use the font Code-128 The conversion works fine under Windows XP with Ghostscript 8.61, but it not works under Linux with ghoestscript 8.62 !
Created attachment 3855 [details] This is the TTF-Font When working fine you should see a Barcode on the document in upper right corner. The file code_128.ttf is the font for displaying the barcode. Because the wrong conversion under linux i will not see the barcode after printing the converted ps-file.
I opened the file here with Acrobat 7 and immediately got a warning (disappeared too quick to see what). The bar code does not display, and the font 'Code-128' is listed in the fonts tab as using Adobe Sans MM. On exit Acrobat asks whether to save changes, so it looks like it repaired some damage to the file. Acrobat 5 gives the same results. Ghostscript 8.60 also does not display the bar code (I don't have a copy of 8.61 to hand) and gives a warning about an invalid XREF table. It substitutes a number of fonts, including Code-128 and gives a warning that a stream length is incorrect. The file seems to be damaged, possibly during upload here. If this is not the observed behaviour with the original file, please upload a new copy. You may like to zip the PDF file first, to reduce any problems with system translations. Or at least make it more obvious that there is some translation occurring. If the original file behaves the same way (especially with Acrobat), then I do not believe this is a GS bug. Ghostscript seems to me to be behaving as well as Adobe Acrobat in the face of a damaged file.
This is definitely a regression in 8.62. I've attached a customer's PDF file 'cg.ttf' that uses the 'CenturyGothic' font. With 8.61, with the Windows 'GOTHIC.TTF' file in the directory specified by -sFONTPATH I see: %Resolving: [13 0] << /Subtype /TrueType /FontDescriptor 18 0 R /LastChar 255 /Widths [ --- snip --- ] /BaseFont /CenturyGothic /FirstChar 0 /Encoding /WinAnsiEncoding /Type /Font >> endobj %Resolving: [18 0] << /StemV 68 /FontName /CenturyGothic /FontStretch /Normal /FontWeight 400 /Flags 32 /Descent -307 /FontBBox [ -169 -307 1152 1060 ] /Ascent 1060 /FontFamily (Century Gothic) /CapHeight 718 /XHeight 531 /Type /FontDescriptor /ItalicAngle 0 >> endobj Scanning c:/windows/fonts for fonts... 273 files, 105 scanned, 94 new fonts. Loading CenturyGothic font from c:/windows/fonts/GOTHIC.TTF... 3366636 1900985 2998948 1638775 3 done. %Resolving: [18 0] %Resolving: [18 0] -0.12 Tc 0.6375 Tw 0 -1 1 0 1303.5 2380.5 Tm (WICKLIFFE, OHIO) Tj ============================================================================== With 8.62, it _does_ find the CenturyGothic font, but then does a substitution: %Resolving: [13 0] << /Subtype /TrueType /FontDescriptor 18 0 R /LastChar 255 /Widths [ --- snip --- ] /BaseFont /CenturyGothic /FirstChar 0 /Encoding /WinAnsiEncoding /Type /Font >> endobj %Resolving: [18 0] << /StemV 68 /FontName /CenturyGothic /FontStretch /Normal /FontWeight 400 /Flags 32 /Descent -307 /FontBBox [ -169 -307 1152 1060 ] /Ascent 1060 /FontFamily (Century Gothic) /CapHeight 718 /XHeight 531 /Type /FontDescriptor /ItalicAngle 0 >> endobj Scanning c:/windows/fonts for fonts... 273 files, 105 scanned, 94 new fonts. Loading CenturyGothic font from c:/windows/fonts/GOTHIC.TTF... 3344188 1870317 12140036 10835724 3 done. %Resolving: [18 0] Substituting font NewCenturySchlbk-Roman for CenturyGothic. Loading CenturySchL-Roma font from /fonts/c059013l.pfb... 3404476 1939258 12140036 10836634 3 done. %Resolving: [18 0] %Resolving: [18 0] -0.12 Tc 0.6375 Tw 0 -1 1 0 1303.5 2380.5 Tm (WICKLIFFE, OHIO) Tj ============================================================================== This is clearly incorrect, and a regression from the correct behavior of 8.61 Assigning to Alex, and bumping the priority to reflect that this is a customer bug.
Created attachment 3856 [details] CG.pdf Customer's file that shows the problem
This regression was introduced in r8509, which fixed bug 689637.
The change made by the rev. 8509 accepts only resource fonts. Unfortunately, the fonts found in the search path are not considered to be resource fonts. The semantics of the resource font flag cannot be changed because it is used in other parts of the code. Even if we accept fonts found in the search path, we will still ignore the fonts defined in VM prior to running the PDF file. For now, we need another flag to mark embedded PDF fonts and ignore them during resource look-up. The font dictionary itself seems to be a good place for the new flag. A better solution would avoid registering embedded PDF fonts as resources and access them only by the reference.
Created attachment 3857 [details] test.pdf Packed as zip I have uploaded the PDF again (packed as zip-File). I know that there is a error contained in the in the document (but we cannot fix it, because the document is created by a 3rd party system). Nevertheless the conversion to postscript format works right (with the barcode font) using Ghostscript 8.61 both under Linux and Windows. So it seems to be a special problem of version 8.62 .
Is there any chance to get it to work with version 8.62 or do we have to use the version 8.61 furthermore ?
Created attachment 3876 [details] experimental patch This patch implements the proposed approach - mark the embedded fonts. However, the patch breaks Bug689644.pdf from our test file collection. I'm looking into the problem now.
This problem is now fixed. The relevant revisions are 8772, 8774, 8775. http://ghostscript.com/pipermail/gs-cvs/2008-May/008350.html http://ghostscript.com/pipermail/gs-cvs/2008-May/008352.html http://ghostscript.com/pipermail/gs-cvs/2008-May/008353.html