PressFontWriterCmds:
PROGRAM
IMPORTS JaMOps, PressFontWriter, Rope, TJaMGraphicsPrivate
= BEGIN
ROPE: TYPE = Rope.ROPE;
Frame: TYPE = JaMInternal.Frame;
fontFile: PressFontWriter.NewFont;
PopRope:
PROCEDURE [f: Frame]
RETURNS [rope:
ROPE] = {
s: string JaMBasic.Object ← JaMOps.PopString[f.opstk];
C:
PROC[c:
CHAR]
RETURNS [
BOOLEAN] =
{t[t.length]𡤌 t.length ← t.length+1; RETURN[FALSE]};
t: REF TEXT ← NEW[TEXT[s.length]];
t.length ← 0;
JaMOps.StringForAll[s, C];
rope ← Rope.FromRefText[t];
};
PushRope:
PROCEDURE [f: Frame, rope:
ROPE] = {
JaMOps.Push[
f.opstk,
JaMOps.MakeString[LOOPHOLE[rope.ToRefText[], LONG STRING]]
];
};
MakeSDFile:
PROCEDURE [f: Frame] = {
face: [0..255) ← JaMOps.PopInteger[f.opstk];
family: ROPE ← PopRope[f];
fileName: ROPE ← PopRope[f];
IF fontFile # NIL THEN fontFile.Close[];
fontFile ← PressFontWriter.Create[fileName, outline, family, face, 0, 0, 0C, 377C];
};
CloseSDFile:
PROCEDURE [f: Frame] = {
IF fontFile # NIL THEN fontFile.Close[];
fontFile ← NIL;
};
WriteSDChar:
PROCEDURE [f: Frame] = {
body: JaMBasic.Object ← JaMOps.Pop[f.opstk];
char: CHAR;
Paint: PressFontWriter.PaintProc = {
TJaMGraphicsPrivate.EstablishNonViewerContext[f, context];
JaMOps.Execute[f, body];
TJaMGraphicsPrivate.ForgetNonViewerContext[f];
};
charInfo: PressFontWriter.CharInfo;
charInfo.maxY ← JaMOps.PopReal[f.opstk];
charInfo.maxX ← JaMOps.PopReal[f.opstk];
charInfo.minY ← JaMOps.PopReal[f.opstk];
charInfo.minX ← JaMOps.PopReal[f.opstk];
charInfo.widthY ← JaMOps.PopReal[f.opstk];
charInfo.widthX ← JaMOps.PopReal[f.opstk];
char ← PopRope[f].Fetch[0];
PressFontWriter.PaintChar[fontFile, char, charInfo, Paint];
};
ConvertAcsiiCharToInteger:
PROCEDURE [f: Frame] = {
char: CHAR ← PopRope[f].Fetch[0];
byte: [0..256) ← char - 000C;
JaMOps.PushInteger[f.opstk, byte];
};
ConvertIntegerToAcsiiChar:
PROCEDURE [f: Frame] = {
byte: [0..256) ← JaMOps.PopInteger[f.opstk];
PushRope[f, Rope.FromChar[000C + byte]];
};
ConvertIntegerToAcsiiString:
PROCEDURE [f: Frame] = {
byte: [0..256) ← JaMOps.PopInteger[f.opstk];
b0: CHAR ← '0 + byte MOD 8;
b1: CHAR ← '0 + byte/8 MOD 8;
b2: CHAR ← '0 + byte/64 MOD 8;
IF 000C + byte IN (Rope.SP..'}] AND 000C + byte # '\" AND 000C + byte # '\\ THEN PushRope[f, Rope.FromChar[000C + byte]]
ELSE PushRope[f, Rope.Cat["\\", Rope.FromChar[b2], Rope.FromChar[b1], Rope.FromChar[b0]]];
};
JaMOps.RegisterExplicit[JaMOps.defaultFrame, "MakeSDFile", MakeSDFile];
JaMOps.RegisterExplicit[JaMOps.defaultFrame, "CloseSDFile", CloseSDFile];
JaMOps.RegisterExplicit[JaMOps.defaultFrame, "WriteSDChar", WriteSDChar];
JaMOps.RegisterExplicit[JaMOps.defaultFrame, ".cvaci", ConvertAcsiiCharToInteger];
JaMOps.RegisterExplicit[JaMOps.defaultFrame, ".cviac", ConvertIntegerToAcsiiChar];
JaMOps.RegisterExplicit[JaMOps.defaultFrame, ".cvias", ConvertIntegerToAcsiiString];
END.