home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / tex / texsrc2 / Src / fontutil / vftovp / ch next >
Text File  |  1993-02-21  |  22KB  |  715 lines

  1. % vftovp.ch for C compilation with web2c.
  2.  
  3.  
  4. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5. % [0] WEAVE: print changes only.
  6. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  7. @x
  8. \pageno=\contentspagenumber \advance\pageno by 1
  9. @y
  10. \pageno=\contentspagenumber \advance\pageno by 1
  11. \let\maybe=\iffalse
  12. \def\title{VF$\,$\lowercase{to}$\,$VP changes for C}
  13. @z
  14.  
  15. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  16. % [1] Change banner string
  17. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  18. @x
  19. @d banner=='This is VFtoVP, Version 1.2' {printed when the program starts}
  20. @y
  21. @d banner=='This is VFtoVP, Version 1.2' {more is printed later}
  22. @z
  23.  
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25. % [2] Remove files in program statement.
  26. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27. @x
  28. @p program VFtoVP(@!vf_file,@!tfm_file,@!vpl_file,@!output);
  29. @y
  30. @p program VFtoVP;
  31. @z
  32.  
  33. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  34. % still [2] Set up for path reading.
  35. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  36. @x
  37.   begin print_ln(banner);@/
  38. @y
  39.   @<Local variables for initialization@>
  40.   begin
  41.     if (argc < 3) or (argc > n_options + arg_options + 4)
  42.     then begin
  43.       print ('Usage: vftovp ');
  44.       print ('[-verbose] ');
  45.       print_ln ('[-charcode-format=<format>] ');
  46.       print_ln ('  <vfm file> <tfm file> [<vpl file>].');
  47. @.Usage: ...@>
  48.       uexit (1);
  49.     end;
  50.  
  51.     @<Initialize the option variables@>;
  52.     @<Parse arguments@>;
  53. @z
  54.  
  55. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  56. % [4] Set name_length to the system constant
  57. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  58. @x
  59. @<Constants...@>=
  60. @y
  61. @d name_length==PATH_MAX
  62. @<Constants...@>=
  63. @z
  64. @x
  65. @!name_length=50; {a file name shouldn't be longer than this}
  66. @y
  67. @z
  68.  
  69. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  70. % [7] Declare vf_name.
  71. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  72. @x
  73. @!vf_file:packed file of byte;
  74. @y
  75. @!vf_file:packed file of byte; {files that contain binary data}
  76. @!vf_name:packed array[1..PATH_MAX] of char;
  77. @z
  78.  
  79. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  80. % [10] Declare tfm_name.
  81. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  82. @x
  83. @!tfm_file:packed file of byte;
  84. @y
  85. @!tfm_file:packed file of byte;
  86. @!tfm_name:packed array[1..PATH_MAX] of char;
  87. @z
  88.  
  89. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  90. % [11] Open the files.
  91. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  92. @x
  93. @ On some systems you may have to do something special to read a
  94. packed file of bytes. For example, the following code didn't work
  95. when it was first tried at Stanford, because packed files have to be
  96. opened with a special switch setting on the \PASCAL\ that was used.
  97. @^system dependencies@>
  98.  
  99. @<Set init...@>=
  100. reset(tfm_file); reset(vf_file);
  101. @y
  102. @ We don't have to do anything special to read a packed file of bytes,
  103. but we do want to use environment variables to find the input files.
  104. @^system dependencies@>
  105.  
  106. @<Set init...@>=
  107. {Use path searching to find the input files.}
  108. set_paths (TFM_FILE_PATH_BIT + VF_FILE_PATH_BIT);
  109.  
  110. argv (optind, vf_name);
  111. if test_read_access (vf_name, VF_FILE_PATH)
  112. then reset (vf_file, vf_name)
  113. else begin
  114.   print_pascal_string (vf_name);
  115.   print_ln (': VF file not found.');
  116.   uexit (1);
  117. end;
  118.  
  119. argv (optind + 1, tfm_name);
  120. if test_read_access (tfm_name, TFM_FILE_PATH)
  121. then reset (tfm_file, tfm_name)
  122. else begin
  123.   print_pascal_string (tfm_name);
  124.   print_ln (': TFM file not found.');
  125.   uexit (1);
  126. end;
  127. if verbose then begin
  128.   print (banner);
  129.   print_ln (version_string);
  130. end;
  131. @z
  132.  
  133. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  134. % [20] Declare vpl_name.
  135. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  136. @x
  137. @!vpl_file:text;
  138. @y
  139. @!vpl_file:text;
  140. @!vpl_name:packed array[1..PATH_MAX] of char;
  141. @z
  142.  
  143. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  144. % [21] Open VPL file.
  145. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  146. @x
  147. @ @<Set init...@>=
  148. rewrite(vpl_file);
  149. @y
  150. @ @<Set init...@>=
  151. if optind + 2 = argc
  152. then vpl_file := stdout
  153. else begin
  154.   argv (optind + 2, vpl_name);
  155.   rewrite (vpl_file, vpl_name);
  156. end;
  157. @z
  158.  
  159. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  160. % [24] `index' is not a good choice for an identifier.
  161. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  162. @x
  163. @<Types...@>=
  164. @!index=0..tfm_size; {address of a byte in |tfm|}
  165. @y
  166. @d index == index_type
  167.  
  168. @<Types...@>=
  169. @!index=0..tfm_size; {address of a byte in |tfm|}
  170. @z
  171.  
  172. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  173. % [24] abort() should cause a bad exit code.
  174. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  175. @x
  176. @d abort(#)==begin print_ln(#);
  177.   print_ln('Sorry, but I can''t go on; are you sure this is a TFM?');
  178.   goto final_end;
  179.   end
  180. @y
  181. @d abort(#)==begin print_ln(#);
  182.   print_ln('Sorry, but I can''t go on; are you sure this is a TFM?');
  183.   uexit(1);
  184.   end
  185. @z
  186.  
  187. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  188. % [31] Ditto for vf_abort.
  189. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  190. @x
  191. @d vf_abort(#)==
  192.   begin print_ln(#);
  193.   print_ln('Sorry, but I can''t go on; are you sure this is a VF?');
  194.   goto final_end;
  195.   end
  196. @y
  197. @d vf_abort(#)==
  198.   begin print_ln(#);
  199.   print_ln('Sorry, but I can''t go on; are you sure this is a VF?');
  200.   uexit(1);
  201.   end
  202. @z
  203.  
  204. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  205. % [32] Be quiet if not -verbose.
  206. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  207. @x
  208. for k:=0 to vf_ptr-1 do print(xchr[vf[k]]);
  209. print_ln(' '); count:=0;
  210. @y
  211. if verbose
  212. then begin
  213.   for k:=0 to vf_ptr-1 do print(xchr[vf[k]]);
  214.   print_ln(' ');
  215. end;
  216. count:=0;
  217. @z
  218.  
  219. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  220. % [35] Be quiet if not -verbose.
  221. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  222. @x
  223. @<Print the name of the local font@>;
  224. @y
  225. if verbose then begin
  226.   @<Print the name of the local font@>;
  227. end;
  228. @z
  229.  
  230. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  231. % [36] Output of real numbers.
  232. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  233. @x
  234. print_ln(' at ',(((vf[k]*256+vf[k+1])*256+vf[k+2])/@'4000000)*real_dsize:2:2,
  235.   'pt')
  236. @y
  237. print(' at ');
  238. print_real((((vf[k]*256+vf[k+1])*256+vf[k+2])/@'4000000)*real_dsize, 2, 2);
  239. print_ln('pt')
  240. @z
  241.  
  242. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  243. % [39] Open another TFM file.
  244. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  245. @x
  246. reset(tfm_file,cur_name);
  247. @^system dependencies@>
  248. if eof(tfm_file) then
  249.   print_ln('---not loaded, TFM file can''t be opened!')
  250. @.TFM file can\'t be opened@>
  251. else  begin font_bc:=0; font_ec:=256; {will cause error if not modified soon}
  252. @y
  253. if not test_read_access(cur_name, TFM_FILE_PATH) then
  254.   print_ln('---not loaded, TFM file can''t be opened!')
  255. @.TFM file can\'t be opened@>
  256. else begin reset(tfm_file, cur_name);
  257.   font_bc:=0; font_ec:=256; {will cause error if not modified soon}
  258. @z
  259.  
  260. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  261. % [40] Be quiet if not -verbose.
  262. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  263. @x
  264.     begin print_ln('Check sum in VF file being replaced by TFM check sum');
  265. @y
  266.     begin
  267.       if verbose
  268.       then print_ln('Check sum in VF file being replaced by TFM check sum');
  269. @z
  270.  
  271. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  272. % [42] Remove initialization of now-defunct array.
  273. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  274. @x
  275. @ @<Set init...@>=
  276. default_directory:=default_directory_name;
  277. @y
  278. @ (No initialization to be done.  Keep this module to preserve numbering.)
  279. @z
  280.  
  281. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  282. % [44] Use lowercase `.tfm'