-- TexTfmDefs.mesa

-- Definition of Tex font metric (.Tfm) files for Alto
-- last written by Doug Wyatt, November 11, 1979 3:56 PM

TexTfmDefs: DEFINITIONS =
BEGIN

BYTE: TYPE = [0..377B];

Char: TYPE = CHARACTER[0C..177C]; -- should match TexDefs.Char
Dimn: TYPE = INTEGER; -- a dimension in micas; should match TexDefs.Dimn

-- the layout of a font information file
--
-- header 12 words
-- nw,nh,.. 8 words
-- finfo 256 words (2 per character)
-- widths 64 words max
-- heights 32 words max
-- depths 32 words max
-- italcorr 64 words max
-- kerns 3 words (typical)
-- ligtable 42 words (for cmr10, usually fewer)
-- exttable ?? words (only in cmathx, which has no ligtable)
-- fontpars 24 words max (for sy fonts) (fonts with mathpars have no ligs)
--
-- a tfm file will typically fit in 2 Alto pages (512 words)

FontType: TYPE = {nontex,roman,italic,symbol,mathex,spare1,spare2,spare3};

TfmHeader: TYPE = MACHINE DEPENDENT RECORD
[
header: FontHeader,
nw: CARDINAL, -- number of words in width array
nh: CARDINAL, -- number of words in height array
nd: CARDINAL, -- number of words in depth array
ni: CARDINAL, -- number of words in italic correction array
nk: CARDINAL, -- number of words in kern array
nl: CARDINAL, -- number of words in ligature table
ne: CARDINAL, -- number of words in extension table
np: CARDINAL -- number of words in fontparams
-- followed by:
-- finfo array
-- width array
-- height array
-- depth array
-- charic array
-- kern array
-- ligature table
-- extension table
-- font params
];

-- a Bcpl string body, 10 words long
NameBody: TYPE = MACHINE DEPENDENT RECORD
[
SELECT OVERLAID * FROM
length => [length: [0..256), unusedbyte: [0..256),
unusedwords: ARRAY [1..10) OF WORD],
chars => [chars: PACKED ARRAY [-1..19) OF CHARACTER],
ENDCASE
];

FontHeader: TYPE = MACHINE DEPENDENT RECORD
[
name: NameBody, -- a bcplSTRING of up to 19 characters
micasize: CARDINAL, -- size in micas
unused: [0..37B],
type: FontType,
face: FaceCode -- face encoding, ala Press
];
FaceCode: TYPE = BYTE;


-- The following must be carefully chosen so that FInfo is properly packed
wdmax: CARDINAL = 77B; -- maximum width index (6 bits)
htmax: CARDINAL = 37B; -- maximum height index (5 bits)
dpmax: CARDINAL = 37B; -- maximum depth index (5 bits)
icmax: CARDINAL = 177B; -- maximum charic index (7 bits)
-- allow 2 bits for LgField’s tag
lgmax: CARDINAL = 177B; -- maximum lig/ext index (7 bits)

FInfo: TYPE = MACHINE DEPENDENT RECORD
[
wd: [0..wdmax], -- index into width array
ht: [0..htmax], -- index into height array
dp: [0..dpmax], -- index into depth array
ic: [0..icmax], -- index into charic array (italic corr or mathop kern)
lg: LgField -- see below
];

LgField: TYPE = MACHINE DEPENDENT RECORD
[
SELECT lgtype: * FROM
none => [unused: [0..lgmax]], -- no ligatures (mathex: largest char)
lig => [i: [0..lgmax]], -- index into ligtable
next => [c: Char], -- c is the next larger char
ext => [i: [0..lgmax]], -- index into exttable
ENDCASE
];

FInfoArray: TYPE = ARRAY Char OF FInfo;

DimnArray: TYPE = ARRAY [0..0) OF Dimn;
-- for widths, heights, depths, italic corrections, and kerns

LigEntry: TYPE = MACHINE DEPENDENT RECORD
[
stop: BOOLEAN, -- if true, this is the last ligature/kern
next: Char, -- if this is the next character, then...
variant: SELECT tag: * FROM -- one-bit tag specifies lig or kern
ligature => [lig: Char], -- resulting ligature
kern => [k: KernPtr], -- index into kern array
ENDCASE
];
KernPtr: TYPE = [0..177B];

LigTable: TYPE = ARRAY [0..0) OF LigEntry;

ExtEntry: TYPE = PACKED ARRAY ExtPart OF ExtChar;
ExtPart: TYPE = {top, mid, bot, ext};
ExtChar: TYPE = MACHINE DEPENDENT RECORD
[
present: BOOLEAN, -- TRUE if this part of the extensible char is present
char: Char
];

ExtTable: TYPE = ARRAY [0..0) OF ExtEntry;

FPIndex: TYPE = CARDINAL; -- index into fontparams

slant: FPIndex=0;
-- the amount of italic slant (x units per 1000 y units)
spacewd: FPIndex=slant+1;
-- the width of blank spaces
spacestr: FPIndex=spacewd+1;
-- the stretch component of the glue for spacing
spaceshr: FPIndex=spacestr+1;
-- the shrink component of the glue for spacing
xheight: FPIndex=spaceshr+1;
-- height of lowercase "x" (default positioning for accents)
quad: FPIndex=xheight+1;
-- the width of one "em"
extraspace: FPIndex=quad+1;
-- additional space to be put after periods

-- Mathematics fonts used as \mathsy and \mathex contain important additional
-- parameter information.

-- In a \mathsy font, the extra parameters are as follows:

mathspace: FPIndex=extraspace;
-- fixed width math space (usually zero)
num1: FPIndex=mathspace+1;
-- amount to raise baseline of numerators in display style
num2: FPIndex=num1+1;
-- ... in nondisplay style
num3: FPIndex=num2+1;
-- ... in nondisplay-atop style
denom1: FPIndex=num3+1;
-- amount to lower baseline of denominators in display style
denom2: FPIndex=denom1+1;
-- ... in nondisplay style
sup1: FPIndex=denom2+1;
-- amount to raise baseline of superscripts in display style
sup2: FPIndex=sup1+1;
-- ... in nondisplay nonvariant style
sup3: FPIndex=sup2+1;
-- ... in variant style
sub1: FPIndex=sup3+1;
-- amount to lower baseline of subscripts if superscript is absent
sub2: FPIndex=sub1+1;
-- ... if superscript is present
supdrop: FPIndex=sub2+1;
-- amount below top of large box to place baseline
-- if the box has a superscript in this size
subdrop: FPIndex=supdrop+1;
-- amount below bottom of large box to place baseline
-- if the box has a subscript in this size
delim1: FPIndex=subdrop+1;
-- size of \comb delimiters in display style
delim2: FPIndex=delim1+1;
-- ... in nondisplay style
axisheight: FPIndex=delim2+1;
-- height of fraction lines above the baseline
-- (this is usually midway between the two bars of the = sign)

defaultrulethickness: FPIndex=extraspace+1;
-- the thickness of \over and \overline bars
-- the following refer to spacing around large displayed operators
bigopspacing1: FPIndex=defaultrulethickness+1;
-- minimum glue space above operator
bigopspacing2: FPIndex=bigopspacing1+1;
-- ... below operator
bigopspacing3: FPIndex=bigopspacing2+1;
-- minimum distance between a limit’s baseline and
-- operator, when the limit is above the operator
bigopspacing4: FPIndex=bigopspacing3+1;
-- ... when the limit is below the operator
bigopspacing5: FPIndex=bigopspacing4+1;
-- extra glue placed above and below limits

END.