-- PressFontFormat.mesa
-- modified by Michael Plass on August 11, 1982 8:43 am
-- modified by Maureen Stone 30-Dec-81 17:14:31
-- modified by Geschke on November 5, 1979 4:42 PM

DIRECTORY
 Mopcodes;


PressFontFormat: DEFINITIONS =
BEGIN

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

-- the IndexHeader corresponds to Structure IX pp5 Font Formats Manual.

IndexHeader: TYPE = MACHINE DEPENDENT RECORD[
 type: IndexType,
 length: [0..4096)
 ];
--length in words, counting this one

IndexType: TYPE = MACHINE DEPENDENT {
 end,name,splines,chars,widths,
 unassigned1,unassigned2,unassigned3,unassigned4,
 unassigned5,unassigned6,unassigned7,unassigned8,
 unassigned9,unassigned10,unassigned11};

bcplMaxLength: CARDINAL = 255;
BcplSTRING: TYPE = MACHINE DEPENDENT RECORD[
 body: PACKED ARRAY[0..bcplMaxLength] OF CHARACTER
  --body[0] is the length of the string
 ];

-- The RawIndex corresponds to the five kinds of index entries.
-- EndSegment, NameSegment, SplineSegment, CharacterSegment, and WidthSegment.

RawIndex: TYPE = MACHINE DEPENDENT RECORD
[hdr: IndexHeader,
variantPart: SELECT COMPUTED IndexType FROM
end => NULL,
name =>
[
fill: Byte,
code: FontCode, -- local, unique name for font
fontname: BcplSTRING
],
splines, widths =>
[
family: FontCode,
face: FaceType,
bc, ec: CHARACTER,      -- first and last character
size: CARDINAL,       -- Font size (10 micron units)
rotation: CARDINAL,      -- Rotation (anti clockwise)
startaddress: bcplLONGPOINTER,  -- Starting address of data part
length: bcplLONGCARDINAL    -- Length of data part
],
chars =>
[
family: FontCode,
face: FaceType,
bc, ec: CHARACTER,      -- first and last character
size: CARDINAL,       -- Font size (10 micron units)
rotation: CARDINAL,      -- Rotation (anti clockwise)
startaddress: bcplLONGPOINTER,  -- Starting address of data part
length: bcplLONGCARDINAL,    -- Length of data part
resolutionx: CARDINAL,     -- 10*(number of bits/inch)
resolutiony: CARDINAL     -- ditto
],
ENDCASE
];

FontCode: TYPE = Byte;
FaceType: TYPE = Byte;
FaceWeight: TYPE = {L,M,B};
FaceSlant: TYPE = {I,R};
FaceWidth: TYPE = {C,R,E};

CharBboxDesc: TYPE = LONG DESCRIPTOR FOR ARRAY OF BoundingBox;
CharDirDesc: TYPE = LONG DESCRIPTOR FOR ARRAY OF bcplLONGPOINTER;

BoundingBox: TYPE = MACHINE DEPENDENT RECORD[
xwidth, ywidth: bcplFraction,
BBox, BBoy: INTEGER, BBdx, BBdy: CARDINAL];


-- BCPL data structures for spline definitions

SplineDataDesc: TYPE = LONG DESCRIPTOR FOR ARRAY OF BcplSplineData;
SplineDirDesc: TYPE = CharDirDesc;

BcplSplineData: TYPE = MACHINE DEPENDENT RECORD[
 xwidth, ywidth, bbox, bboy, rightx, topy: BcplREAL];

missingCharValueBits: bcplLONGCARDINAL = [highhalf: 0, lowhalf: 177777B];
missingCharValue: BcplREAL = LOOPHOLE[missingCharValueBits];

SplineCommandCode: TYPE = MACHINE DEPENDENT {
 MoveTo, DrawTo, DrawCurve, NewObject, EndDefinition
 };

BcplSplineCommand: TYPE = MACHINE DEPENDENT RECORD
[type: BcplCommandCode,
variantPart: SELECT OVERLAID SplineCommandCode FROM
MoveTo, DrawTo => [x,y: BcplREAL],
DrawCurve => [x0,y0, x1,y1, x2,y2: BcplREAL],
NewObject, EndDefinition => NULL,
ENDCASE
];

