diff options
Diffstat (limited to 'toolbin/genfontmap.ps')
-rw-r--r-- | toolbin/genfontmap.ps | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/toolbin/genfontmap.ps b/toolbin/genfontmap.ps new file mode 100644 index 000000000..f1d7ab170 --- /dev/null +++ b/toolbin/genfontmap.ps @@ -0,0 +1,68 @@ +%!PS +% Copyright (C) 2001-2012 Artifex Software, Inc. +% All Rights Reserved. +% +% This software is provided AS-IS with no warranty, either express or +% implied. +% +% This software is distributed under license and may not be copied, +% modified or distributed except as expressly authorized under the terms +% of the license contained in the file LICENSE in this distribution. +% +% Refer to licensing information at http://www.artifex.com or contact +% Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael, +% CA 94903, U.S.A., +1(415)492-9861, for further information. +% + +% Create a Fontmap format file after scanning the FONTPATH directories +% +% Example usage: +% windows: gswin32c -q -sFONTPATH=c:/windows/fonts genfontmap.ps > myFontmap +% +% unix: gs -q -sFONTPATH=/usr/local/fonts genfontmap.ps > myFontmap +% +% The myFontmap file created by the above can be renamed to Fontmap and +% placed in the LIBPATH directory. + +/=error { (%stderr) (w) file exch writestring } def + +% First make sure there is a FONTPATH defined +FONTPATH length 0 eq { + (\n Specify a FONTPATH using -sFONTPATH or GS_FONTPATH in order to\n) =error + ( generate a Fontmap file from the fonts found in those folders.\n\n) =error + flush quit +} if + +QUIET not { + (\n You must use the '-q' option in order to generate a clean Fontmap.\n\n) =error + flush quit +} if + +% ------------------------------------------------------------------------- + +/Initial_count Fontmap length def + +( ) cvn findfont pop % force the scan + +% Create an array so we can sort it + +Fontmap { [ 3 1 roll ] } forall +count array astore + +% sort the array +{ 0 get 100 string cvs exch 0 get 100 string cvs gt } .sort + +% Now print it out in Fontmap format +(% This Fontmap generated by genfontmap.ps\n) = +{ + dup 0 get % get the name of the font + % Since the name might be Unicode, write it as a string + 100 string cvs ==only + ( ) print 1 get 0 get ==only ( ;) = +} forall +flush + +(\ngenfontmap completed OK. ) =error +Fontmap length Initial_count sub 10 string cvs =error +( new fonts added.\n\n) =error +quit |