This is an enhancement that is windows specific, but could be generalized to allow for environment variables to be inserted into paths. The specific request was to be able to use %windir%/fonts/ prefix in the cidfmap, but I suggest implementing this in a general fashion, and _could_ be used on other platforms as well (linux, unix, OS/X, ...). The use of '%' is problematic, however since it conflicts with the Adobe defines standard for IODevice delimiters such as (%rom%...), but since only the _first_ %___% part of a path is taken as a device delimiter, we could use (%os%%windir%/fonts/...) to be unambiguous. Another method would be to require an escape character prefix prior to the '%' as in: (\\%windir%/fonts/...), I (slightly) prefer the latter, but suggestions are welcome.
What's wrong with the following? (%os%) (windir) getenv concatstrings (/Fonts/) concatstrings
cidfmap file is a PostScript program that can use any PostScipt operators and Ghostscript extensions to construct the path dynamically. For instance, ... (windir) getenv (/Fonts/) concatstrings ... A comment that shows how to do this has been added to the cidfmap file by the rev.
87045a3280e268a52f0d738d34f2a6a3ea093406
The syntax recommended by Alex, and committed to the comments section of cidfmap on 2011-07-29 20:37:42 UTC, is failing on Windows 7-64 with GS 9.04 with the example below. FAILS: /Webdings << /CSI [(Identity) 0] /Path (windir)getenv(/fonts/webdings.ttf)concatstrings /SubfontID 0 /FileType /TrueType >> ; WORKS: /Webdings << /CSI [(Identity) 0] /Path (windir) getenv pop (/fonts/webdings.ttf) concatstrings /SubfontID 0 /FileType /TrueType >> ; Command line testing shows that '(windir) getenv' places two items on the stack: <1> true <2> C:\Windows We need to delete the top item with 'pop' before string concatenation.
I updated the examples and documentation to reflect that a few weeks ago, but thanks for pointing it out.
Actually, ghostscript's "getenv" operator is defined as: <string> getenv <value_string> true <string> getenv false Thus the correct procedure is: /Webdings << /CSI [(Identity) 0] /Path (windir) getenv not { () } if (/fonts/webdings.ttf) concatstrings /SubfontID 0 /FileType /TrueType >> ; Thus if gentenv returns false, an empty string will be concatenated to the font directory.
The updated example in the default cidfmap uses the boolean return to decide whether to fall back to a default value. Does this bug really need reopened?
No, I looked in the "Use.htm#CIDFontSubstitution" and didn't see it there. I agree that what's in the Resource/Init/cidfmap looks OK (my comment was based on the the assumption that you had taken the "WORKS" from comment 4 (which would fail if the windir environment wasn't found. What documentation did you update ?
Hmm, looks like I didn't update the documentation, just the example. I'll add it to the section about cidfmap on Monday.
The current example in cidfmap fails: /Ryumin-Medium << /FileType /TrueType /Path (windir) getenv not {c:/windows}if (/Fonts/BATANG.TTC)concatstrings /SubfontID 3 /CSI [(Japan1) 2] >> ; Should be: /Ryumin-Medium << /FileType /TrueType /Path (windir) getenv not {(c:/windows)}if (/Fonts/BATANG.TTC)concatstrings /SubfontID 3 /CSI [(Japan1) 2] >> ;
I've fixed the example (thanks Joe!), and added stuff about "getenv" in cidfmap in the appropriate section in Use.htm.