EntityProc: PressReader.EntityProc = {
-- Xe, Ye, fontSet
xe: INT ← entityTrailer.Xe + xTranslate;
ye: INT ← entityTrailer.Ye + yTranslate;
x: INT ← xe;
y: INT ← ye;
currentFont: PressReader.FontDirectoryEntry; -- 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 = {
IF skipAlternative THEN RETURN;
IF reposition THEN {pressHandle.PutText[text, x, y]; reposition ← FALSE}
ELSE pressHandle.PutTextHere[text];
}; -- showCharactersProc
fontProc: PressReader.FontProc = {
IF skipAlternative THEN RETURN;
currentFont ← fontTable[entityTrailer.fontSet*16+font];
IF currentFont.family.Length # 0
THEN
pressHandle.SetFont[currentFont.family, currentFont.size, currentFont.face.encoding, currentFont.rotation];
};
positionProc: PressReader.PositionProc = {
IF skipAlternative THEN RETURN;
IF opCode = setX THEN x ← xe + value
ELSE y ← ye + value;
reposition ← TRUE;
};
spacingProc: PressReader.SpacingProc = {
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 pressHandle.ResetSpace ELSE pressHandle.SetSpace[currentSpaceX, currentSpaceY];
};
spaceProc: PressReader.SpaceProc = {
showCharactersProc[showCharacterImmediate, 1, " "];
};
colorProc: PressReader.ColorProc = {
IF skipAlternative THEN RETURN;
SELECT opCode
FROM
setHue => pressHandle.SetHue[value];
setSaturation => pressHandle.SetSaturation[value];
setBrightness => pressHandle.SetBrightness[value];
ENDCASE => ERROR;
};
showRectangleProc: PressReader.ShowRectangleProc = {
IF skipAlternative THEN RETURN;
pressHandle.PutRectangle[x, y, width, height];
};
alternativeProc: PressReader.AlternativeProc = {
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 = {
moveToProc: PressReader.MoveToProc = {pressHandle.PutMoveTo[x: x+xe, y: y+ye]};
drawToProc: PressReader.DrawToProc = {pressHandle.PutDrawTo[x: x+xe, y: y+ye]};
drawCurveProc: PressReader.DrawCurveProc = {
pressHandle.PutCubic[cX, cY, bX, bY, aX, aY];
};
IF skipAlternative THEN RETURN;
pressHandle.StartOutline;
pressFile.GetObject[moveToProc, drawToProc, drawCurveProc];
pressHandle.EndOutline;
}; -- showObjectProc
showDotsProc: PressReader.ShowDotsProc = {
codingType, dotsPerLine, scanLines, passDots, displayDots, passLines, displayLines: INT ← 0;
scanMode: CARDINAL ← 0;
windowWidth, windowHeight: INT ← 0;
dotInfo: PressReader.Dots;
samplingInfo: LIST OF PressReader.SamplingProperty ← NIL;
setCodingProc: PressReader.SetCodingProc = {
codingType ← code;
windowWidth ← dotsPerLine ← displayDots ← dots;
windowHeight ← scanLines ← displayLines ← lines;
};
setModeProc: PressReader.SetModeProc = {scanMode ← mode};
setWindowProc: PressReader.SetWindowProc = {
passDots ← pd;
displayDots ← dd;
passLines ← pl;
displayLines ← dl;
};
setSizeProc: PressReader.SetSizeProc = {
windowWidth ← width;
windowHeight ← height;
};
setSamplingPropertiesProc: PressReader.SetSamplingPropertiesProc = {
samplingInfo ← samplingProperties;
};
dotsFollowProc: PressReader.DotsFollowProc = {
dotInfo ← dots;
};
ScratchRec: TYPE ~ RECORD [SEQUENCE length: NAT OF WORD];
scratch: REF ScratchRec;
bytesPerLine: INT ← 0;
IF skipAlternative THEN RETURN;
pressFile.GetDots[setCodingProc, setModeProc, setWindowProc, setSizeProc, setSamplingPropertiesProc, dotsFollowProc];
scratch ← NEW[ScratchRec[(dotsPerLine+3)/2]];
pressHandle.BeginScannedRectangle[
x: x, y: y,
dotsPerLine: dotsPerLine,
numberOfLines: scanLines,
width: windowWidth,
height: windowHeight,
nextLineDirection: LOOPHOLE[scanMode MOD 4],
nextDotDirection: LOOPHOLE[scanMode / 4],
coding:
SELECT codingType
FROM
0 => bitMap,
1 => bitSampled,
2 => bitBitSampled,
4 => nybbleSampled,
8 => byteSampled,
ENDCASE => ERROR
];
bytesPerLine ← (MAX[codingType, 1] * dotsPerLine + 7)/8;
scratch[bytesPerLine/2] ← 0; -- make sure array is big enough
dotInfo.file.SetIndex[INT[dotInfo.pageNumber]*bytesPerPage+dotInfo.byteOffset];
FOR i:
INT
IN [0..scanLines)
DO
TRUSTED {[] ← dotInfo.file.UnsafeGetBlock[[base: (LOOPHOLE[@scratch[0]]), startIndex: 0, count: bytesPerLine]]};
TRUSTED {pressHandle.UnsafeShowLine[@scratch[0]]};
ENDLOOP;
pressHandle.EndScannedRectangle;
}; -- showDotsProc
fontProc[0];
pressHandle.SetColor[0, 0, 0];
pressFile.GetCommands[
showCharactersProc: showCharactersProc,
fontProc: fontProc,
positionProc: positionProc,
spacingProc: spacingProc,
spaceProc: spaceProc,
colorProc: colorProc,
showRectangleProc: showRectangleProc,
alternativeProc: alternativeProc,
showObjectProc: showObjectProc,
showDotsProc: showDotsProc
];
}; -- EntityProc