wftopfa.ps 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. % Copyright (C) 1995, 1996 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This file is part of AFPL Ghostscript.
  4. %
  5. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  6. % distributor accepts any responsibility for the consequences of using it, or
  7. % for whether it serves any particular purpose or works at all, unless he or
  8. % she says so in writing. Refer to the Aladdin Free Public License (the
  9. % "License") for full details.
  10. %
  11. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  12. % in a plain ASCII text file named PUBLIC. The License grants you the right
  13. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14. % conditions described in the License. Among other things, the License
  15. % requires that the copyright notice and this notice be preserved on all
  16. % copies.
  17. % $Id: wftopfa.ps,v 1.2 2000/09/19 18:29:11 lpd Exp $
  18. % wftopfa.ps
  19. % Convert a Wadalab base font to .PFA (or .PFB) format.
  20. (gs_ksb_e.ps) runlibfile
  21. (wrfont.ps) runlibfile
  22. /wftopfa_dict 100 dict def
  23. wftopfa_dict begin
  24. /KanjiSubEncoding dup .findencoding def
  25. % Initialize parameters.
  26. /init % - init -
  27. { /chars 256 dict def
  28. /version (001.001) def
  29. /highcode 0 def
  30. /StdHW [32] def
  31. /StdVW [32] def
  32. /UniqueID 20000000 def
  33. /FontBase (Wadalab) def
  34. /StdEncMode false def
  35. /CustomEncMode false def
  36. /Binary false def
  37. /Encrypt true def
  38. } bind def
  39. % Read definitions.
  40. /rdstring 5000 string def
  41. /readdefs % <filename> readdefs -
  42. { (r) file
  43. { dup rdstring readline not { pop exit } if
  44. dup length 15 ge
  45. { dup dup length 7 sub 7 getinterval (> CompD) eq
  46. { token pop exch token pop exch pop
  47. dup 0 get /highcode exch def
  48. exch chars 3 1 roll put
  49. }
  50. { pop
  51. }
  52. ifelse
  53. }
  54. { pop
  55. }
  56. ifelse
  57. }
  58. loop closefile
  59. } bind def
  60. % Write out the final font.
  61. /writepfa
  62. { 4 string highcode 16#1000 add 16 2 index cvrs 0 (.r) putinterval
  63. FontBase exch concatstrings /fullname exch def
  64. UniqueID 20000000 eq { /UniqueID 4990000 highcode add def } if
  65. /encoding CustomEncMode
  66. { KanjiSubEncoding }
  67. { StdEncMode { StandardEncoding } { ISOLatin1Encoding } ifelse }
  68. ifelse def
  69. /Font 30 dict def
  70. Font begin
  71. /FontInfo 20 dict def
  72. FontInfo begin
  73. % Write the clear text part.
  74. /CreationDate (%Calendar%) currentdevparams
  75. dup /Weekday get {(Sun )(Mon )(Tue )(Wed )(Thu )(Fri )(Sat )} exch get
  76. 1 index /Month get 1 sub
  77. {(Jan)(Feb)(Mar)(Apr)(May)(Jun)(Jul)(Aug)(Sep)(Oct)(Nov)(Dec)} exch get
  78. concatstrings
  79. {{/Day ( )} {/Hour ( )} {/Minute (:)} {/Second (:)} {/Year ( )}}
  80. { dup 1 get 3 -1 roll exch concatstrings exch
  81. 0 get 2 index exch get
  82. dup 10 lt { =string cvs (0) exch concatstrings } { =string cvs } ifelse
  83. concatstrings
  84. }
  85. forall exch pop readonly def
  86. /VMusage 100000 def
  87. /version version readonly def
  88. /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
  89. /FullName fullname readonly def
  90. /FamilyName FontBase readonly def
  91. /Weight (Regular) readonly def
  92. /ItalicAngle 0 def
  93. /isFixedPitch true def
  94. /UnderlinePosition 0 def
  95. /UnderlineThickness 0 def
  96. end % FontInfo
  97. /FontName fullname cvn def
  98. /Encoding encoding def
  99. /PaintType 0 def
  100. /FontType 1 def
  101. /FontMatrix [.001 0 0 .001 0 -0.16] readonly def
  102. /UniqueID UniqueID def
  103. /FontBBox [0 0 1000 1000] readonly def
  104. /Private 20 dict def
  105. Private begin
  106. /-| {string currentfile exch readstring pop} readonly def
  107. /|- {readonly def} readonly def
  108. /| {readonly put} readonly def
  109. /BlueValues [] readonly def
  110. /OtherBlues [] readonly def
  111. /MinFeature {16 16} readonly def
  112. /StdHW StdHW def
  113. /StdVW StdVW def
  114. /ForceBold false def
  115. /password 5839 def
  116. /UniqueID UniqueID def
  117. /OtherSubrs [] readonly def
  118. /Subrs [
  119. (\020\2771p|\020\024\020=-\223D\\\342R) readonly
  120. (\020\2771py\274\366Uz) readonly
  121. (\020\2771py\275\304\236i) readonly
  122. (\020\2771p\371) readonly
  123. (\020\2771p~\266+6\034\3446z) readonly
  124. ] readonly def
  125. end % Private
  126. /CharStrings 256 dict def
  127. chars
  128. { exch =string cvs
  129. dup 0 get highcode eq
  130. { 1 get encoding exch get exch CharStrings 3 1 roll put }
  131. { pop pop }
  132. ifelse
  133. }
  134. forall
  135. end % Font
  136. Font /FontName get Font definefont setfont
  137. (%stdout) (w) file writefont
  138. } bind def
  139. % Scan the command line and process files.
  140. /options mark
  141. /version { 2 copy get /version exch def 1 add } bind
  142. /StdHW { 2 copy get cvx exec /StdHW exch def 1 add } bind
  143. /StdVW { 2 copy get cvx exec /StdVW exch def 1 add } bind
  144. /UniqueId { 2 copy get cvi /UniqueID exch def 1 add } bind
  145. /UniqueID 1 index
  146. /FontBase { 2 copy get /FontBase exch def 1 add } bind
  147. /StdEnc { /StdEncMode true def } bind
  148. /CustomEnc { /CustomEncMode true def } bind
  149. /Binary { /Binary true def } bind
  150. /noEncrypt { /Encrypt false def } bind
  151. .dicttomark def
  152. /wftopfa % [(arg1) ...] wftopfa -
  153. { init dup 0
  154. { dup 2 index length ge { exit } if
  155. 2 copy get exch 1 add exch
  156. options 1 index .knownget { exch pop exec } { readdefs } ifelse
  157. }
  158. loop pop pop
  159. wrfont_dict /binary_CharStrings Binary put
  160. wrfont_dict /eexec_encrypt Encrypt put
  161. wrfont_dict /name_all_Encodings CustomEncMode put
  162. writepfa
  163. } bind def
  164. end % wftopfa_dict
  165. /wftopfa
  166. { mark exch wftopfa_dict begin /saved save def { wftopfa } exec false%stopped
  167. { cleartomark true } { cleartomark false } ifelse
  168. saved end restore { stop } if
  169. } bind def
  170. [ shellarguments
  171. { ] wftopfa }
  172. { pop }
  173. ifelse
  174. % ---------------- Root font ---------------- %
  175. % Define the Encoding for the root font.
  176. /wfrootencoding
  177. % \x00-\x3F
  178. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  179. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  180. 0 1 2 3 4 5 6 7 8 0 0 0 0 0 0 0
  181. 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  182. % \x40-\x7F
  183. 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
  184. 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
  185. 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
  186. 73 74 75 76 77 0 0 0 0 0 0 0 0 0 0 0
  187. % \x80-\xFF
  188. 128 copy
  189. 256 packedarray def
  190. % Define the template for the root font dictionary.
  191. /wfrootfontdict mark
  192. /FontType 0
  193. /FontMatrix [1 0 0 1 0 0]
  194. /FMapType 2
  195. /Encoding wfrootencoding
  196. .dicttomark def
  197. % Define a dummy (placeholder) Type 1 font for the FDepVector.
  198. /type1dummyfont % <fontname> type1dummyfont <font>
  199. { mark /FontName 3 -1 roll
  200. /FontType 1
  201. /FontMatrix [.001 0 0 .001 0 0]
  202. /FontBBox [0 0 1000 1000]
  203. /Encoding /KanjiSubEncoding findencoding
  204. /CharStrings 0 dict
  205. /Private mark /BlueValues [] /password 5839 .dicttomark
  206. .dicttomark dup /FontName get exch definefont
  207. } bind def
  208. % Write a root font. Again, wrfont.ps does most of the work.
  209. /makerootfont % <rootname> makerootfont <font>
  210. { wfrootfontdict dup length 4 add % FontName, FDepVector, PrefEnc, FID
  211. dict copy begin
  212. cvlit /FontName exch def
  213. 4 dict begin
  214. /len FontName length def
  215. /str len 4 add string def
  216. FontName str cvs pop
  217. str len (.r) putinterval
  218. /FDepVector [ 16#21 1 16#74
  219. { dup wfrootencoding exch get 0 eq
  220. { pop
  221. }
  222. { 16 str len 2 add 2 getinterval cvrs pop
  223. str cvn type1dummyfont
  224. }
  225. ifelse
  226. }
  227. for end counttomark -1 roll dup counttomark 2 roll
  228. ] def
  229. FontName currentdict end definefont
  230. } bind def
  231. /writerootfont % <rootname> writerootfont -
  232. { save exch makerootfont setfont (%stdout) (w) file writefont restore
  233. } bind def
  234. % ---------------- Converting entire fonts ---------------- %
  235. % Define the directory where the Wadalab fonts are stored.
  236. /wfdir (/home/ghost/kanji/w) def
  237. % Convert an entire Wadalab font.
  238. /writeentirefont % <fontname> <template*> writeentirefont -
  239. { 2 dict begin
  240. /templates exch def
  241. /fontname exch def
  242. [ templates
  243. { wfdir (/) concatstrings exch concatstrings { copystring }
  244. 100 string filenameforall
  245. }
  246. forall
  247. wfdir (/wadalab-sym/*.ps) concatstrings { copystring }
  248. 100 string filenameforall
  249. ]
  250. (%!\n) print
  251. { /currentuserparams where
  252. { pop currentuserparams /VMReclaim get -2 vmreclaim { vmreclaim } }
  253. { { } }
  254. ifelse
  255. } == (exec\n) print
  256. (/KanjiSubEncoding ) print /KanjiSubEncoding findencoding ==
  257. (readonly def\n) print
  258. { (%stderr) (w) file dup 2 index write== flushfile
  259. mark exch (CustomEnc) (Binary) (noEncrypt)
  260. (FontBase) fontname counttomark -1 roll ] wftopfa
  261. }
  262. forall
  263. fontname cvn writerootfont
  264. (exec\n) print
  265. end
  266. } def % don't bind, so we can print the procedure
  267. % Convert the Wadalab JIS 1&2 SaiMincho font.
  268. % To invoke this from the command line,
  269. % gs -dNODISPLAY -q wftopfa.ps -c writeSaiMincho0 flush quit >wmin0.ps
  270. % To make the resulting font loadable on demand, add to the Fontmap file:
  271. % /Wadalab-SaiMincho (wmin0.ps) ;
  272. /writeSaiMincho0
  273. { (Wadalab-SaiMincho) [ (wadalab-mincho-0-8/*.ps) ] writeentirefont
  274. } bind def