BcplREAL: TYPE = MACHINE DEPENDENT RECORD[
sign: [0..1], exp: [0..377B], sigbit: [0..1], topmantissa: [0..77B],
restofmantissa: [0..177777B]];

BcplCommandCode: TYPE = INTEGER;
moveToCode: BcplCommandCode = 1;
drawToCode: BcplCommandCode = 2;
drawCurveCode: BcplCommandCode = 3;
newObjectCode: BcplCommandCode = -1;
endSplineCode: BcplCommandCode = -2;

-- BCPL data structures for width definitions

BcplWidthSegment: TYPE = MACHINE DEPENDENT RECORD[
 FBBox, FBBoy, FBBdx, FBBdy: CARDINAL,
 XWidthFixed, YWidthFixed: BOOLEAN,
 fill: PACKED ARRAY [0..14) OF BOOLEAN,
 widthData: ARRAY [0..0) OF CARDINAL
 ];

-- converting from the doubleword world of Mesa to BCPL and conversely

LongCardinalFromBcplLongPointer: PROCEDURE [bp: bcplLONGPOINTER] RETURNS [p: LONG CARDINAL] =
MACHINE CODE BEGIN Mopcodes.zEXCH; END;

MesaToBcplLongCardinal: PROCEDURE [c: LONG CARDINAL] RETURNS [bc: bcplLONGCARDINAL] =
MACHINE CODE BEGIN Mopcodes.zEXCH; END;

BcplToMesaLongCardinal: PROCEDURE [bc: bcplLONGCARDINAL] RETURNS [c: LONG CARDINAL] =
MACHINE CODE BEGIN Mopcodes.zEXCH; END;

MesaToBcplFraction: PROCEDURE [f: Fraction] RETURNS [bf: bcplFraction] =
MACHINE CODE BEGIN Mopcodes.zEXCH; END;

BcplToMesaFraction: PROCEDURE [bf: bcplFraction] RETURNS [f: Fraction] =
MACHINE CODE BEGIN Mopcodes.zEXCH; END;


bcplLONGPOINTER: TYPE = MACHINE DEPENDENT RECORD[
highhalf, lowhalf: WORD];

bcplLONGCARDINAL: TYPE = MACHINE DEPENDENT RECORD[
highhalf, lowhalf: WORD];

bcplFraction: TYPE = MACHINE DEPENDENT RECORD[
integerpart, fractionpart: WORD];

Fraction: TYPE = LONG INTEGER;

RasterPointer: TYPE = LONG POINTER TO RasterDimension;
RasterDimension: TYPE = MACHINE DEPENDENT RECORD[height: [0..77B], width: [0..1777B]];

-- The private record structure for the font reader, for those who want to dig into the bits for themselves.
CharRepresentation: TYPE = {raster, outline, widthsOnly};
FontPrivateRec: PUBLIC TYPE = RECORD [
base: LONG POINTER, -- For checking against handle.base
descriptors: SELECT rep: CharRepresentation FROM
raster => [
indexEntry: LONG POINTER TO chars RawIndex,
dataDesc: CharBboxDesc,
dirDesc: CharDirDesc,
rasterStart, rasterEnd: LONG CARDINAL
],
outline => [
indexEntry: LONG POINTER TO splines RawIndex,
dataDesc: SplineDataDesc,
dirDesc: SplineDirDesc,
commandStart, commandEnd: LONG CARDINAL
],
widthsOnly => [
indexEntry: LONG POINTER TO widths RawIndex,
widthSeg: LONG POINTER TO BcplWidthSegment,
xWidthDesc: LONG DESCRIPTOR FOR ARRAY OF CARDINAL,
yWidthDesc: LONG DESCRIPTOR FOR ARRAY OF CARDINAL
],
ENDCASE
];


END.

Michael Plass on August 5, 1982 8:41 am. Extracted from BcplFontFileDefs.