% AMSMODES.MF
% This file can be loaded after PLAIN.MF.
% It introduces conventions that were commonly used at WAITS and
% may still be commonly used at AMS.
% (I combined two files on AMS's public directory --- don.)
base_version:=base_version&"/AMS";

% We make the following modification of "mode_def" from PLAIN in order
% to accommodate modes not preloaded in MF.  Even though mode had been
% set dependently on the command line (as with mode=talaris), when
% mode_def came along to define "talaris" the assignment operator
% (:=) wiped out that dependency and left mode hanging and undefined
% when mode_setup was called.  We simply add a test to see whether
% "mode" has been set to the mode being defined.

% Furthermore, if mode was set to a mode which was preloaded and
% that mode was re-defined at run-time, the value of mode would
% only pick up the old definition.  So, for the other case,
% that the mode being defined already has a numeric realization,
% we avoid redefining that mode's (behind-the-scenes) value.

% We also add the following macros to enable conditional "and"
% and "or".  See The METAFONTbook, pp.288--289.

def cand(text q) = startif true q else: false fi enddef;
def cor(text q) = startif true true else: q fi enddef;
tertiarydef p startif true = if p: enddef;

def mode_def suffix $ =
if known($) cand
  (numeric $ cand
  ($<number_of_modes cand
  (mode_name[$] = (str $ & "_")))):
else: if known(mode-$) cand (unknown mode): mode:= fi
      $:=incr number_of_modes;
      mode_name[$]:=str$ & "_";
fi
expandafter quote def scantokens mode_name[$] enddef;

% Say "boise_proof" on the command line, to get proofmode on boise
def boise_proof = lcode_:=" /";
extra_setup:=extra_setup&"grayfont grbois;" enddef;

screen_rows:=400; screen_cols:=480;

% Here are conventions for local output devices:

mode_def dover =  % dover mode: for the Xerox Dover
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=384;
blacker:=1.2;      % make pens somewhat blacker
fillin:=0;      % no compensation for fillin
o_correction:=.6;    % but don't overshoot as much
enddef;

mode_def imagen =  % imagen mode: for the Imagen 8/300 (Canon engine)
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=300;
blacker:=0;      % Canon engine is black enough
fillin:=.2;      % and it tends to fill in diagonals
o_correction:=.6;    %
enddef;

mode_def qms =    % qms mode: for the QMS (Xerox engine)
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=300;
blacker:=.75;      % (this value is conjectural)
fillin:=0;      % (ditto)
o_correction:=.5;    % (ditto)
enddef;

mode_def aps =    % aps mode: for the Autologic APS-Micro5
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=1;      % yes, show titles online
pixels_per_inch:=722.909;    % that's roughly 10 per pt
blacker:=.2;      % make pens a teeny bit blacker
fillin:=.2;      % but compensate for diagonal fillin
o_correction:=1;      % and keep the full overshoot
enddef;

mode_def linotronic =    % for the Linotronic
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=1;      % yes, show titles online
pixels_per_inch:=1270;    % high resolution mode
blacker:=.2;      % make pens a teeny bit blacker (aps value)
fillin:=.2;      % but compensate for diagonal fillin (aps value)
o_correction:=1;      % and keep the full overshoot (aps value)
enddef;

mode_def halflinotronic =    % for the Linotronic
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=1;      % yes, show titles online
pixels_per_inch:=635;    % high resolution mode
blacker:=.2;      % make pens a teeny bit blacker (aps value)
fillin:=.2;      % but compensate for diagonal fillin (aps value)
o_correction:=1;      % and keep the full overshoot (aps value)
enddef;

mode_def crs =    % crs mode: for the Alphatype CRS
 proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=1;      % yes, show titles online
begingroup interim warningcheck:=0;  % (we need to go past 4096)
 pixels_per_inch:=4000+4000/3 endgroup;  % HIGH res
blacker:=4;      % make pens a lot blacker
fillin:=0;      % but don't compensate for fillin
o_correction:=1;      % and keep the full overshoot
enddef;

mode_def boise =  % boise mode: for the HP 2680A
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=180;
blacker:=.55;      % make pens a bit blacker
fillin:=.1;      % and compensate for diagonal fillin
o_correction:=.3;    % but don't overshoot much
enddef;

mode_def DD =  % DD mode: for the DataDisc (usually with mag=magstep 2=1.44)
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;      % no, don't show titles in the log
pixels_per_inch:=70;    % really lowres
blacker:=0;      % don't make the pens any blacker
fillin:=0;        % and don't compensate for fillin
o_correction:=.2;      % but suppress most overshoots
enddef;

mode_def canon =  % canon mode: for the old Imagen (Canon LBP10)
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=240;
blacker:=.2;      % make pens a wee bit blacker
fillin:=.2;      % and compensate for fillin
o_correction:=.4;    % but don't overshoot as much
enddef;

mode_def newDD =  % newDD mode: for DataDisc with special aspect ratio
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=70;    % really lowres
blacker:=0;      % don't make the pens any blacker
fillin:=0;      % and don't compensate for fillin
o_correction:=.2;    % but suppress most overshoots
aspect_ratio:=4/3;    % this is the new feature...
enddef;

mode_def cg =    % cg mode: for the Compugraphic 8600
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=1;      % yes, show titles online
pixels_per_inch:=1301.5;    % a bit less than 20 per pt
blacker:=.2;      % make pens a teeny bit blacker
fillin:=.2;      % but compensate for diagonal fillin
o_correction:=1;      % and keep the full overshoot
aspect_ratio:=1569/1301.5;    % strange, no?
enddef;

mode_def epson =  % Epson
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=240;    % lowres
blacker:=0;      % don't make the pens any blacker
fillin:=0;      % and don't compensate for fillin
o_correction:=.2;    % but suppress most overshoots
aspect_ratio:=9/10;    % 216 dots/inch vertical
enddef;

mode_def pcscreen =  % pcscreen mode: for screen fonts (118dpi)
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=118;
blacker:=0;      % don't make pens any blacker
fillin:=0;      % and don't compensate for diagonal fillin
o_correction:=0;    % don't overshoot (corrected -- they had 1 -- don)
enddef;

mode_def epsonlq =  % epsonlq mode: for the Epson LQ and Toshiba
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=180;
blacker:=0;      % don't make pens any blacker
fillin:=0;      % and don't compensate for diagonal fillin
o_correction:=.3;    % but don't overshoot much
enddef;

mode_def epsonx =  % Epson 240dpi
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=240;    % lowres
blacker:=0;      % don't make the pens any blacker
fillin:=0;      % and don't compensate for fillin
o_correction:=.2;    % but suppress most overshoots
aspect_ratio:=9/10;    % 216 dots/inch vertical
enddef;

mode_def laser =  % laser mode: for the Apple LaserWriter or Canon 300dpi
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=300;
blacker:=0;      % Canon engine is black enough
fillin:=.2;      % and it tends to fill in diagonals
o_correction:=.6;    %
enddef;

mode_def fourc =  % for 400dpi printers
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=400;
blacker:=0;      % engine is black enough
fillin:=.2;      % and it tends to fill in diagonals
o_correction:=.6;    %
enddef;

% macintosh mode: for screen fonts (72dpi) & imagewriter (144dpi)
mode_def macintosh =
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=72;
blacker:=0;      % Don't blacken
fillin:=0;      %
o_correction:=0;  % (corrected -- they had 1 -- don)
enddef;

mode_def notimagewriter =  % notimagewriter mode: to get 129pk for screen
      % Largest resolution which guarantees at least one point size less
      % than imagewriter size.
proofing:=0;      % no, we're not making proofs
fontmaking:=1;      % yes, we are making a font
tracingtitles:=0;    % no, don't show titles in the log
pixels_per_inch:=129;
blacker:=0;      % Don't blacken
fillin:=0;      %
o_correction:=0;  % (corrected -- they had 1 -- don)
enddef;

localfont:=imagen;

% Finally, here are macros for Xerox-world font info:

def font_family expr s =  % string s names the font family, e.g., "CMR"
headerbyte 49: BCPL_string(s,20);
special "identifier "&s enddef;
def coding_scheme expr s = % string s names the scheme, e.g. "TEX TEXT"
headerbyte 9: BCPL_string(s,40);
special "codingscheme "&s enddef;
def font_face_byte expr x = % integer x gives the family member number,
headerbyte 72: x;          % which should be between 0 and 255
special "fontfacebyte"; numspecial x enddef;

def BCPL_string(expr s,n)= % string s becomes an n-byte BCPL string
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;

Xerox_world:=1;    % users can say `if known Xerox_world:...fi'

inner end;
def bye=
if fontmaking>0: font_family font_identifier_;
 coding_scheme font_coding_scheme_;
 font_face_byte max(0,254-round 2designsize); fi
tracingstats:=1;  % at least for now we want this
end
enddef;

outer bye,end;