% Compiled 1991 by Karl Berry from modes collected by Doug Henderson,
% Pierre MacKay, and others.  This file is in the public domain.
% 
% Please change the definitions of |localfont|, |screen_cols|, and
% |screen_rows| at the end of file (see explanations below).
% 
% When you make a new |mode_def|, please send it to {\tt
% karl@cs.umb.edu} or {\tt dlatex@cmsa.berkeley.edu}.  Please mention
% what fonts at what sizes you tested it on.  This will help other
% people wondering where particular values came from.  Ideally, you
% would try normal, bold, and italic variants, at sizes around 5$\,$pt,
% 10$\,$pt and 15$\,$pt.
% 
% You can run this file through {\tt mft} to generate a \TeX\
% file, if you like reading typeset output instead of computer screens.
% 
%%% def mode_def
%%% addto font_size coding_scheme font_face_byte landscape landscape_
% 
% @mffile{
%   author = "Pierre MacKay, Doug Henderson, et al."
%   version = "0.8",
%   date = "Wed Oct 30 07:24:30 EST 1991"
%   filename = "modes.mf",
%   contact = "Karl Berry",
%   email = "karl@cs.umb.edu"
%   address = "135 Center Hill Rd. // Plymouth, MA 02360"
%   checksum = "1183    5713   41941",
%   codetable = "ISO/ASCII",
%   supported = "yes",
%   docstring = "
% 
% This file collects all known \MF\ modes, some of which have not been
% tested.  It also makes definitions to put specials identifying the
% mode in the \MF\ GF output, and to put the coding scheme and other
% so-called Xerox-world information in the TFM output.  Finally, it
% defines some code to handle write-white devices better; this code
% comes into play if a |mode_def| includes the statement
% |mode_write_white_setup_;|.  This only works for those fonts which
% follow Computer Modern's conventions for using |font_setup|.
% 
% This file follows a naming convention that has emerged in the
% discussion of |mode_def|s in {\sl TUGboat}.
% 
% \item{1)} The print engine is identified wherever possible,
%   rather than the printer which incorporates that engine.
% 
% \item{2)} Because |mode_def| names may not contain digits,
%   each digit is spelled out; e.g., {\tt RicohFourZeroEightZero}.
% 
% \item{3)} For historical reasons, some modes have synonyms of all
%   lowercase letters, e.g., `cx' for `CanonCX'.  These abbreviations
%   mostly come from {\tt waits.mf}, a predecessor to this file.
%
% This file is typically loaded when making a \MF\ base; for example,
% the command line {\tt inimf plain input modes} makes a file {\tt
% plain.base} (or {\tt plain.bas}, or something like that) with all the
% modes herein defined (plain itself defines modes called |proof|,
% |smoke|, and |lowres|.)
% 
% A user selects a particular mode when s/he runs \MF, by assigning to
% the variable |mode|.  For example, typing
% {\tt \char`\\mode:=CanonCX; input cmr10}
% sets up values appropriate for the CanonCX engine.
% 
% If no mode is assigned, the default is |proof| mode, as stated in {\sl
% The \MF book}.  This is the cause of the ``{\tt .2602gf}'' files which
% are a periodic question in the \TeX\ community.  The remedy is simply
% to assign a different mode---|localfont|, for example.
% 
% Every site should define the mode |localfont| to be a synonym for the
% mode most commonly used there.  This file defines |localfont| to be
% |CanonCX|.  The values for |screen_rows| and |screen_cols|, which
% determine how big \MF's window for online output is, should perhaps
% also be changed; individual users should definitely change them to
% their own tastes.
% 
% This file defines {\tt ?} to type out a list of all the known
% |mode_def|s (once only).
% 
% A |mode_def| is a \MF\ definition that typically consists of a series
% of assignments to various device-specific variables, either primitive
% or defined in plain.  These variables include the following (page
% numbers refer to {\sl The \MF book\/}:
% 
% |aspect_ratio|: the ratio of the vertical resolution to the horizontal
%   resolution (page 94).
% 
% |blacker|: a correction added to the width of stems and similar
%   features, to account for devices which would otherwise make them too
%   light (page 93).  (Write-white devices are best handled by a more
%   sophisticated method than adding to |blacker|, as explained above.)
% 
% |fillin|: a correction factor for diagonals and other features which
%   would otherwise be ``filled in'' (page 94).  An ideal device would
%   have |fillin=0| (page 94).  Negative values for |fillin| will
%   probably either gross effects or none at all.
% 
% |fontmaking|: if nonzero at the end of the job, \MF\ makes a TFM file
%   (page 315).
% 
% |o_correction|: a correction factor for the ``overshoot'' of curves
%   beyond the baseline (or x-height, or some other line).  High
%   resolution curves look better with overshoot, so such devices should
%   have |o_correction=1|; but at low resolutions, the overshoot appears
%   to simply be a distortion (page 93).  Here some additional comments
%   about |o_correction|, courtesy of Pierre MacKay (edited by Karl):
% 
%   At present, I find that |o_correction| works nicely at 80 pixels per
%   em, and gets increasingly disturbing as you move down towards 50
%   pixels per em. Below that I do not think it ought to happen at all.
%
%   The problem, of course, is that full |o_correction| is supposed to
%   occur only at the zenith and nadir of the curve of `o', which is a
%   small region at high resolution, but may be a long line of
%   horizontal pixels at medium resolution.  The full |o_correction|
%   does not change a 300$\,$dpi {\tt cmr10}, but it changes a 21-pixel
%   high {\tt cmr12} to be 23 pixels high.  The extra height and depth
%   is seen along a line of seven pixels at the bottom and five at the
%   top.  This is a pronounced overshoot indeed.
%
%   For high-resolution devices, such as phototypesetters, the values
%   for |blacker|, |fillin|, and |o_correction| don't matter all that
%   much, so long as the values are within their normal ranges: between
%   0 and 1, with the values approaching 0, 0, and 1 respectively.
% 
% |pixels_per_inch|: the horizontal resolution; the \MF\ primitive
%   |hppp| (which is what determines the extension on the GF filename,
%   as among other things) is computed from this (page 94).  (An
%   ``inch'' is 72.27\thinspace pt in the \TeX\ world.)
%
%   To be more precise, you can determine the resolution of a font given
%   a |mode_def| and a magnification |m| by simply multiplying
%   |pixels_per_inch| for that |mode_def| by |m|.  (Of course, your
%   results may differ from \MF's if you don't use equivalent
%   fixed-point arithmetic routines.)  Then you can determine the number
%   used in the name of the GF font output by rounding.  For example, a
%   font generated at |magstep(.5)| (which is $\sqrt{1.2}$, which \MF
%   computes as 1.09544) for a printer with |pixels_per_inch=300| will
%   have a resolution of 328.63312 dots per inch, and the GF filename
%   will include the number {\tt 329}.
%
% |proofing|: says whether to put additional specials in the GF file for
%   use in making proofsheets with the assistance of, e.g., the utility
%   program {\tt GFtoDVI} (page 323--4).
% 
% |tracingtitles|: if nonzero, strings that appear as \MF\ statements
%   are typed on the terminal (page 187).
% 
% Neenie Billawala's article in the April 1987 issue of {\sl TUGboat}
% describes how to test your printer for the best set of values for the
% magic numbers above.  Here are some brief comments on the subject,
% courtesy of {\tt rocky@watson.ibm.com}, again edited by Karl:
% 
% For medium-to-low resolution devices, you can first set the |blacker|
% and |o_correction| to~0 and decide on a |fillin| value by looking at
% the diagonal of a lowercase `z' in the typewriter font. The diagonal
% should be the same thickness as the horizontal bars of the `z'. Then I
% decide on the |blacker| value, generally by checking the smaller fonts
% for too much filling in.  Finally, you can set the |o_correction|
% using the guidelines suggested above.
% 
%"
% }

