-- LedgerFonts.mesa
-- Edited by Sweet, 14-Jan-81 16:44:25
DIRECTORY
LedgerDefs,
Press,
PressDefs,
PressUtilities,
Storage;
LedgerFonts: PROGRAM
IMPORTS LedgerDefs, PressDefs, PressUtilities, Storage
EXPORTS LedgerDefs =
BEGIN OPEN LedgerDefs;
currentWidths: POINTER TO ARRAY CHARACTER OF Mica;
knownWidths: ARRAY FontIndex OF ARRAY FontWeight OF ARRAY FontSlope OF POINTER TO ARRAY CHARACTER OF Mica ← ALL[ALL[ALL[NIL]]];
currentRotation: CARDINAL ← 5400;
SetFontRotation: PUBLIC PROC [rot: CARDINAL] =
BEGIN
currentRotation ← rot;
END;
SetCurrentFont: PUBLIC PROC [fi: FontIndex, weight: FontWeight, slope: FontSlope] =
BEGIN
PointSize: ARRAY FontIndex OF CARDINAL = [Hv6: 6, Hv8: 8, Hv10: 10];
PressDefs.SetFont[
p: pfd,
Name: "Helvetica"L,
PointSize: PointSize[fi],
Face: ComputeFontFace[weight, slope],
Rotation: currentRotation];
currentWidths ← knownWidths[fi][weight][slope];
IF currentWidths = NIL THEN {
currentWidths ← Storage.Node[256];
[] ← PressUtilities.FindFontWidths[
family: "Helvetica"L,
points: PointSize[fi],
weight: weight,
slope: regular,
widths: LOOPHOLE[currentWidths]];
knownWidths[fi][weight][slope] ← currentWidths};
END;
ComputeFontFace: PROCEDURE [w: FontWeight, s: FontSlope]
RETURNS [ff: CARDINAL] =
BEGIN --copied from PressFontWidths
ff ← 0;
SELECT w FROM
medium => ff ← ff + 0;
bold => ff ← ff + 2;
--light => ff ← ff+4;
ENDCASE => ERROR;
SELECT s FROM
regular => ff ← ff + 0;
italic => ff ← ff + 1;
ENDCASE => ERROR;
--SELECT expansion FROM
-- regular => ff ← ff+0;
-- condensed => ff ← ff+6;
-- expanded => ff ← ff+12;
-- ENDCASE => ERROR Press.BadParameters;
END;
GetWidthOfString: PUBLIC PROC [s: STRING] RETURNS [w: Mica] =
BEGIN
w ← 0;
IF s # NIL THEN FOR i: CARDINAL IN [0..s.length) DO
w ← w + currentWidths[s[i]];
ENDLOOP;
END;
GetWidthOfCharacter: PUBLIC PROC [c: CHARACTER] RETURNS [Mica] =
BEGIN
RETURN [currentWidths[c]];
END;
END.