Reputation: 17
I was attempting to emulate a CID font, 'AdobeGothicStd-Bold', that exists as an OpenType font, using the following command (Ghostscript 9.27, Windows 10):
gswin64c.exe -I"C:/Program Files/gs/ghostscript-9.27/Resource/Init";"C:/Program Files/gs/ghostscript-9.27/Resource/Font" -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dPDFSTOPONERROR -dBATCH -dNOPAUSE -sOutputFile=output.pdf "C:/Temp/ghostscript_question_4-22-2019.pdf"
I've tried making the following addition in 'cidfmap' (this was before I realized in the documentation that substitutions in 'cidfmap' only work with TrueType fonts):
/AdobeGothicStd-Bold << /FileType /TrueType /Path (C:/Windows/Fonts/AdobeGothicStd-Bold.otf) /CSI [(Japan1) 2] >> ;
with the following output:
GPL Ghostscript 9.27 (2019-04-04)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 1.
Page 1
Loading a TT font from C:/WINDOWS/Fonts/AdobeGothicStd-Bold.otf to emulate a CID font AdobeGothicStd-Bold ... Done.
Error: /undefined in --get--
Operand stack:
--nostringval-- --dict:19/29(L)-- --nostringval-- --dict:19/29(L)-- --dict:1/1(L)-- N false true --dict:3/3(L)-- --dict:13/21(ro)(L)-- F0 13 5 --dict:6/15(L)-- --dict:6/15(L)-- AdobeGothicStd-Bold --dict:10/12(ro)(G)-- --nostringval-- --nostringval-- CIDFontObject --dict:8/17(L)-- --dict:8/17(L)-- AdobeGothicStd-Bold 26 10 75742 resourcefont --dict:29/32(L)-- undefinederror
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1992 1 3 %oparray_pop 1991 1 3 %oparray_pop 1979 1 3 %oparray_pop 1980 1 3 %oparray_pop --nostringval-- --nostringval-- 2 1 1 --nostringval-- %for_pos_int_continue 1983 1 7 %oparray_pop --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --dict:1/1(L)-- --nostringval-- 1 %dict_continue --nostringval-- 1968 7 9 %oparray_pop --nostringval-- 1969 8 9 %oparray_pop --nostringval-- 9 0 1913 10 10 %oparray_pop --nostringval-- false 1 %stopped_push 1912 10 10 %oparray_pop --nostringval-- --nostringval-- (gstatetype) --dict:0/0(L)-- --nostringval-- --nostringval-- %loop_continue 1964 15 10 %oparray_pop --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- --nostringval-- --nostringval-- --nostringval--
Dictionary stack:
--dict:735/1123(ro)(G)-- --dict:1/20(G)-- --dict:80/200(L)-- --dict:80/200(L)-- --dict:133/256(ro)(G)-- --dict:317/325(ro)(G)-- --dict:31/32(L)-- --dict:6/9(L)-- --dict:7/20(L)-- --dict:5/5(L)--
Current allocation mode is local
GPL Ghostscript 9.27: Unrecoverable error, exit code 1
I've also tried running the above command with the following change to Fontmap.GS:
/AdobeGothicStd-Bold (C:/Windows/Fonts/AdobeGothicStd-Bold.otf) ;
and the following output:
GPL Ghostscript 9.27 (2019-04-04)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 1.
Page 1
Can't find CID font "AdobeGothicStd-Bold".
Attempting to substitute CID font /Adobe-Korea1 for /AdobeGothicStd-Bold, see doc/Use.htm#CIDFontSubstitution.
The substitute CID font "Adobe-Korea1" is not provided either. attempting to use fallback CIDFont.See doc/Use.htm#CIDFontSubstitution.
Loading a TT font from C:/Program Files/gs/ghostscript-9.27/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font Adobe-Korea1 ... Done.
which tells me that the change in Fontmap.GS wasn't recognized (and I'm probably not supposed to be using Fontmap.GS for CID font substitutions).
Are we able to emulate CID fonts using an .OTF file? Or is this currently not supported?
I did see an external link from 2015 that explains how to setup CID fonts in Ghostscript, using OpenType font files:
https://www.preining.info/blog/2015/04/setting-up-cid-fonts-for-ghostscript-technical-notes/
But I don't know if the method applies to the current version of Ghostscript.
The PDF used in my question is found here:
https://drive.google.com/open?id=1hsUACus_T0pu7D2BGnWE2H_mUpfCBrtk
Upvotes: 0
Views: 1514
Reputation: 31159
The fundamental problem is that PostScript doesn't directly support TrueType. It supports type 42, which is a TrueType fotn wrapped up with extra information to allow a PostScript interpreter to use it. So in order to use a TrueType font as a substitute for a missing CIDFont (or Font), the itnerpreter has to make guesses about the missing information.
Usually this works, but sometimes it doesn't. The code which makes the guesses only expects to encounter TrueType fonts, and it gets some of the information it needs from the TrueType tables. What you are calling an OpenType font is a TrueType font with CFF outlines, that's actually an OTTO font, TrueType fonts must have TrueType outline data; OpenType fonts can have either TrueType or CFF outline data. An OTTO OpenType font doesn't have the same information that the code wants in the TrueType tables, and it has to be gathered instead from the dictionaries in the CFF font data.
I don't recall exactly how far along this process is right at the moment, its on-going.
As I always say in this sort of case, you should always embed all the fonts you are using in the PDF file. The PDF specification even says that this is the case for CIDFonts. Its the only way to guarantee reproducibility.
I can't try this out for you because I don't have a copy of AdobeGothicStd-Bold.otf, but there are several points whcih might help:
Note that all these points relate to supplying a substitute font to use in place of a font reference in a PDF file which does not have the font (or CIDFont) embedded. Embedded fonts, whatever outline type should work, and that includes OpenType fonts with CFF outlines.
Upvotes: 1