% Identify ourselves in the format file.
base_version := base_version & "/modes 0.8";


% Here are useful macros (also called definitions) that we will use
% throughout.

% First, some comments about how the |mode_defs| are constructed (from
% {\tt rocky@watson.ibm.com}).  In the past, |mode_defs| unconditionally
% assigned a value to the various mode-dependent parameters. For
% example, they contained an assignment |fontmaking:=1|, which tells
% \MF\ to write a TFM file.
%
% But suppose you want to generate a font using all of the setup for
% some mode |m|, but just do not want to generate a tfm? One could
% create another mode that doesn't have the assignment, but this seems a
% bit wasteful since the rest of the code in the mode would be
% duplicated.  Furthermore, given the way the mode definitions were
% written, it was not possible to change the mode parameters.  To see
% why, I review how a \MF run typically works.
%
% First, \MF is invoked with some base file to load.  Then you might
% want give additional instructions, such as |scrollmode|, or |mode:=m|.
% Next, you input a parameter file, say {\tt cmr10}.  The parameter file
% calls a driver file, such as {\tt roman}, with the command |generate
% roman|.  Finally, the driver finished by saying |bye| or |end|.  Thus,
% any additional commands you give after the input of the parameter file
% are ignored.
%
% Usually, one of the first things a driver file does is to call
% |mode_setup|. It is here that the mode parameters are set.  (In our
% hypothetical mode, it would be here that |fontmaking| is assigned.)
%
% To allow a flexible setting of |fontmaking|, we can make a simple
% change: in the |mode_def|, first test to see if a value has been
% defined prior and only make the assignment if not. That is:
% |if unknown fontmaking: fontmaking := 1; fi|.
%
% Alas, this doesn't work.  Primitives, like |fontmaking|, are always
% |known|.  So instead we create ``guard'' variables, e.g.,
% |mode_guard_.fontmaking|; we set the guard variable when we assign the
% parameter.  Then we test whether the guard variable is |known| before
% we actually do an assignment.
% This allows more flexible definitions: you can specify some of the
% parameters, and keep the default value for others.
%
% It is also possible to write a program that creates a |mode_def| on
% the fly. Although useful, this has a slightly different focus than
% starting with an existing |mode_def| and changing a couple of
% parameters. In particular, one still has to peek inside the
% file to see what the old values were and set them again (in the
% new context). Also, such on-the-fly |mode_def| generation programs are
% inherently less machine-independent that a scheme that does
% everything in \MF\ itself.
%
% The upshot of all this is the following definition:  we say, e.g.,
% |mode_param (fontmaking, 1)| below, instead of doing a real
% assignment.  The name (``|mode_param|'') is kept short because you
% also use this to override a mode assignment, on the command line or in
% response to the {\tt **} prompt.
def mode_param (suffix v) (expr e) =
  if unknown mode_guard_.v:
    v := e;
    mode_guard_.v := 1;
  fi
enddef;

% This macro is invoked by all the modes, after |pixels_per_inch|
% has been defined, thus saving some space and time.
def mode_common_setup_ =
  mode_param (proofing, 0);
  mode_param (fontmaking, 1);
  mode_param (tracingtitles, if pixels_per_inch > 700: 1 else: 0 fi);
enddef;


% In a similar spirit, here are definitions to change to ``landscape''
% mode.  You just say {\tt mode := whatever; landscape; ...}, and when
% |mode_setup| is executed, the |aspect_ratio| will be inverted, and
% |pixels_per_inch| changed.
def landscape =
  extra_setup := extra_setup & "landscape_;"
