home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / fontutils-0.6-base.tgz / fontutils-0.6-base.tar / fsf / fontutils / bzrto / bzrsetup.mf < prev    next >
Text File  |  1992-10-19  |  7KB  |  209 lines

  1. % bzrsetup.mf: interesting and/or necessary things for bzrto's Metafont output.
  2. % Copyright (C) 1992 Free Software Foundation, Inc.
  3. %
  4. % This program is free software; you can redistribute it and/or modify
  5. % it under the terms of the GNU General Public License as published by
  6. % the Free Software Foundation; either version 2, or (at your option)
  7. % any later version.
  8. %
  9. % This program is distributed in the hope that it will be useful,
  10. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. % GNU General Public License for more details.
  13. %
  14. % You should have received a copy of the GNU General Public License
  15. % along with this program; if not, write to the Free Software
  16. % Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19. % |true_design_size| must be set before this file is input.  It is
  20. % supposed to be the design size of the original font.  If the user does
  21. % not set |designsize| on the command line, we default to the following.
  22. default_design_size# := 10pt#;
  23. if designsize = 0: designsize := default_design_size#; fi;
  24.  
  25. % It's pointless to actually produce different TFM files for different
  26. % design sizes: we have only one set of outlines, after all.  So we
  27. % adjust the resolution to account for different sizes, by setting
  28. % |mag|.  Then we reset |designsize| to the default.
  29. if unknown mag: mag := 1; fi;
  30. mag := mag * designsize / default_design_size#;
  31.  
  32. % So we can produce output at varying sizes, all our dimensions are
  33. % output in terms of the ad hoc parameter |u|.
  34. u# := default_design_size# / true_design_size#;
  35.  
  36. designsize := default_design_size#;
  37.  
  38. % Macros from page 289 of {\sl The Metafontbook} for short-circuit evaluation.
  39. def cand (text q) = startif true q else: false fi enddef;
  40. def cor (text q) = startif true true else: q fi enddef;
  41. tertiarydef p startif true = if p: enddef;
  42.  
  43. % The proof resolution of 2601.72 pixels per inch established by plain
  44. % \MF\ does not always work, because the characters might be too large
  45. % (or small, for that matter) for the paper size.  So, here we change
  46. % the proof resolution to fit the design size of the font into
  47. % |proof_size| inches.  To do this, we must know the resolution of the
  48. % device the proof output will be printed on; we make |proof_resolution|
  49. % default to 300.
  50. if unknown mode cor ((mode = proof) or (mode = smoke)):
  51.   % Given in inches:
  52.   if unknown proof_size: proof_size := 7; fi;
  53.   
  54.   % Given in pixels per inch:
  55.   if unknown proof_resolution: proof_resolution := 300; fi;
  56.   
  57.   % Set up the new mode to be the same as the old one, except for the
  58.   % resolution.
  59.   original_mode := if known mode: mode else: proof fi;
  60.   mode_def bzr_proof_mode =
  61.     if original_mode = proof:
  62.       proof_;
  63.     else:
  64.       smoke_;
  65.     fi;
  66.     pixels_per_inch
  67.       := (proof_size * proof_resolution)
  68.          * (72.27 / proof_resolution)
  69.          * (72.27 / designsize);
  70.   enddef;
  71.   mode := bzr_proof_mode;
  72. fi;
  73.  
  74. % Set up the device values for this run.  Since we allow a nonstandard
  75. % value of |proofing| (see below), we must save its value, if it has
  76. % already been assigned.
  77. %
  78. if (known proofing) cand (proofing > 2):
  79.   save_proofing := proofing;
  80. fi
  81.  
  82. mode_setup;
  83.  
  84. if known save_proofing:
  85.   proofing := save_proofing;
  86. fi;
  87.  
  88.  
  89. % We can't define the pixel-oriented version of |u| until after
  90. % |mode_setup| has been called.
  91. define_pixels (u);
  92.  
  93.  
  94. % Use a font that blends better with the \MF\ logo for the title line.
  95. special "titlefont cmss8";
  96.  
  97. % If we are doing smoke proofs, put the character at its actual size on
  98. % the output; if we're doing gray proofs, use a smaller font for the
  99. % labels.
  100. if proofing <= 1:
  101.   special "labelfont " & jobname;
  102.   extra_beginchar := extra_beginchar &
  103.     "makelabel.lft.nodot (decimal charcode, (w + 1in#, 0));";
  104. else:
  105.   special "labelfont cmtt8";
  106. fi;
  107.  
  108. % Produce a |makelabel| command for each |z| point in |point_list| and
  109. % each suffix in |suffixes|.
  110. def general_label (text point_list, suffixes) =
  111.   forsuffixes point_suffix = ,suffixes:
  112.     forsuffixes point = point_list:
  113.       % Unfortunately, the way in which the |str| operator formats its
  114.       % argument (which is an arbitrary suffix) cannot be changed, so
  115.       % the proofsheets end up showing "0 0" for the variable |z[0][0]|.
  116.       makelabel (str point.point_suffix, z.point.point_suffix);
  117.     endfor
  118.   endfor
  119. enddef;
  120.  
  121. % Define our labels for the proofsheets.  The person running Metafont
  122. % can also see the control points on each spline, by setting
  123. % |proofing>2| at the beginning.  (The {\tt plain.mf} macros only
  124. % distinguish between |proofing=0|, |proofing>0| and |proofing>1|, so we
  125. % are not disturbing them.)
  126. def proof_labels (text t) =
  127.   % We need to delimit the arguments here, so \MF\ knows where the
  128.   % second |text| argument begins.  Our output uses the suffix |"s"| for
  129.   % startpoints of segments, and the suffixes |"c1"| and |"c2"| for
  130.   % control points.
  131.   if proofing > 1: general_label (t) (s); fi;
  132.   if proofing > 2: general_label (t) (c1,c2); fi;
  133. enddef;
  134.  
  135.  
  136. % We define our characters as filled outlines; page 206 of {\sl The
  137. % Metafontbook} suggests disabling \MF's |autorounding| and
  138. % |smoothing| features in that case.
  139. autorounding := 0;
  140. smoothing := 0;
  141.  
  142. % Sometimes we want to fill our paths, other times unfill them,
  143. % depending on whether the winding number is positive or negative.  We
  144. % could be absolutely safe here, and declare |temp_path| inside a group,
  145. % at every invocation of |fill_or_unfill|; but this would waste time and
  146. % space to no advantage, since we know exactly what kind of \MF\
  147. % programs we output, and the variable |temp_path| is not used in them.
  148. % Incidentally, we need a variable in the first place only because it is more
  149. % efficient to avoid evaluating long paths more than once.
  150. path temp_path;
  151.  
  152. def fill_or_unfill expr p =
  153.   temp_path := p;
  154.   if turningnumber temp_path > 0: fill else: unfill fi temp_path;
  155. enddef;
  156.  
  157. % Since we can assume the font fills all cycles counterclockwise
  158. % (because PostScript requires this), we want to disable the
  159. % |turningnumber| checking which generates the `Strange path' errors.
  160. % See p.112 and p.119 of the Metafontbook.
  161. % (By the way, setting |turningcheck := 0| makes Metafont always use the
  162. % filling rule for positive turning number, i.e., always |fill| and
  163. % never |unfill|.  When would this be useful?)
  164. turningcheck := 1;
  165.  
  166. % When we don't know the dimensions of the character we're defining
  167. % before we define it, we have to use these to begin it:
  168. def begin_no_dimen_char (expr c) =
  169.   begingroup
  170.   transform save_currenttransform;
  171.   save_currenttransform := currenttransform;
  172.   charcode:=if known c: byte c else: 0 fi;
  173.   charic:=0; clearxy; clearit; clearpen; scantokens extra_beginchar;
  174. enddef;
  175.  
  176. def end_no_dimen_char =
  177.   currenttransform := save_currenttransform;
  178.   endchar;
  179. enddef;
  180.  
  181. % When use the above to start a character, must call this before `endchar'.
  182. def set_char_dimens (expr w_sharp,h_sharp,d_sharp) =
  183.  charwd:=w_sharp;      charht:=h_sharp;       chardp:=d_sharp;
  184.  w:=hround(charwd*hppp); h:=vround(charht*hppp); d:=vround(chardp*hppp);
  185. enddef;
  186.  
  187. % Move by shifting the current transform matrix.
  188. def move (expr h_amount, v_amount) =
  189.   currenttransform := currenttransform shifted (h_amount, v_amount);
  190. enddef;
  191.  
  192. def hmove (expr amount) = move (amount, 0); enddef;
  193. def vmove (expr amount) = move (0, amount); enddef;
  194.