2 |
- |
1 |
% Copyright (C) 1995, 1996 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
%
|
|
|
3 |
% This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
% implied.
|
|
|
5 |
%
|
|
|
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.
|
|
|
9 |
%
|
|
|
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.
|
|
|
15 |
|
|
|
16 |
% $Id: wftopfa.ps,v 1.5 2003/08/08 18:45:05 ray Exp $
|
|
|
17 |
% wftopfa.ps
|
|
|
18 |
% Convert a Wadalab base font to .PFA (or .PFB) format.
|
|
|
19 |
|
|
|
20 |
(gs_ksb_e.ps) runlibfile
|
|
|
21 |
(wrfont.ps) runlibfile
|
|
|
22 |
|
|
|
23 |
/wftopfa_dict 100 dict def
|
|
|
24 |
wftopfa_dict begin
|
|
|
25 |
|
|
|
26 |
/KanjiSubEncoding dup .findencoding def
|
|
|
27 |
|
|
|
28 |
% Initialize parameters.
|
|
|
29 |
/init % - init -
|
|
|
30 |
{ /chars 256 dict def
|
|
|
31 |
/version (001.001) def
|
|
|
32 |
/highcode 0 def
|
|
|
33 |
/StdHW [32] def
|
|
|
34 |
/StdVW [32] def
|
|
|
35 |
/UniqueID 20000000 def
|
|
|
36 |
/FontBase (Wadalab) def
|
|
|
37 |
/StdEncMode false def
|
|
|
38 |
/CustomEncMode false def
|
|
|
39 |
/Binary false def
|
|
|
40 |
/Encrypt true def
|
|
|
41 |
} bind def
|
|
|
42 |
|
|
|
43 |
% Read definitions.
|
|
|
44 |
/rdstring 5000 string def
|
|
|
45 |
/readdefs % <filename> readdefs -
|
|
|
46 |
{ (r) file
|
|
|
47 |
{ dup rdstring readline not { pop exit } if
|
|
|
48 |
dup length 15 ge
|
|
|
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
|
|
|
53 |
}
|
|
|
54 |
{ pop
|
|
|
55 |
}
|
|
|
56 |
ifelse
|
|
|
57 |
}
|
|
|
58 |
{ pop
|
|
|
59 |
}
|
|
|
60 |
ifelse
|
|
|
61 |
}
|
|
|
62 |
loop closefile
|
|
|
63 |
} bind def
|
|
|
64 |
|
|
|
65 |
% Write out the final font.
|
|
|
66 |
/writepfa
|
|
|
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
|
|
|
71 |
{ KanjiSubEncoding }
|
|
|
72 |
{ StdEncMode { StandardEncoding } { ISOLatin1Encoding } ifelse }
|
|
|
73 |
ifelse def
|
|
|
74 |
|
|
|
75 |
/Font 30 dict def
|
|
|
76 |
Font begin
|
|
|
77 |
/FontInfo 20 dict def
|
|
|
78 |
FontInfo begin
|
|
|
79 |
|
|
|
80 |
% Write the clear text part.
|
|
|
81 |
|
|
|
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
|
|
|
86 |
concatstrings
|
|
|
87 |
{{/Day ( )} {/Hour ( )} {/Minute (:)} {/Second (:)} {/Year ( )}}
|
|
|
88 |
{ dup 1 get 3 -1 roll exch concatstrings exch
|
|
|
89 |
|
|
|
90 |
dup 10 lt { =string cvs (0) exch concatstrings } { =string cvs } ifelse
|
|
|
91 |
concatstrings
|
|
|
92 |
}
|
|
|
93 |
forall exch pop readonly def
|
|
|
94 |
/VMusage 100000 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
|
|
|
100 |
/ItalicAngle 0 def
|
|
|
101 |
/isFixedPitch true def
|
|
|
102 |
/UnderlinePosition 0 def
|
|
|
103 |
/UnderlineThickness 0 def
|
|
|
104 |
|
|
|
105 |
end % FontInfo
|
|
|
106 |
|
|
|
107 |
/FontName fullname cvn def
|
|
|
108 |
/Encoding encoding def
|
|
|
109 |
/PaintType 0 def
|
|
|
110 |
/FontType 1 def
|
|
|
111 |
/FontMatrix [.001 0 0 .001 0 -0.16] readonly def
|
|
|
112 |
/UniqueID UniqueID def
|
|
|
113 |
/FontBBox [0 0 1000 1000] readonly def
|
|
|
114 |
|
|
|
115 |
/Private 20 dict def
|
|
|
116 |
Private begin
|
|
|
117 |
|
|
|
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
|
|
|
124 |
/StdHW StdHW def
|
|
|
125 |
/StdVW StdVW def
|
|
|
126 |
/ForceBold false def
|
|
|
127 |
/password 5839 def
|
|
|
128 |
/UniqueID UniqueID def
|
|
|
129 |
/OtherSubrs [] readonly def
|
|
|
130 |
/Subrs [
|
|
|
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
|
|
|
136 |
] readonly def
|
|
|
137 |
|
|
|
138 |
end % Private
|
|
|
139 |
|
|
|
140 |
/CharStrings 256 dict def
|
|
|
141 |
chars
|
|
|
142 |
{ exch =string cvs
|
|
|
143 |
dup 0 get highcode eq
|
|
|
144 |
{ 1 get encoding exch get exch CharStrings 3 1 roll put }
|
|
|
145 |
{ pop pop }
|
|
|
146 |
ifelse
|
|
|
147 |
}
|
|
|
148 |
forall
|
|
|
149 |
|
|
|
150 |
end % Font
|
|
|
151 |
|
|
|
152 |
Font /FontName get Font definefont setfont
|
|
|
153 |
(%stdout) (w) file writefont
|
|
|
154 |
} bind def
|
|
|
155 |
|
|
|
156 |
% Scan the command line and process files.
|
|
|
157 |
/options mark
|
|
|
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
|
|
|
162 |
/UniqueID 1 index
|
|
|
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
|
|
|
168 |
.dicttomark def
|
|
|
169 |
/wftopfa % [(arg1) ...] wftopfa -
|
|
|
170 |
{ init dup 0
|
|
|
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
|
|
|
174 |
}
|
|
|
175 |
loop pop pop
|
|
|
176 |
wrfont_dict /binary_CharStrings Binary put
|
|
|
177 |
wrfont_dict /eexec_encrypt Encrypt put
|
|
|
178 |
wrfont_dict /name_all_Encodings CustomEncMode put
|
|
|
179 |
writepfa
|
|
|
180 |
} bind def
|
|
|
181 |
|
|
|
182 |
end % wftopfa_dict
|
|
|
183 |
|
|
|
184 |
/wftopfa
|
|
|
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
|
|
|
188 |
} bind def
|
|
|
189 |
|
|
|
190 |
[ shellarguments
|
|
|
191 |
{ ] wftopfa }
|
|
|
192 |
{ pop }
|
|
|
193 |
ifelse
|
|
|
194 |
|
|
|
195 |
% ---------------- Root font ---------------- %
|
|
|
196 |
|
|
|
197 |
% Define the Encoding for the root font.
|
|
|
198 |
/wfrootencoding
|
|
|
199 |
% \x00-\x3F
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
|
|
204 |
% \x40-\x7F
|
|
|
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
|
|
|
209 |
% \x80-\xFF
|
|
|
210 |
128 copy
|
|
|
211 |
256 packedarray def
|
|
|
212 |
|
|
|
213 |
% Define the template for the root font dictionary.
|
|
|
214 |
/wfrootfontdict mark
|
|
|
215 |
/FontType 0
|
|
|
216 |
/FontMatrix [1 0 0 1 0 0]
|
|
|
217 |
/FMapType 2
|
|
|
218 |
/Encoding wfrootencoding
|
|
|
219 |
.dicttomark def
|
|
|
220 |
|
|
|
221 |
% Define a dummy (placeholder) Type 1 font for the FDepVector.
|
|
|
222 |
/type1dummyfont % <fontname> type1dummyfont <font>
|
|
|
223 |
{ mark /FontName 3 -1 roll
|
|
|
224 |
/FontType 1
|
|
|
225 |
/FontMatrix [.001 0 0 .001 0 0]
|
|
|
226 |
/FontBBox [0 0 1000 1000]
|
|
|
227 |
/Encoding /KanjiSubEncoding findencoding
|
|
|
228 |
/CharStrings 0 dict
|
|
|
229 |
/Private mark /BlueValues [] /password 5839 .dicttomark
|
|
|
230 |
.dicttomark dup /FontName get exch definefont
|
|
|
231 |
} bind def
|
|
|
232 |
|
|
|
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
|
|
|
236 |
dict copy begin
|
|
|
237 |
cvlit /FontName exch def
|
|
|
238 |
4 dict begin
|
|
|
239 |
/len FontName length def
|
|
|
240 |
/str len 4 add string def
|
|
|
241 |
FontName str cvs pop
|
|
|
242 |
str len (.r) putinterval
|
|
|
243 |
/FDepVector [ 16#21 1 16#74
|
|
|
244 |
{ dup wfrootencoding exch get 0 eq
|
|
|
245 |
{ pop
|
|
|
246 |
}
|
|
|
247 |
{ 16 str len 2 add 2 getinterval cvrs pop
|
|
|
248 |
str cvn type1dummyfont
|
|
|
249 |
}
|
|
|
250 |
ifelse
|
|
|
251 |
}
|
|
|
252 |
for end counttomark -1 roll dup counttomark 2 roll
|
|
|
253 |
] def
|
|
|
254 |
FontName currentdict end definefont
|
|
|
255 |
} bind def
|
|
|
256 |
/writerootfont % <rootname> writerootfont -
|
|
|
257 |
{ save exch makerootfont setfont (%stdout) (w) file writefont restore
|
|
|
258 |
} bind def
|
|
|
259 |
|
|
|
260 |
% ---------------- Converting entire fonts ---------------- %
|
|
|
261 |
|
|
|
262 |
% Define the directory where the Wadalab fonts are stored.
|
|
|
263 |
/wfdir (/home/ghost/kanji/w) def
|
|
|
264 |
|
|
|
265 |
% Convert an entire Wadalab font.
|
|
|
266 |
/writeentirefont % <fontname> <template*> writeentirefont -
|
|
|
267 |
{ 2 dict begin
|
|
|
268 |
/templates exch def
|
|
|
269 |
/fontname exch def
|
|
|
270 |
[ templates
|
|
|
271 |
{ wfdir (/) concatstrings exch concatstrings { copystring }
|
|
|
272 |
8192 string filenameforall
|
|
|
273 |
}
|
|
|
274 |
forall
|
|
|
275 |
wfdir (/wadalab-sym/*.ps) concatstrings { copystring }
|
|
|
276 |
8192 string filenameforall
|
|
|
277 |
]
|
|
|
278 |
(%!\n) print
|
|
|
279 |
{ /currentuserparams where
|
|
|
280 |
{ pop currentuserparams /VMReclaim get -2 vmreclaim { vmreclaim } }
|
|
|
281 |
{ { } }
|
|
|
282 |
ifelse
|
|
|
283 |
} == (exec\n) print
|
|
|
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
|
|
|
289 |
}
|
|
|
290 |
forall
|
|
|
291 |
fontname cvn writerootfont
|
|
|
292 |
(exec\n) print
|
|
|
293 |
end
|
|
|
294 |
} def % don't bind, so we can print the procedure
|
|
|
295 |
|
|
|
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) ;
|
|
|
301 |
/writeSaiMincho0
|
|
|
302 |
{ (Wadalab-SaiMincho) [ (wadalab-mincho-0-8/*.ps) ] writeentirefont
|
|
|
303 |
} bind def
|