enddef;

def landscape_ =
  begingroup
    interim warningcheck := 0;
    pixels_per_inch := aspect_ratio * pixels_per_inch;
    aspect_ratio := 1 / aspect_ratio;
  endgroup
enddef;


% Here are macros to add specials with mode information to the GF file.
% 
% Specifically, we add the |pixels_per_inch|, |o_correction|,
% |aspect_ratio| (if not 1), |mag|, |fillin|, and |mode_def| name.  This
% information can be used to automatically verify that a font file name
% matches the specification within the file.  For example, you could
% check that the number in the filename matches |mag*pixels_per_inch|.
% Or, if the |mode_def| name is is put in the font directory path (e.g.,
% you put fonts in {\tt $\ldots$/tex/fonts/CanonCX}), that all of the
% bitmap files in the directory have the expected |mode_def| name.

def mode_special_ (suffix $) =
  string s, d;
  s := str $;
  d := decimal scantokens s;
  special s & " := " & d & ";"
enddef;

def mode_output_specials_ =
  begingroup
    save d, s, p, p_p_i;
    string p;

    interim warningcheck := 0; % In case |pixels_per_inch>4096|.

    % We need the old |pixels_per_inch| to compute the true device
    % resolution.
    p_p_i = pixels_per_inch / mag;

    % But now we want to change |pixels_per_inch|, so we |save| the
    % old value.
    save pixels_per_inch;
    pixels_per_inch := p_p_i;

    special jobname;
    mode_special_ (mag);

    p := if string mode:
           mode
         else:
           substring (0, length (mode_name[mode]) - 1) of mode_name[mode]
         fi;
    special "mode := " & p & ";";

    mode_special_ (pixels_per_inch);
    if aspect_ratio <> 1:
      mode_special_ (aspect_ratio);
    fi;
    mode_special_ (blacker);
    mode_special_ (fillin);
    mode_special_ (o_correction);
  endgroup
enddef;


% Here are macros for Xerox-world font info, which can be useful even
% if you never use a Xerox printer.  For instance, {\tt crudetype} uses
% the |coding_scheme| and it is nice to have the font family on record.
% This goes into both the TFM file (as |headerbyte| information), and
% into the GF file, with |special|.

% Make the string |s| be |n| bytes long.
def BCPL_string (expr s, n) =
  for l := if length (s) >= n: n-1 else: length (s) fi: l
    for k := 1 upto l: , substring (k - 1, k) of s endfor
    for k := l + 2 upto n: , 0 endfor
  endfor
enddef;

% The string |s| names the encoding scheme, e.g., {\tt TeX TEXT}.
def coding_scheme expr s =
  headerbyte 9: BCPL_string (s, 40);
  special "codingscheme " & s
enddef;

% The string |s| names the font family, e.g., {\tt CMR}.
def font_family expr s =
  headerbyte 49: BCPL_string (s, 20);
  special "identifier " & s
enddef;

% The integer |x| gives the family member number, which should be
% between 0 and 255.
def font_face_byte expr x =
  headerbyte 72: x;
  special "fontfacebyte";
  numspecial x
enddef;

% So users can say |if known Xerox_world: $\ldots$ fi|
Xerox_world := 1;


% Redefine |end| to put the extra information above in the GF and TFM
% files.  This code is based on that on page 321.
inner end;
let primitive_end_ = end;
def end =
  if fontmaking > 0:
    font_family font_identifier_;
    coding_scheme font_coding_scheme_;
    font_face_byte max (0, 254 - round 2designsize); 
    mode_output_specials_;
  fi;
  primitive_end_.
enddef;

% The {\sl \MF book} gives |bye| two different definitions (on pages 278
% and 321). The first is used in {\tt plain.mf} and is merely a synoynym
% for the primitive |end|.  The second, which is not part of {\tt
% plain.mf}, is similar to the code given above. We want the extra
% information to get into the output files regardless of whether the
% \MF\ source used |end| or |bye|.  The above changed |end|; now we have
% to redefine |bye| again (as on page 278).
outer end, primitive_end_;
let bye = end;


% Here are macros to handle write-white printers.
%
% The basic correction for write-white fonts occurs in the definition of
% |font_setup|.  This can be used to extend or change the write-black
% definition in Computer Modern's {\tt cmbase.mf} or other base files
% based on CM, such as {\tt dxbase.mf}.
%
def mode_write_white_setup_ =
  begingroup
    let black_setup = font_setup;
    def font_setup =
      black_setup;
      min_Vround:=max(fine.breadth,crisp.breadth,tiny.breadth,2);
      if min_Vround<vround min_Vround: min_Vround:=vround min_Vround; fi
      if flare<vround flare: flare:=vround flare; fi
      forsuffixes $=vair,bar,slab,cap_bar,cap_band,vair',vstem,cap_vstem,bold:
        if $<min_Vround: $:=min_Vround; fi endfor
      forsuffixes $=thin_join,hair,curve,flare,dot_size,cap_hair,cap_curve,
       vair,bar,slab,cap_bar,cap_band,stem',cap_stem',vair',fudged.hair,
       fudged.stem,fudged.cap_stem: $:=max($,2); endfor
    enddef;
  endgroup;
  % Only do the above once, in case a font file (unnecessarily) calls
  % |mode_setup| more than once.
  let mode_write_white_setup_ = relax
enddef;


% Here are the modes, given in alphabetical order (without regard to case).

