Created attachment 6585 [details] pdf with TimesNewRoman font Hi, I've a problem with one my customer. He sends me pdf documents and fonts are TimesNewRoman. I'm using newest Ghostscript and distribution is Centos 5.5. The output is: /opt/bin/gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=/root/pdfs/test2.pdf /root/pdfs/20100630144713_136.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 "TimesNewRoman". Substituting CID font /Adobe-Identity for /TimesNewRoman, see doc/Use.htm#CIDFontSubstitution. Error: /undefinedresource in findresource Operand stack: --dict:8/17(L)-- F0 12 --dict:7/7(L)-- --dict:7/7(L)-- TimesNewRoman --dict:10/12(ro)(G)-- --nostringval-- CIDFontObject --dict:8/8(L)-- --dict:8/8(L)-- Adobe-Identity CIDFont true Adobe-Identity Adobe-Identity NimbusRomNo9L-Regu 17 NimbusRomNo9L-Regu 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 --nostringval-- --nostringval-- 1829 13 11 %oparray_pop findresource %errorexec_pop --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- Dictionary stack: --dict:1151/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:21/40(L)-- --dict:1/1(ro)(G)-- --dict:9/15(L)-- --dict:20/26(ro)(G)-- Current allocation mode is local GPL Ghostscript 8.71: Unrecoverable error, exit code 1 In cidfmap I've made this change: /Adobe-Identity /NimbusRomNo9L-Regu ; I run this command with strace and I see : open("/opt/share/ghostscript/8.71/Resource/Init/CIDFont/NimbusRomNo9L-Regu", O_RDONLY) = -1 ENOENT (No such file or directory) So I have created this directory and copied NimbusRomNo9L-Regu file, but I get now this: /opt/bin/gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=/root/pdfs/test2.pdf /root/pdfs/20100630144713_136.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 "TimesNewRoman". Substituting CID font /Adobe-Identity for /TimesNewRoman, 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:8/17(L)-- F0 12 --dict:7/7(L)-- --dict:7/7(L)-- TimesNewRoman --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:1151/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:21/40(L)-- --dict:1/1(ro)(G)-- --dict:9/15(L)-- Current allocation mode is local Last OS error: 2 GPL Ghostscript 8.71: Unrecoverable error, exit code 1 Can somebody help me with this problem?
Hi, Now I have made some changes in cidfmap: /TimesNewRoman << /FileType /TrueType /Path (/usr/share/fonts/truetype/msttcorefonts/times.ttf) /SubfontID 0 /CSI [(Unicode) 0] >> ; and gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=1.pdf 20100630144713_136.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/msttcorefonts/times.ttf to emulate a CID font TimesNewRoman ... Done. Error: /typecheck in --run-- Operand stack: --dict:8/17(L)-- F0 12 --dict:7/7(L)-- --dict:7/7(L)-- TimesNewRoman --dict:9/10(L)-- --dict:7/7(L)-- --dict:9/10(L)-- --nostringval-- --nostringval-- 0 0 1 2 (\003\003\004\004\005\005\006\006\007\007\b\b\t\t\n\n\013\013\f\f\r\r\016\016\017\017\020\020\021\021\022\022\023\023\024\024\025\025\026\026\027\027\030\030\031\031\032\032\033\033\034\034\035\035\036\036\037\037 !!""##$$%%&&''\(\(\)\)**++,,--..//00112233445566778899::;;<<==>>??@@AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ[[\\\\]]^^__``aa\003\003\243\243\204\204\205\205) (\000!\000!\000"\000#\000$\000%\000&\000'\000\(\000\)\000*\000+\000,\000-\000.\000/\0000\0001\0002\0003\0004\0005\0006\0007\0008\0009\000:\000;\000<\000=\000>\000?\000@\000A\000B\000C\000D\000E\000F\000G\000H\000I\000J\000K\000L\000M\000N\000O\000P\000Q\000R\000S\000T\000U\000V\000W\000X\000Y\000Z\000[\000\\\000]\000^\000_\000`\000a\000b\000c\000d\000e\000f\000g\000h\000i\000j\000k\000l\000m\000n\000o\000p\000q\000r\000s\000t\000u\000v\000w\000x\000y\000z\000{\000|\000}\000~\000\240\000\241\000\242\000\243) (\000!) 33 34 1 (\003\003\004\004\005\005\006\006\007\007\b\b\t\t\n\n\013\013\f\f\r\r\016\016\017\017\020\020\021\021\022\022\023\023\024\024\025\025\026\026\027\027\030\030\031\031\032\032\033\033\034\034\035\035\036\036\037\037 !!""##$$%%&&''\(\(\)\)**++,,--..//00112233445566778899::;;<<==>>??@@AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ[[\\\\]]^^__``aa\003\003\243\243\204\204\205\205) 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-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- 5 5 729 --nostringval-- %for_pos_int_continue --nostringval-- 4 2 197 --nostringval-- %for_pos_int_continue --nostringval-- Dictionary stack: --dict:1155/1684(ro)(G)-- --dict:1/20(G)-- --dict:76/200(L)-- --dict:76/200(L)-- --dict:108/127(ro)(G)-- --dict:288/300(ro)(G)-- --dict:22/25(L)-- --dict:6/8(L)-- --dict:21/40(L)-- --dict:1/1(ro)(G)-- --dict:9/15(L)-- --dict:1/100(L)-- Current allocation mode is local GPL Ghostscript 8.71: Unrecoverable error, exit code 1 Can you help me with it...
(In reply to comment #1) > Now I have made some changes in cidfmap: > /TimesNewRoman << /FileType /TrueType /Path > (/usr/share/fonts/truetype/msttcorefonts/times.ttf) /SubfontID 0 /CSI > [(Unicode) 0] >> ; You should specify two strings in CSI, eg : /CSI [(Artifex) (Unicode) 0] However this 'works' for me either way with the Windows version of times.ttf. The glyphs are totally incorrect, but there is no error. This is using the HEAD revision of GS of course, you haven't specified which version of Ghostscript you are using.
(In reply to comment #2) > (In reply to comment #1) > > > Now I have made some changes in cidfmap: > > /TimesNewRoman << /FileType /TrueType /Path > > (/usr/share/fonts/truetype/msttcorefonts/times.ttf) /SubfontID 0 /CSI > > [(Unicode) 0] >> ; > > You should specify two strings in CSI, eg : > > /CSI [(Artifex) (Unicode) 0] Now I've made cidfmap like this: /TimesNewRoman << /FileType /TrueType /Path (/usr/share/fonts/msttcorefonts/times.ttf) /SubfontID 0 /CSI [(Artifex) (Unicode) 0] >> ; > > However this 'works' for me either way with the Windows version of times.ttf. Could you please share your font and cidfmap? I've tried in windows with gs 8.71 - the same issue? > The glyphs are totally incorrect, but there is no error. This is using the HEAD > revision of GS of course, you haven't specified which version of Ghostscript > you are using. The ghostscript version is 8.71. After these changes I tried again , but still without success: gs -dBATCH -dNOPAUSE -I/usr/local/share/ghostscript/8.71/Resource/Init -sDEVICE=pdfwrite -sOutputFile=1.pdf 20100630144713_136.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/msttcorefonts/times.ttf to emulate a CID font TimesNewRoman ... Done. Error: /typecheck in --run-- Operand stack: --dict:8/17(L)-- F0 12 --dict:7/7(L)-- --dict:7/7(L)-- TimesNewRoman --dict:9/10(L)-- --dict:7/7(L)-- --dict:9/10(L)-- --nostringval-- --nostringval-- 0 0 1 2 (\003\003\004\004\005\005\006\006\007\007\b\b\t\t\n\n\013\013\f\f\r\r\016\016\017\017\020\020\021\021\022\022\023\023\024\024\025\025\026\026\027\027\030\030\031\031\032\032\033\033\034\034\035\035\036\036\037\037 !!""##$$%%&&''\(\(\)\)**++,,--..//00112233445566778899::;;<<==>>??@@AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ[[\\\\]]^^__``aa\003\003\243\243\204\204\205\205) (\000!\000!\000"\000#\000$\000%\000&\000'\000\(\000\)\000*\000+\000,\000-\000.\000/\0000\0001\0002\0003\0004\0005\0006\0007\0008\0009\000:\000;\000<\000=\000>\000?\000@\000A\000B\000C\000D\000E\000F\000G\000H\000I\000J\000K\000L\000M\000N\000O\000P\000Q\000R\000S\000T\000U\000V\000W\000X\000Y\000Z\000[\000\\\000]\000^\000_\000`\000a\000b\000c\000d\000e\000f\000g\000h\000i\000j\000k\000l\000m\000n\000o\000p\000q\000r\000s\000t\000u\000v\000w\000x\000y\000z\000{\000|\000}\000~\000\240\000\241\000\242\000\243) (\000!) 33 34 1 (\003\003\004\004\005\005\006\006\007\007\b\b\t\t\n\n\013\013\f\f\r\r\016\016\017\017\020\020\021\021\022\022\023\023\024\024\025\025\026\026\027\027\030\030\031\031\032\032\033\033\034\034\035\035\036\036\037\037 !!""##$$%%&&''\(\(\)\)**++,,--..//00112233445566778899::;;<<==>>??@@AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ[[\\\\]]^^__``aa\003\003\243\243\204\204\205\205) 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-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- 5 5 729 --nostringval-- %for_pos_int_continue --nostringval-- 4 2 197 --nostringval-- %for_pos_int_continue --nostringval-- Dictionary stack: --dict:1151/1684(ro)(G)-- --dict:1/20(G)-- --dict:76/200(L)-- --dict:76/200(L)-- --dict:108/127(ro)(G)-- --dict:288/300(ro)(G)-- --dict:22/25(L)-- --dict:6/8(L)-- --dict:21/40(L)-- --dict:1/1(ro)(G)-- --dict:9/15(L)-- --dict:1/100(L)-- Current allocation mode is local GPL Ghostscript 8.71: Unrecoverable error, exit code 1 I've installed times.ttf: yum list installed | grep -i ms msttcorefonts.noarch 2.0-1 installed
Created attachment 6639 [details] tiff file It seems that this problem appear only with pdfwrite device. If I use tiffg4 device and I convert pdf to tiff , I don't receive any errors, but tiff file is corrupted (new symbols, I don't see text).
(In reply to comment #4) > It seems that this problem appear only with pdfwrite device. If I use tiffg4 > device and I convert pdf to tiff , I don't receive any errors, but tiff file is > corrupted (new symbols, I don't see text). Does not happen for me, I was using the pdfwrite device as that was what was specified in the original report. Since the output using other devices is also incorrect this is clearly NOT a pdfwrite problem. I cannot attach a copy of times.ttf as this is a commercial font, supplied with Windows (in my case Windows Vista). Perhaps you would care to supply the font you are using. The entry in my cidfmap matches the one you have supplied.
Hi, I've retested this on windows XP, windows Vista and Windows 7 and the results are the same: I see boxes instead of letters. I've used ghostscript 8.71, downloaded from http://ghostscript.com/releases/gs871w32.exe. It's very strange what can be wrong. And could you please attach your output file ? Thanks
(In reply to comment #6) > I've retested this on windows XP, windows Vista and Windows 7 and the results > are the same: I see boxes instead of letters. Your original report was an undefinedresource error, your next result was a typecheck error in run. Seeing boxes (TrueType /.notdef glyphs I imagine) instead of letters is another different result. Clearly you have got past the errors, this is a different problem. Its not guaranteed possible to load a TrueType font, pretend its a CIDFont and get the same results as if the original CIDFont had been used. Ghostscript does generally manage it, but its not 100%. > I've used ghostscript 8.71, > downloaded from http://ghostscript.com/releases/gs871w32.exe. > It's very strange what can be wrong. Attempting to use a TrueType font to replace a missing CIDFont. When doing this you are reliant on some heuristic attempts inside Ghostscript to convert the CIDFont CIDs into TrueType font GIDs. This is done using the TrueType font's CMAP subtable, but depending on what table is available, it may not get the correct answer. > And could you please attach your output > file ? See my comment #2 'the glyphs are totally incorrect'. It seems you are now able to see what I was, so there is little point in attaching my output file.
But why Acrobat reader and other pdf viewers (Evince in Ubuntu) can open this doc successfully, but ghostscript (and gv viewer)not. As I understand acrobat reader also uses times.ttf for TimesNewRoman font? Maybe it's possible to trace acrobat reader to see how it opens this doc? Or maybe it uses other fonts? Thanks
(In reply to comment #8) > But why Acrobat reader and other pdf viewers (Evince in Ubuntu) can open this > doc successfully, but ghostscript (and gv viewer)not. I have no idea. Presumably they use a different set of heuristics. Please confirm that the *original* problem is now resolved. Bug reports that spiral out of control like this are very hard to follow and address. In fact it might be best to close this report, and open a new one. > As I understand acrobat > reader also uses times.ttf for TimesNewRoman font? Possibly. > Maybe it's possible to > trace acrobat reader to see how it opens this doc? Acrobat is proprietary commercial software from Adobe. Without the source code to the application I'm not sure how you think we should trace it. Also doing so would probably fall foul of the DMCA, if not other legal issues. > Or maybe it uses other > fonts? Possibly, its not really practical to tell. All I can say is that if it is using the same font, it is using a different set of heuristics to convert the CIDs into GIDs. Bear in mind that Ghostscript also needs to work for PostScript files, not just PDF files, Acrobat is only concerned with PDF.
Created attachment 6643 [details] obj_11_0.txt This is the ToUnicode map from the file's object 11. I extracted this using: (bug691513.pdf) (r) file runpdfbegin 11 0 R oforce true resolvestream /I exch def /O (obj_11_0.txt) (w) file def { I 20000 string readstring exch O exch writestring not { exit } if } loop O closefile
The ToUnicode CMap from the file sure doesn't look like an "Identity" map to me, but at least using that leads to sensible mapping. For example, the first string printed starts with: 0033 0039 0030 0003 0036 0104 0036 002e 0024 which we print as: 390<box>6A6.$ where the A has a little tail off of it. Using the info from the ToUnicode, this maps to: 0x50 0x56 0x4d 0x20 0x53 0x104 0x53 0x4b 0x41 which is what Adobe displays: PVM SĄSKA Now, how to do this automatically ?
Hi, Thanks for a help. I'm newbie with ghostscript, but how to use your ps file ? Thanks
As I understand your obj_11_0 ps file should be as Identity-H in CMap directory?
After this replace I have better results. Now I can see some words...
(In reply to comment #14) > After this replace I have better results. Now I can see some words... Finally I have fixed the issue. Thanks for help
in comment #13, voipas wrote: > As I understand your obj_11_0 ps file should be as Identity-H in CMap directory? The short answer is NO. If this works for you on this file, good for you, but as far as I understand these things, that doesn't look like it will help in general. That ToUnicode file I extracted from the PDF, while it has an Adobe Identity-H comment does NOT look like anything that I (or Ken) expects as an Identity CMap. Even though the submitter is happy, I am re-opening this bug because I want a better understanding from the Artifex font experts (Chris and Ken)
Basically, the only way to get this to work properly is to use a font with the same glyph ordering as the Times New Roman TTF that comes with MS Windows, and the correct cidfmap entry (the file expects an Adobe Identity ordering to be specified). This is expected behaviour.
I had a similar problem rendering a PDF 1.5 with French accents. I had to add the Identity-UTF16-H to the computer for it to render the text, once added, I had to add the following to cidfmap : /var/lib/ghostscript/fonts/cidfmap /Arial << /FileType /TrueType /Path (/usr/share/fonts/truetype/msttcorefonts/Arial.ttf) /SubfontID 0 /CSI [(Identity) 0] >> ; /Arial,Bold << /FileType /TrueType /Path (/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf) /SubfontID 0 /CSI [(Identity) 0] >> ; (Times New Roman,Bold) << /FileType /TrueType /Path (/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttf) /SubfontID 0 /CSI [(Identity) 0] >> ; (Times New Roman) << /FileType /TrueType /Path (/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf) /SubfontID 0 /CSI [(Identity) 0] >> ; The document renders fine now.