ListFontsInPressFileImpl.mesa
Copyright (C) 1983, Xerox Corporation. All rights reserved.
Last edited by Plass on August 29, 1984 9:29:41 am PDT
Last Edited by: Beach, February 24, 1984 1:32:02 pm PST
DIRECTORY IO, PressReader, Real, Rope, Commander;
ListFontsInPressFileImpl: CEDAR PROGRAM
IMPORTS IO, PressReader, Real, Commander = BEGIN
ROPE: TYPE = Rope.ROPE;
Break: PROC [char: CHAR] RETURNS [IO.CharClass] = {
IF char = '← THEN RETURN [break];
IF char = ' OR char = '  OR char = ', OR char = '; OR char = '\n THEN RETURN [sepr];
RETURN [other];
};
GetToken: PROC [stream: IO.STREAM] RETURNS [token: ROPENIL] = {
token ← stream.GetTokenRope[Break ! IO.EndOfStream => CONTINUE].token;
};
ListFonts: Commander.CommandProc = TRUSTED {
fileName: ROPE ← GetToken[IO.RIS[cmd.commandLine]];
pressFile: PressReader.Handle ← PressReader.OpenPressFile[fileName !
PressReader.PressReaderError => {
cmd.out.PutRope[
SELECT errorCode FROM
FileNotAPressFile => "File not a Press file!\n",
FileNotAvailableForRead => "File not readable!\n",
ENDCASE => ERROR
];
GOTO Quit;
}
];
log: IO.STREAM ~ cmd.out;
FontPrinter: PressReader.FontEntryProc = {
texDesignSize: REAL ← -1.0;
log.PutRope["\nFamily name: "];
log.PutRope[fontDirectoryEntry.family];
IF fontDirectoryEntry.face.encoding < 18 THEN {
log.PutF["\n Face: %g (%g%g%g)",
IO.int[fontDirectoryEntry.face.encoding],
IO.rope[SELECT fontDirectoryEntry.face.weight FROM
medium => "M",
bold => "B",
light => "L",
ENDCASE => ERROR],
IO.rope[SELECT fontDirectoryEntry.face.slope FROM
regular => "R",
italic => "I",
ENDCASE => ERROR],
IO.rope[SELECT fontDirectoryEntry.face.expansion FROM
regular => "R",
condensed => "C",
expanded => "E",
ENDCASE => ERROR]];
log.PutF[" = Weight: %g, Slope: %g, Expansion: %g",
IO.rope[SELECT fontDirectoryEntry.face.weight FROM
medium => "medium",
bold => "bold",
light => "light",
ENDCASE => ERROR],
IO.rope[SELECT fontDirectoryEntry.face.slope FROM
regular => "regular",
italic => "italic",
ENDCASE => ERROR],
IO.rope[SELECT fontDirectoryEntry.face.expansion FROM
regular => "regular",
condensed => "condensed",
expanded => "expanded",
ENDCASE => ERROR]];
}
ELSE {
texDesignSize ← (254.0-fontDirectoryEntry.face.encoding)/2.0;
log.PutF["\n Face: %g == TEX design size %g",
IO.int[fontDirectoryEntry.face.encoding],
IO.real[texDesignSize]
];
};
IF fontDirectoryEntry.size >= 0 THEN
log.PutF["\n Size: %g points", IO.int[fontDirectoryEntry.size]]
ELSE
log.PutF["\n Size: %g micas (%g points)", IO.int[-fontDirectoryEntry.size], IO.real[(-fontDirectoryEntry.size)*72/2540.0]];
IF texDesignSize>0 AND fontDirectoryEntry.size<0.0 THEN {
magnification: REAL ← -fontDirectoryEntry.size*72.27/(2540*texDesignSize);
magnification ← Real.RoundLI[magnification*100]/100.0;
log.PutF[" (magnification %g)", IO.real[magnification]];
};
log.PutF["\n Rotation: %g", IO.int[fontDirectoryEntry.rotation]];
}; -- FontPrinter
pressFile.GetFonts[FontPrinter];
pressFile.ClosePressFile[];
EXITS Quit => NULL;
};
Commander.Register[
key: "ListFontsInPressFile",
proc: ListFonts,
doc: "Lists the fonts used in the named press file"
];
END.