% From {\tt cudat@cu.warwick.ac.uk}.
mode_def AgfaFourZeroZero =             % AGFA 400PS
  mode_param (pixels_per_inch, 406);
  mode_param (blacker, .2);
  mode_param (fillin, 0);
  mode_param (o_correction, .6);
  mode_common_setup_;
enddef;

% From {\tt rokicki@neon.stanford.edu}.
mode_def amiga =                        % Commodore Amiga
  mode_param (pixels_per_inch, 100);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, .2);
  mode_common_setup_;
enddef;

% From {\tt ee@dacth51.bitnet}.
mode_def AtariSLMEightZeroFour =        % Atari ST SLM 804 printer
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, -.25);
  mode_param (fillin, .5);
  mode_param (o_correction, 0);
  mode_common_setup_;
  mode_write_white_setup_;
enddef;

% From {\tt ee@dacth51.bitnet}.
mode_def AtariSMOneTwoFour =            % Atari ST SM 124 screen
  mode_param (pixels_per_inch, 101);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, .4);
  mode_common_setup_;
enddef;

mode_def aps =                          % Autologic APS-Micro5
  mode_param (pixels_per_inch, 722.909);
  mode_param (blacker, .2);
  mode_param (fillin, .2);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;

% From {\tt rocky@watson.ibm.com}.  Tested on the single APS-6 at IBM
% Research.
mode_def ApsSixHi =                     % Autologic APS-Micro6
  mode_param (pixels_per_inch, 1016);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;

mode_def bitgraph =                     % BBN Bitgraph at 118dpi
  mode_param (pixels_per_inch, 118);
  mode_param (blacker, .55);
  mode_param (fillin, .1);
  mode_param (o_correction, .3);
  mode_common_setup_;
enddef;

mode_def boise =                        % HP 2680A
  mode_param (pixels_per_inch, 180);
  mode_param (blacker, .55);
  mode_param (fillin, .1);
  mode_param (o_correction, .3);
  mode_common_setup_;
enddef;

% This applies to the LaserWriter Plus, HP Laserjet, HP Laserjet Plus,
% and also the Canon LBP-LX engine, in the Laserjet IIP, QMS 410, and
% Apple Personal LaserWriter, and also to the CanonSX engine, in the
% LaserWriter II family.
mode_def CanonCX =                      % Canon CX, SX, LBP-LX
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, 0);
  mode_param (fillin, .2);
  mode_param (o_correction, .6);
  mode_common_setup_;
enddef;
mode_def hplf =                      % Canon CX, SX, LBP-LX
  mode_param (pixels_per_inch, 600);
  mode_param (blacker, 0);
  mode_param (fillin, .2);
  mode_param (o_correction, .6);
  mode_common_setup_;
enddef;
cx := CanonCX;
corona := CanonCX;
dp := CanonCX; % some kind of DataProducts
hplaser := CanonCX;
imagen := CanonCX;
kyocera := CanonCX;
laserwriter := CanonCX;
% I have seen a |mode_def| that claimed the LaserJet II was the Canon SX
% write-white engine, but I don't think that's right.
laserjethi := CanonCX;
laserjet := CanonCX;
% {\tt ogawa@orion.arc.nasa.gov} says that this is definitely not a
% write-white engine, despite earlier versions of this file claiming the
% contrary.  Thus, probably the same parameters as |CanonCX| will do.
CanonSX := CanonCX;
CanonLBPLX := CanonCX;

mode_def CanonLBPTen =                  % e.g., Symbolics LGP-10
  mode_param (pixels_per_inch, 240);
  mode_param (blacker, .2);
  mode_param (fillin, .2);
  mode_param (o_correction, .4);
  mode_common_setup_;
enddef;


% The Chelgraph IBX is the machine introduced to North American \TeX\
% users by Type~2000 in Mill Valley, California; telephone
% (415)~388-8873.  Since the machine's stated output resolution is only
% 2000\thinspace dpi this truly spectacular 9600\thinspace dpi must be
% used for translation to an outline font description.  This
% |mode_def| has been tested and used in a publication of the University
% of Washington Press.  These values from Pierre MacKay, based on Lance
% Carnes' crs values, at magstep~1.8.
mode_def ChelgraphIBX =                 % Chelgraph IBX
  mode_param (pixels_per_inch, 4000 + 4000 + 1600);
  mode_param (blacker, 4);
  mode_param (fillin, 0);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;

% From {\tt rokicki@cs.umb.edu}.
mode_def CItohThreeOneZero =            % CItoh 310
  mode_param (pixels_per_inch, 240);
  mode_param (aspect_ratio, 144 / pixels_per_inch);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, .2);
  mode_common_setup_;
enddef;
cthreeten := CItohThreeOneZero;

% From {\tt local.mf} via {\tt cudat@cu.warwick.ac.uk}.
mode_def CItohEightFiveOneZero =        % CItoh 8510A
  mode_param (pixels_per_inch, 160);
  mode_param (aspect_ratio, 144 / pixels_per_inch);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, .1);
  mode_common_setup_;  
enddef;
itoh := CItohEightFiveOneZero;

mode_def CompugraphicEightSixZeroZero = % Compugraphic 8600
  mode_param (pixels_per_inch, 1301.5);
  mode_param (aspect_ratio, 1569 / pixels_per_inch);
  mode_param (blacker, .2);
  mode_param (fillin, .2);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;
cg := CompugraphicEightSixZeroZero;

% This has a resolution of |5333 + 1/3| pixels per inch.
mode_def crs =                          % Alphatype CRS
  mode_param (pixels_per_inch, 4000 + 4000/3);
  mode_param (blacker, 4); 
  mode_param (fillin, 0);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;

% At least magstep 2 is recommended at this low resolution.
mode_def DataDisc =                     % DataDisc
  mode_param (pixels_per_inch, 70);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, .2);
  mode_common_setup_;
