Bug 691184 - Customer wants to be able to specify path relative to %windir% for system fonts
Summary: Customer wants to be able to specify path relative to %windir% for system fonts
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Font API (show other bugs)
Version: master
Hardware: All Windows XP
: P2 enhancement
Assignee: Vasu Raman
URL:
Keywords: bountiable
Depends on:
Blocks:
 
Reported: 2010-03-17 19:00 UTC by Ray Johnston
Modified: 2012-04-12 17:16 UTC (History)
4 users (show)

See Also:
Customer: 580
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ray Johnston 2010-03-17 19:00:02 UTC
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.
Comment 1 Alex Cherepanov 2011-07-24 23:24:03 UTC
What's wrong with the following?
(%os%) (windir) getenv concatstrings (/Fonts/) concatstrings
Comment 2 Alex Cherepanov 2011-07-29 20:37:06 UTC
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.
Comment 3 Alex Cherepanov 2011-07-29 20:37:42 UTC
87045a3280e268a52f0d738d34f2a6a3ea093406
Comment 4 Joe Mooring 2012-01-21 18:04:04 UTC
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.
Comment 5 Chris Liddell (chrisl) 2012-01-21 18:17:31 UTC
I updated the examples and documentation to reflect that a few weeks ago, but thanks for pointing it out.
Comment 6 Ray Johnston 2012-01-21 20:23:52 UTC
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.
Comment 7 Chris Liddell (chrisl) 2012-01-21 20:57:06 UTC
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?
Comment 8 Ray Johnston 2012-01-21 21:09:26 UTC
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 ?
Comment 9 Chris Liddell (chrisl) 2012-01-21 21:22:48 UTC
Hmm, looks like I didn't update the documentation, just the example. I'll add it to the section about cidfmap on Monday.
Comment 10 Joe Mooring 2012-01-21 22:12:24 UTC
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] >> ;
Comment 11 Chris Liddell (chrisl) 2012-01-24 17:13:39 UTC
I've fixed the example (thanks Joe!), and added stuff about "getenv" in cidfmap in the appropriate section in Use.htm.