EntityProc: PressReader.EntityProc =
TRUSTED {
-- Xe, Ye, fontSet
xe: INT ← entityTrailer.Xe;
ye: INT ← entityTrailer.Ye;
x: INT ← xe;
y: INT ← ye;
lastShowX, lastShowY: INT ← -1;
currentFont: PressReader.FontDirectoryEntry; -- will be established by setFont
currentPressFont: PressFontReader.Font ← NIL; -- will be established by setFont
currentMicaSize: NAT ← 0; -- will be established by setFont
currentSpaceX, currentSpaceY: INT; -- will be established by setFont
hue: REAL ← 0.0;
saturation: REAL ← 1.0;
brightness: REAL ← 0.0;
skipAlternative, inAlternative: BOOL ← FALSE;
reposition: BOOLEAN ← FALSE;
showCharactersProc: PressReader.ShowCharactersProc =
TRUSTED {
xw, yw: INT ← 0;
IF skipAlternative THEN RETURN;
IF lastShowY # y
THEN {
stream.PutChar['\n];
lastShowX ← 2540;
};
IF ABS[x - lastShowX] < 50 THEN NULL
ELSE
FOR i:
INT ← x - lastShowX, i - 175
UNTIL i <= 0
DO
stream.PutChar[' ]
ENDLOOP;
FOR i:
INT
IN [0..text.Length[])
DO
c: CHAR ← text.Fetch[i];
IF c = '
THEN {
xw ← xw+currentSpaceX;
yw ← yw+currentSpaceY;
}
ELSE
IF currentPressFont #
NIL
THEN {
charInfo: PressFontReader.CharInfo ← PressFontReader.GetCharInfo[currentPressFont, c];
xw ← xw+Real.RoundLI[charInfo.widthX*currentMicaSize];
yw ← yw+Real.RoundLI[charInfo.widthY*currentMicaSize];
}
ENDLOOP;
stream.PutRope[text];
x ← x + xw;
y ← y + yw;
lastShowX ← x;
lastShowY ← y;
}; -- showCharactersProc
fontProc: PressReader.FontProc =
TRUSTED {
IF skipAlternative THEN RETURN;
currentFont ← fontTable[entityTrailer.fontSet*16+font];
currentMicaSize ← IF currentFont.size < 0 THEN -currentFont.size ELSE Real.RoundLI[currentFont.size/72.0*2540.0];
FOR l:
LIST
OF PressFontReader.Font ← pressFonts, l.rest
UNTIL l =
NIL
DO
fontRec: PressFontReader.FontInfoRec ← l.first.info;
IF Rope.Equal[fontRec.family, currentFont.family,
FALSE]
AND (fontRec.face = currentFont.face.encoding)
AND ((fontRec.size = 0.0)
OR (
ABS[fontRec.size - currentMicaSize*(1.0E-5)] < 4.0E-5))
AND ((fontRec.rotation = currentFont.rotation)
OR ((fontRec.rotation = 0)
AND (currentFont.rotation
MOD 5400 = 0)))
THEN {
currentPressFont ← l.first;
EXIT;
};
ENDLOOP;
};
positionProc: PressReader.PositionProc =
TRUSTED {
IF skipAlternative THEN RETURN;
IF opCode = setX THEN x ← xe + value
ELSE y ← ye + value;
reposition ← TRUE;
};
spacingProc: PressReader.SpacingProc =
TRUSTED {
IF skipAlternative THEN RETURN;
SELECT opCode
FROM
setSpaceX, setSpaceXShort => currentSpaceX ← value;
setSpaceY, setSpaceYShort => currentSpaceY ← value;
resetSpace => {
currentSpaceX ← 200;
currentSpaceY ← 0;
};
ENDCASE => ERROR;
IF opCode = resetSpace THEN NULL ELSE NULL;
};
spaceProc: PressReader.SpaceProc =
TRUSTED {
showCharactersProc[showCharacterImmediate, 1, " "];
};
colorProc: PressReader.ColorProc =
TRUSTED {
IF skipAlternative THEN RETURN;
SELECT opCode
FROM
setHue => NULL;
setSaturation => NULL;
setBrightness => NULL;
ENDCASE => ERROR;
};
showRectangleProc: PressReader.ShowRectangleProc =
TRUSTED {
IF skipAlternative THEN RETURN;
NULL;
};
alternativeProc: PressReader.AlternativeProc =
TRUSTED {
IF (types = 0)
AND (elBytes = 0)
AND (dlBytes = 0)
THEN
inAlternative ← skipAlternative ← FALSE
ELSE IF inAlternative THEN skipAlternative ← TRUE
ELSE inAlternative ← TRUE;
};
showObjectProc: PressReader.ShowObjectProc =
TRUSTED {
NULL;
}; -- showObjectProc
showDotsProc: PressReader.ShowDotsProc =
TRUSTED {
NULL;
}; -- showDotsProc
fontProc[0];
pressFile.GetCommands[PressReader.CommandProcs[
showCharactersProc: showCharactersProc,
fontProc: fontProc,
positionProc: positionProc,
spacingProc: spacingProc,
spaceProc: spaceProc,
colorProc: colorProc,
showRectangleProc: showRectangleProc,
alternativeProc: alternativeProc,
showObjectProc: showObjectProc,
showDotsProc: showDotsProc
]];
}; -- EntityProc
stream.PutRope["\n\n------------------------------------------------------------------------"];