%! % Copyright (C) 2001-2023 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., 39 Mesa Street, Suite 108A, San Francisco, % CA 94129, USA, for further information. % % Utility program for converting Japanese fonts produced by Macromedia's % Rollup program to Type 0 fonts suitable for use with Ghostscript. % % Rollup produces the following files, where xxx is the font name: % xxx-H, xxx-SA, xxx-SB, xxx-SK, xxx-SR, xxx-UG % JIS83-1_COD % JIS83-1_CSA % The _COD and _CSA files are large files containing the actual % character outline data; they may theoretically be shared between % multiple fonts. % % rollconv.ps converts the above to files named: % fff.ps % fff.COD % fff.CSA % fff.CSR % where fff is a font file name provided by the user at conversion time. % The fff.ps file is the actual font file to be loaded with `run' % or placed in a Fontmap or a directory named by [GS_]FONTPATH; % the other two files must be present at runtime in a directory that is % on Ghostscript's search path (-I, GS_LIB, GS_LIB_DEFAULT). % % The normal way to invoke this program is % gsnd -- rollconv.ps xxx fff InDir CDir OutDir % (assuming that gsnd is an alias for gs -dNODISPLAY), where: % xxx is the font name; % fff is the base part of the output file name; % InDir is the name of the directory containing the xxx-* input files; % CDir is the name of the directory containing the _COD and _CSA % input files (typically the same as InDir); % OutDir is the name of the directory where the output should be written % (OutDir must already exist). % For example: % gsnd -- rollconv.ps HGGothicBPRO gothic /gs/k/rufonts/Gothic \ % /gs/k/rufonts/Gothic /gs/k/gsfonts % To suppress output messages, you may insert -q: % gsnd -q -- rollconv.ps ... % % This program assumes that the files have been FTP'ed from a Macintosh and % therefore have 128 bytes of garbage at the beginning. If you have % transferred them in some manner that avoids this, change true to false % in the following line. /fromMac true def % The FontName of the converted font is xxx-83pv-RKSJ-H. In order to % use a converted font with Ghostscript, you may either load it explicitly % at run time, e.g., % (gothic.ps) run % or you may add an entry to the Fontmap file, in the form: % /HGGothicBPRO-83pv-RKSJ-H (gothic.ps) ; % which will allow the font to be loaded automatically. After % loading the font, by either method, you can select it in the usual way: % /HGGothicBPRO-83pv-RKSJ-H findfont 36 scalefont setfont % or % /HGGothicBPRO-83pv-RKSJ-H 36 selectfont /macrfile % macrfile { (r) file fromMac { % Get rid of the initial Mac garbage (128 characters). % The garbage at the end is unpredictable, % so we'll just have to hope that it's all nulls. dup =string 0 128 getinterval readstring pop pop } if } bind def /convert % convert - { /OutDir exch def /CDir exch def /InDir exch def /OutBase exch def /FName exch def /inprefix InDir (/) concatstrings FName concatstrings (-) concatstrings def /inh inprefix (H) concatstrings def % Open the output file. /OutDot OutDir (/) concatstrings OutBase concatstrings (.) concatstrings def /outname OutDot (ps) concatstrings def QUIET not { (Writing ) print outname = flush } if /cdfromstr (\(pgfonts/) FName concatstrings (-JIS83-1_) concatstrings def /cdstr (\() OutBase concatstrings (.) concatstrings def /out outname (w) file def /buffer 65000 string def % Copy the initial comments from the input file. inh macrfile { dup =string readline pop out 1 index writestring out (\n) writestring (%%EndComments) eq { exit } if } loop % Write out our preamble. out ( currentpacking true setpacking userdict /AltsysCFD3 known { (%END) .skipeof } if userdict /AltsysCFD3 25 dict dup begin /beint { 0 exch { exch 8 bitshift add } forall } bind def /rfile { findlibfile { exch pop } { (r) file } ifelse } bind def /str 500 string def /AltRO { } def /BuildCh % BuildCh - { /bias exch def /ccode exch def begin % font ccode dup 255 and dup bias lt exch 252 gt or { pop 127 } if dup -8 bitshift -67 mul add % subfonts have 189 chars, not 256 bias sub buildch1 } bind def /BuildChr % BuildChr - { /ccode exch def begin % font ccode buildch1 } bind def /buildch1 { 6 mul PGOffsets add FileNames 0 get rfile dup dup 4 -1 roll setfileposition (xxxxxx) readstring pop exch closefile dup 1 3 getinterval beint % COD offset exch 4 2 getinterval beint % length dup 0 eq { pop pop currentdict end 1000 0 0 0 1 1 0 -1000 500 1000 setcachedevice2 } { dup str length gt { /str 1 index string store } if FileNames 1 get rfile dup dup % offset length file file file 5 -1 roll setfileposition % length file file str 0 5 -1 roll getinterval readstring pop pop closefile currentdict end ccode str 1183615869 internaldict /CCRun get exec } ifelse } bind def /privates 100 dict def /BuildPr % BuildPr { 2 copy 1000 mul add privates 1 index known { privates exch get 3 1 roll pop pop } { 7 dict begin /MinFeature{16 16}executeonly def /BlueValues BlueValues def /StdVW 3 -1 roll 1 array astore def /StdHW 3 -1 roll 1 array astore def /password 5839 def /LanguageGroup 1 def /Subrs Subrs def currentdict readonly end privates 2 index 2 index put exch pop } ifelse } bind def /FullEncoding systemdict { pop } forall systemdict length 512 sub 1 255 { (x) dup 0 4 -1 roll put cvn } for 768 packedarray def /BlueValues[-250 -250 1100 1100]readonly def /BuildChar{AltsysCFD3 begin 64 BuildCh end}bind def /CharStrings 1 dict dup /.notdef (