enddef;
DD := DataDisc;

mode_def DataDiscNew =                  % DataDisc with special aspect ratio
  mode_param (aspect_ratio, 4/3);
  DataDisc_;
enddef;
newDD := DataDiscNew;

mode_def dover =                        % Xerox Dover
  mode_param (pixels_per_inch, 384);
  mode_param (blacker, 1.2);
  mode_param (fillin, 0);
  mode_param (o_correction, .6);
  mode_common_setup_;
enddef;

% Perhaps this should be 120 horizontally and 216 vertically, if it is
% for the MX-80.
mode_def epsonlo =                      % Epson at 120dpi
  mode_param (pixels_per_inch, 120);
  mode_param (aspect_ratio, 144 / pixels_per_inch);
  EpsonMXFX_;
enddef;
epslo := epsonlo;

% This and |EpsonLQFiveZeroZeroLo| also work for a Mannesmann 300 (from
% {\tt cudat@csv.warwick.ac.uk}, 4 September 1991).  The $360\times360$
% modes for these printers fails for {\tt cudat}, however.
mode_def EpsonLQFiveZeroZeroMed =       % Epson LQ-500, 360x180dpi
  mode_param (pixels_per_inch, 360);
  mode_param (aspect_ratio, 180 / pixels_per_inch);
  mode_param (blacker, 0); % 0.3 avoids `holes'.
  mode_param (fillin, 0);
  mode_param (o_correction, .1);
enddef;
lqmedres := EpsonLQFiveZeroZeroMed;

mode_def EpsonLQFiveZeroZeroLo =        % Epson LQ-500, 180x180dpi
  mode_param (pixels_per_inch, 180);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, .1);
enddef;
lqlores := EpsonLQFiveZeroZeroLo;

% These values from Charles Karney, {\sl TUGboat} 8(2), page 133.  This
% is for the Epson MX/FX family (-85, -286), which are 9-pin printers.
% The 24-pin LQ family have higher resolutions; no one has sent me
% |mode_def|s for them yet.  Ditto for Epson's laser printer.  (Thanks
% to {\tt cargo@escargot.cray.com} for all this information.)
mode_def EpsonMXFX =                    % 9-pin Epson MX/FX family
  mode_param (pixels_per_inch, 240);
  mode_param (aspect_ratio, 216 / pixels_per_inch);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, .2);
  mode_common_setup_;
enddef;
epson := EpsonMXFX;
epshi := EpsonMXFX;
epsonfx := EpsonMXFX;

% From {\tt drstrip@intvax.uucp}.
mode_def GThreefax =                    % 200 x 100dpi G3fax
  mode_param (pixels_per_inch, 200);
  mode_param (aspect_ratio, 100 / pixels_per_inch);
  mode_param (blacker, 0);
  mode_param (fillin, .2);
  mode_param (o_correction, .2);
  mode_common_setup_;
enddef;

% From {\tt fieberjr@whitman.bitnet}.
mode_def HPDeskJet =                    % HP DeskJet 500
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, .6);
  mode_common_setup_;
enddef;

% Here are some general comments on the IBM printers, courtesy of {\tt
% rocky@watson.ibm.com}.
% 
% IBM 3820's, 3825's, 3827's and 3835's have some sort of corner imaging
% or shading that the IBM 3812's and 3816's don't.  The latter two
% models may get this feature in the future.
%
% The IBM 3827 is made by Kodak, the rest are IBM engines.
%
% Some of the other printers have a knob that allows a service engineer
% to set one of up to ten levels of darkness.  At IBM Research, we run
% very black.  The service engineer sets the level by running a
% completely black page and then two completely blank ones. The black
% page must be black and the following two must be completely white.
%
% Thanks to Jim Hafner ({\tt hafner@ibm.com}) for experimenting with
% |blacker|, and Paul Dantzig for information about these printers.

% From {\tt rocky@watson.ibm.com}.  For the typewriter, slanted, and
% italic fonts, |blacker=0| makes the `M's and `W's more legible.  But
% then the weight of the font does not match the others.
mode_def IBMD =                         % IBM 38xx
  mode_param (pixels_per_inch, 240);
  mode_param (blacker, .3);
  mode_param (fillin, .4);
  mode_param (o_correction, .75);
  mode_common_setup_;
enddef;

% From {\tt vumalki\%weizmann.weizmann.ac.il@taunivm.tau.ac.il}.
mode_def IBMFourTwoFiveZero =           % IBM 4250
  mode_param (pixels_per_inch, 600);
  mode_param (blacker, .05);
  mode_param (fillin, 0);
  mode_param (o_correction, .6);
  mode_common_setup_;
enddef;  

