home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Impressora_PDF / converter.exe / GPLGS / wftopfa.ps < prev    next >
Text File  |  2003-12-13  |  9KB  |  304 lines

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