1 % Copyright (C) 1995, 1996 Aladdin Enterprises. All rights reserved.
3 % This software is provided AS-IS with no warranty, either express or
6 % This software is distributed under license and may not be copied,
7 % modified or distributed except as expressly authorized under the terms
8 % of the license contained in the file LICENSE in this distribution.
10 % For more information about licensing, please refer to
11 % http://www.ghostscript.com/licensing/. For information on
12 % commercial licensing, go to http://www.artifex.com/licensing/ or
13 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14 % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
16 % $Id: wftopfa.ps,v 1.5 2003/08/08 18:45:05 ray Exp $
18 % Convert a Wadalab base font to .PFA (or .PFB) format.
20 (gs_ksb_e.ps) runlibfile
21 (wrfont.ps) runlibfile
23 /wftopfa_dict 100 dict def
26 /KanjiSubEncoding dup .findencoding def
28 % Initialize parameters.
31 /version (001.001) def
35 /UniqueID 20000000 def
36 /FontBase (Wadalab) def
38 /CustomEncMode false def
44 /rdstring 5000 string def
45 /readdefs % <filename> readdefs -
47 { dup rdstring readline not { pop exit } if
49 { dup dup length 7 sub 7 getinterval (> CompD) eq
50 { token pop exch token pop exch pop
51 dup 0 get /highcode exch def
52 exch chars 3 1 roll put
65 % Write out the final font.
67 { 4 string highcode 16#1000 add 16 2 index cvrs 0 (.r) putinterval
68 FontBase exch concatstrings /fullname exch def
69 UniqueID 20000000 eq { /UniqueID 4990000 highcode add def } if
70 /encoding CustomEncMode
72 { StdEncMode { StandardEncoding } { ISOLatin1Encoding } ifelse }
80 % Write the clear text part.
82 /CreationDate (%Calendar%) currentdevparams
83 dup /Weekday get {(Sun )(Mon )(Tue )(Wed )(Thu )(Fri )(Sat )} exch get
84 1 index /Month get 1 sub
85 {(Jan)(Feb)(Mar)(Apr)(May)(Jun)(Jul)(Aug)(Sep)(Oct)(Nov)(Dec)} exch get
87 {{/Day ( )} {/Hour ( )} {/Minute (:)} {/Second (:)} {/Year ( )}}
88 { dup 1 get 3 -1 roll exch concatstrings exch
89 0 get 2 index exch get
90 dup 10 lt { =string cvs (0) exch concatstrings } { =string cvs } ifelse
93 forall exch pop readonly def
95 /version version readonly def
96 /Notice (No copyright on this font. Original available from moe.ipl.t.u-tokyo.ac.jp:/Font. Converted by wftopfa.ps (Aladdin Enterprises).) readonly def
97 /FullName fullname readonly def
98 /FamilyName FontBase readonly def
99 /Weight (Regular) readonly def
101 /isFixedPitch true def
102 /UnderlinePosition 0 def
103 /UnderlineThickness 0 def
107 /FontName fullname cvn def
108 /Encoding encoding def
111 /FontMatrix [.001 0 0 .001 0 -0.16] readonly def
112 /UniqueID UniqueID def
113 /FontBBox [0 0 1000 1000] readonly def
118 /-| {string currentfile exch readstring pop} readonly def
119 /|- {readonly def} readonly def
120 /| {readonly put} readonly def
121 /BlueValues [] readonly def
122 /OtherBlues [] readonly def
123 /MinFeature {16 16} readonly def
128 /UniqueID UniqueID def
129 /OtherSubrs [] readonly def
131 (\020\2771p|\020\024\020=-\223D\\\342R) readonly
132 (\020\2771py\274\366Uz) readonly
133 (\020\2771py\275\304\236i) readonly
134 (\020\2771p\371) readonly
135 (\020\2771p~\266+6\034\3446z) readonly
140 /CharStrings 256 dict def
143 dup 0 get highcode eq
144 { 1 get encoding exch get exch CharStrings 3 1 roll put }
152 Font /FontName get Font definefont setfont
153 (%stdout) (w) file writefont
156 % Scan the command line and process files.
158 /version { 2 copy get /version exch def 1 add } bind
159 /StdHW { 2 copy get cvx exec /StdHW exch def 1 add } bind
160 /StdVW { 2 copy get cvx exec /StdVW exch def 1 add } bind
161 /UniqueId { 2 copy get cvi /UniqueID exch def 1 add } bind
163 /FontBase { 2 copy get /FontBase exch def 1 add } bind
164 /StdEnc { /StdEncMode true def } bind
165 /CustomEnc { /CustomEncMode true def } bind
166 /Binary { /Binary true def } bind
167 /noEncrypt { /Encrypt false def } bind
169 /wftopfa % [(arg1) ...] wftopfa -
171 { dup 2 index length ge { exit } if
172 2 copy get exch 1 add exch
173 options 1 index .knownget { exch pop exec } { readdefs } ifelse
176 wrfont_dict /binary_CharStrings Binary put
177 wrfont_dict /eexec_encrypt Encrypt put
178 wrfont_dict /name_all_Encodings CustomEncMode put
185 { mark exch wftopfa_dict begin /saved save def { wftopfa } exec false%stopped
186 { cleartomark true } { cleartomark false } ifelse
187 saved end restore { stop } if
195 % ---------------- Root font ---------------- %
197 % Define the Encoding for the root font.
200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
201 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
202 0 1 2 3 4 5 6 7 8 0 0 0 0 0 0 0
203 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
205 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
206 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
207 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
208 73 74 75 76 77 0 0 0 0 0 0 0 0 0 0 0
213 % Define the template for the root font dictionary.
216 /FontMatrix [1 0 0 1 0 0]
218 /Encoding wfrootencoding
221 % Define a dummy (placeholder) Type 1 font for the FDepVector.
222 /type1dummyfont % <fontname> type1dummyfont <font>
223 { mark /FontName 3 -1 roll
225 /FontMatrix [.001 0 0 .001 0 0]
226 /FontBBox [0 0 1000 1000]
227 /Encoding /KanjiSubEncoding findencoding
229 /Private mark /BlueValues [] /password 5839 .dicttomark
230 .dicttomark dup /FontName get exch definefont
233 % Write a root font. Again, wrfont.ps does most of the work.
234 /makerootfont % <rootname> makerootfont <font>
235 { wfrootfontdict dup length 4 add % FontName, FDepVector, PrefEnc, FID
237 cvlit /FontName exch def
239 /len FontName length def
240 /str len 4 add string def
242 str len (.r) putinterval
243 /FDepVector [ 16#21 1 16#74
244 { dup wfrootencoding exch get 0 eq
247 { 16 str len 2 add 2 getinterval cvrs pop
248 str cvn type1dummyfont
252 for end counttomark -1 roll dup counttomark 2 roll
254 FontName currentdict end definefont
256 /writerootfont % <rootname> writerootfont -
257 { save exch makerootfont setfont (%stdout) (w) file writefont restore
260 % ---------------- Converting entire fonts ---------------- %
262 % Define the directory where the Wadalab fonts are stored.
263 /wfdir (/home/ghost/kanji/w) def
265 % Convert an entire Wadalab font.
266 /writeentirefont % <fontname> <template*> writeentirefont -
271 { wfdir (/) concatstrings exch concatstrings { copystring }
272 8192 string filenameforall
275 wfdir (/wadalab-sym/*.ps) concatstrings { copystring }
276 8192 string filenameforall
279 { /currentuserparams where
280 { pop currentuserparams /VMReclaim get -2 vmreclaim { vmreclaim } }
284 (/KanjiSubEncoding ) print /KanjiSubEncoding findencoding ==
285 (readonly def\n) print
286 { (%stderr) (w) file dup 2 index write== flushfile
287 mark exch (CustomEnc) (Binary) (noEncrypt)
288 (FontBase) fontname counttomark -1 roll ] wftopfa
291 fontname cvn writerootfont
294 } def % don't bind, so we can print the procedure
296 % Convert the Wadalab JIS 1&2 SaiMincho font.
297 % To invoke this from the command line,
298 % gs -dNODISPLAY -q wftopfa.ps -c writeSaiMincho0 flush quit >wmin0.ps
299 % To make the resulting font loadable on demand, add to the Fontmap file:
300 % /Wadalab-SaiMincho (wmin0.ps) ;
302 { (Wadalab-SaiMincho) [ (wadalab-mincho-0-8/*.ps) ] writeentirefont