% From {\tt Martin.Ward@durham.ac.uk}.  Apparently the engine is
% different from the Ricoh 4080.  With a larger value of |blacker|,
% characters like the `e' in {\tt cmtt8} look bad.
mode_def IBMFourTwoOneSix =             % IBM 4216
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, .2);
  mode_param (fillin, 0);
  mode_param (o_correction, .75);
  mode_common_setup_;
  mode_write_white_setup_;
enddef;
RicohA := IBMFourTwoOneSix;

% From Rick Simpson via {\tt erikjan@icce.rug.nl}.
mode_def IBMProPrinter =                % IBM ProPrinter
  mode_param (pixels_per_inch, 240);
  mode_param (aspect_ratio, 216 / pixels_per_inch);
  mode_param (blacker, 0);
  mode_param (fillin, .2);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;
proprinter := IBMProPrinter;

% From Rick Simpson via {\tt erikjan@icce.rug.nl}.  Also gave values of
% zero for |blacker|, |fillin|, and |o_correction|.
mode_def IBMSixOneFiveFour =            % IBM 6154 display
  mode_param (pixels_per_inch, 0);
  mode_param (blacker, .8);
  mode_param (fillin, .2);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;

% From {\tt rocky@watson.ibm.com}.  This is an old, untested definition.
mode_def IBMSixSixSevenZero =           % IBM 6670 (Sherpa)
  mode_param (pixels_per_inch, 240);
  mode_param (blacker, 1);
  mode_param (fillin, 1);
  mode_param (o_correction, .5);
  mode_common_setup_;
  mode_write_white_setup_;
enddef;
Sherpa := IBMSixSixSevenZero;

% From {\tt vumalki\%weizmann.weizmann.ac.il@taunivm.tau.ac.il}.
mode_def IBMThreeEightOneTwo =          % IBM 3812
  mode_param (pixels_per_inch, 240);
  mode_param (blacker, .6);
  mode_param (fillin, .4);
  mode_param (o_correction, 0);
  mode_common_setup_;
  mode_write_white_setup_;
enddef;
IBMUlfHolleberg := IBMThreeEightOneTwo;

% These values from {\tt d\_webb@chcc.harwell.aea-technology.uk}.
mode_def IBMThreeEightTwoZero =         % IBM 3820
  mode_param (pixels_per_inch, 240);
  mode_param (blacker, .78);
  mode_param (fillin, .25);
  mode_param (o_correction, .5);
  mode_common_setup_;
enddef;

% These values from {\tt melvin@math.psu.edu}.
mode_def IBMEGA =                       % IBM VGA monitor
  mode_param (pixels_per_inch, 96);
  mode_param (aspect_ratio, .841);
  mode_param (blacker, .3);
  mode_param (fillin, 0);
  mode_param (o_correction, 0);
  mode_common_setup_;
enddef;

% These values from {\tt d\_webb@chcc.harwell.aea-technology.uk}.
% {\tt melvin@math.psu.edu} thinks |pixels_per_inch=96| might be better.
mode_def IBMVGA =                       % IBM VGA monitor
  mode_param (pixels_per_inch, 110);
  mode_param (blacker, .3);
  mode_param (fillin, 0);
  mode_param (o_correction, 0);
  mode_common_setup_;
enddef;

% Perhaps the value for |fillin| should be 0.
mode_def imagewriter =                  % Apple ImageWriter
  mode_param (pixels_per_inch, 144);
  mode_param (blacker, 0);
  mode_param (fillin, 0.3);
  mode_param (o_correction, .2);
  mode_common_setup_;
enddef;
iw := imagewriter;

% From {\tt ST-TeX.MF} via {\tt braams@pttrnl.nl}.  (The 300dpi LaserJet
% is another |CanonCX|.)
mode_def laserjetlo =                   % HP LaserJet at 150dpi
  mode_param (pixels_per_inch, 150);
  mode_param (blacker, 0);
  mode_param (o_correction, 1);
  mode_param (fillin, .1);
  mode_common_setup_;
enddef;

% From John Sauter.
mode_def LASevenFive =                  % DEC LA75
  mode_param (pixels_per_inch, 144);
  mode_param (blacker, .3);
  mode_param (fillin, -.1);
  mode_param (o_correction, 0);
  mode_common_setup_;
enddef;

mode_def LinotypeOneZeroZeroLo =        % Linotype Linotronic [13]00 at 635dpi
  mode_param (pixels_per_inch, 635);
  LinotypeOneZeroZero_;
enddef;
linolo := LinotypeOneZeroZeroLo;
linohalf := LinotypeOneZeroZeroLo;

% These values from {\tt d\_webb@chcc.harwell.aea-technology.uk}.  The
% `a' in {\tt cmr5} looks better with |blacker=.3|.  Values of .2 for
% both |blacker| and |fillin| have also been used.
mode_def LinotypeOneZeroZero =          % Linotype Linotronic [13]00 at 1270dpi
  mode_param (pixels_per_inch, 1270);
  mode_param (blacker, .65);
  mode_param (fillin, -.1);
  mode_param (o_correction, .5);
  mode_common_setup_;
  mode_write_white_setup_;
enddef;
linoone := LinotypeOneZeroZero;
linohi := LinotypeOneZeroZero;
linothreelo := LinotypeOneZeroZero;

% These values from {\tt d\_webb@chcc.harwell.aea-technology.uk}.
mode_def LinotypeThreeZeroZeroHi =      % Linotype Linotronic 300 at 2540dpi
  mode_param (pixels_per_inch, 2540);
  mode_param (blacker, .2);                % Copied from |aps|---conjectural.
  mode_param (fillin, .2);                 % (ditto)
  mode_param (o_correction, 1);            % (ditto)
  mode_common_setup_;
enddef;
linothree := LinotypeThreeZeroZero;
linosuper := LinotypeThreeZeroZero;

% From Richard Watson at the Queensland Institute of Technology.  This
% printer is said to have some kind of Xerox engine, but I don't know
% which.
mode_def LNZeroOne =                    % DEC LN01
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, .9);
  mode_param (fillin, 0);
  mode_param (o_correction, .5);
  mode_common_setup_;
enddef;

% These values from {\tt karl@cs.umb.edu}.  |blacker = .8| or more
% thickens dots, to their detriment.  |blacker = .6| produces two-pixel
% stems, which looks pretty good for {\tt cmr}, but it's a little dark
% for {\tt cmti}, and {\tt cmbx} and {\tt cmr} then turn out the same.
% |o_correction = 1| made no difference.  |fillin = 1| made no
% difference.
mode_def lview =                        % Sigma L-View monitor
  mode_param (pixels_per_inch, 118.06);
  mode_param (aspect_ratio, 109.25 / pixels_per_inch);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, 0);
  mode_common_setup_;
enddef;

% This |mode_def| is untested.
mode_def MacMagnified =                 % Mac screens at magstep 1
  mode_param (pixels_per_inch, 86.4);
  mode_param (blacker, .35);
  mode_param (fillin, .1);
  mode_param (o_correction, .3);
  mode_common_setup_;
enddef;
bettermac := MacMagnified;

% From the VMS distribution tape (except {\tt karl@cs.umb.edu} changed
% the |o_correction| to zero).
mode_def MacTrueSize =                  % Mac screens at 72dpi
  mode_param (pixels_per_inch, 72);
  mode_param (blacker, .0);
  mode_param (fillin, 0);
  mode_param (o_correction, 0);
  mode_common_setup_;
enddef;
truemac := MacTrueSize;

% From {\tt rokicki@neon.stanford.edu}.
mode_def NEC =                          % NEC
  mode_param (pixels_per_inch, 180);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, .2);
  mode_common_setup_;
enddef;
lqlores := NEC;

% This is the same as |CanonCX|, except for the resolution.
mode_def NEChi =                        % NEC-P6 at 360x360dpi
  mode_param (pixels_per_inch, 360);
  CanonCX_;
enddef;
lqhires := NEChi;

% From {\tt lambert@silver.cs.umanitoba.ca}.
mode_def Newgen =                       % Newgen 400dpi
  mode_param (pixels_per_inch, 400);
  CanonCX_;
enddef;

% From {\tt rokicki@neon.stanford.edu}.
mode_def NeXTprinter =                  % NeXT 400dpi
  mode_param (pixels_per_inch, 400);
  CanonCX_;
enddef;
nexthi := NeXTprinter;

% From {\tt rokicki@neon.stanford.edu}.
mode_def NeXTscreen =                   % 100dpi NeXT monitor
  mode_param (pixels_per_inch, 100);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, 0);
  mode_common_setup_;
enddef;
nextscreen := NeXTscreen;

% From {\tt deby@cs.utwente.nl}.
mode_def OCESixSevenFiveZeroPS =        % OCE 6750PS
  mode_param (pixels_per_inch, 508);
  mode_param (blacker, 0);
  mode_param (fillin, -.2);
  mode_param (o_correction, .7);
  mode_common_setup_;
enddef;

% From {\tt rokicki@neon.stanford.edu}.
mode_def okidata =                      % Okidata
  mode_param (pixels_per_inch, 240);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, .2);
  mode_param (aspect_ratio, 288 / pixels_per_inch);
  mode_common_setup_;
enddef;
okihi := okidata;

% {\tt AMSmodes.def} defines |pcscreen| to be essentially this, but with
% a resolution of 118.  I figured |pcscreen| was such a general name
% that I could change the definition slightly.
mode_def OneTwoZero =                   % e.g., high-resolution Suns
  mode_param (pixels_per_inch, 120);
  mode_param (blacker, .35);
  mode_param (fillin, .1);
  mode_param (o_correction, .3);
  mode_common_setup_;
enddef;
pcscreen := OneTwoZero;

% This is a write-white PostScript laser-setter, made by a Xerox
% subsidiary.  It has a bizarre nonsquare aspect ratio of 1/2, but {\tt
% mis@apsedoff.bitnet} says that the printer hides this, and PostScript
% programs should treat it as having a square aspect ratio.
% Headquarters in Minnesota; telephone: (612) 456-1400.  At this
% resolution, the write-white correction may not matter, but it is safer
% to turn it on anyway.  This |mode_def| not yet tested in production.
mode_def PrintwareSevenTwoZeroIQ =      % Printware 720IQ
  mode_param (pixels_per_inch, 1200);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, 1);
  mode_common_setup_;
  mode_write_white_setup_;
enddef;

% From John Gourlay.  See {\sl TUGboat} 8(2), page 133.
mode_def qms =                          % QMS (Xerox engine)
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, .6);
  mode_param (fillin, -.3);
  mode_param (o_correction, .6);
  mode_common_setup_;
enddef;

% These values from Stan Osborne, {\sl TUGboat} 8(2), page 134.
mode_def RicohFourZeroEightZero =       % e.g., the TI Omnilaser
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, .2);
  mode_param (fillin, -.2);
  mode_param (o_correction, .5);
  mode_common_setup_;
  mode_write_white_setup_;
enddef;
ricoh := RicohFourZeroEightZero;
RicohFortyEighty := RicohFourZeroEightZero;

% From John Sauter.
mode_def RicohLP =                      % e.g., the DEC LN03
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, .65);
  mode_param (fillin, -.2);
  mode_param (o_correction, .5);
  mode_common_setup_;
  mode_write_white_setup_;
enddef;
LNOthree := RicohLP;
LNZeroThree := RicohLP;

% From {\tt dickson@eeserv.ee.umanitoba.ca}.  {\tt gil.cc.gatech.edu}
% has different values.  Corrected by {\tt andy@vlsi.cs.caltech.edu}, 28
% August 1991.
mode_def SparcPrinter =                 % Sun SPARCprinter
  mode_param (pixels_per_inch, 400);
  mode_param (blacker, .25);
  mode_param (fillin, .2);
  mode_param (o_correction, .6);
  mode_common_setup_;
enddef;

% From {\tt ee@dacth51.bitnet}.
mode_def StarNLOneZero =                % Star NL-10
  mode_param (pixels_per_inch, 240);
  mode_param (aspect_ratio, 216 / pixels_per_inch);
  mode_param (blacker, -.6);
  mode_param (fillin, .2);
  mode_param (o_correction, .4);
  mode_common_setup_;
enddef;

% From {\tt grunwald@foobar.colorado.edu}.  Sun monitors have several
% different resolutions, but this seems the best choice of the lot.
mode_def sun =                          % Sun and BBN Bitgraph at 85dpi
  mode_param (pixels_per_inch, 85);
  mode_param (blacker, .35);
  mode_param (fillin, .1);
  mode_param (o_correction, .3);
  mode_common_setup_;
  enddef;

mode_def supre =                        % Ultre*setter at 2400dpi
  mode_param (pixels_per_inch, 2400);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;

mode_def toshiba =                      % Toshiba 13XX, EpsonLQ
  mode_param (pixels_per_inch, 180);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, .2);
  mode_common_setup_;
enddef;
epsonlq := toshiba;

mode_def ultre =                        % Ultre*setter at 1200dpi
  mode_param (pixels_per_inch, 1200);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;

% From {\tt rocky@watson.ibm.com}.  This can also be used for the
% Autologic's APS6 cut sheet dry process printer.  For that printer,
% perhaps |blacker=0.8| is better. For the Varityper, though, at
% |blacker=0.8| the dots of the umlaut start to fill in.  For
% |blacker<0.6|, the tops and bottoms of lowercase g's and s's in {\tt
% cmr5} drop out.
mode_def VarityperFiveZeroSixZeroW =    % Varitype 5060W
  mode_param (pixels_per_inch, 600);
  mode_param (blacker, .7);
  mode_param (fillin, 0);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;
APSSixMed := VarityperFiveZeroSixZeroW;

% From {\tt erikjan@icce.rug.nl}, 23 August 1991.
mode_def VarityperFourTwoZeroZero =     % Varityper Phototypesetter 4200 B-P
  mode_param (pixels_per_inch, 1800);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;

% The worst problem is toner irregularity.
mode_def VarityperSixZeroZero =         % Varityper Laser 600
  mode_param (pixels_per_inch, 600);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, 1);
  mode_common_setup_;
enddef;
varityper := VarityperSixZeroZero;
VTSix := VarityperSixZeroZero;

% From {\tt Martin.Ward@durham.ac.uk}.  
mode_def VAXstation =                   % VAXstation monitor
  mode_param (pixels_per_inch, 78);
  mode_param (blacker, 0);
  mode_param (fillin, 0);
  mode_param (o_correction, 0);
  mode_common_setup_;
enddef;
vs := VAXstation;
gpx := VAXstation;

% From {\tt u12570@uicvm.uic.edu}.  These values are mostly guesses.
mode_def XeroxEightSevenNineZero =      % Xerox 8790 or 4045
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, 0.4);
  mode_param (fillin, 0);
  mode_param (o_correction, 0.2);
  mode_common_setup_;
  mode_write_white_setup_;
enddef;

% From {\tt u12570@uicvm.uic.edu}.  Many variations for different fonts
% here.
mode_def XeroxFourZeroFiveZero =        % Xerox 4050
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, .7);
  mode_param (fillin, 0);
  mode_param (o_correction, .5);
  mode_common_setup_;
enddef;

% From {\tt u12570@uicvm.uic.edu}.  He sent many variations of this,
% for different fonts.  I don't know a reasonable way to put them in
% yet, so this is just the basic entry.
mode_def XeroxNineSevenZeroZero =       % Xerox 9700
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, .7);
  mode_param (fillin, 0);
  mode_param (o_correction, .5);
  mode_common_setup_;
enddef;

% From {\tt lee@sq.com}.  These values may be improvable.
mode_def XeroxThreeSevenZeroZero =      % Xerox 3700
  mode_param (pixels_per_inch, 300);
  mode_param (blacker, .85);
  mode_param (fillin, -.1);
  mode_param (o_correction, .5);
  mode_common_setup_;
  mode_write_white_setup_;
enddef;

mode_def help =                         % What modes are defined?
 for i = 1 upto number_of_modes:
   message mode_name[i];
 endfor; 
 % Doesn't make sense to be able to do this twice, so forget this
 % definition after it's been used.
 save ?;
enddef;

let ? = help_;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%local stuff for the Milieu package

picture picvar; numeric charnr;charnr:=ASCII("A")-1;

def sscreen(expr w_sharp,h_sharp,d_sharp,c_scale) =
 picvar:=currentpicture;
 charscreen(incr charnr,w_sharp,h_sharp,d_sharp)
  currentpicture:=currentpicture scaled c_scale;
 endchar;
 currentpicture:=picvar;
enddef;

def charscreen(expr c,w_sharp,h_sharp,d_sharp) =
 begingroup
 charcode:=if known c: byte c else: 0 fi;
 charwd:=w_sharp;      charht:=h_sharp;       chardp:=d_sharp;
 w:=hround(charwd*hppp); h:=vround(charht*hppp); d:=vround(chardp*hppp);
 charic:=0; scantokens extra_beginchar;
enddef;


% These variables determine the size of \MF's (window system) window for
% online output.  These numbers should match whatever the window system
% is told, or bizarre positioning of the output in the window results.
% Properly implemented online device drivers will use these values as
% the default size.
screen_cols := 800;
screen_rows := 600;
pair screen_topleft;
screen_topleft:=(-50,500);
def openit = openwindow currentwindow
 from origin to (screen_rows,screen_cols) at screen_topleft enddef;

% The mode most commonly used to make fonts here.
localfont := CanonCX;

%%\bye
%%%% 
%%%% Local variables:
%%%% page-delimiter: "^% here are"
%%%% End:
