DEFINITION MODULE pxlreader;

(* Author:         Andrew Trevorrow
   Implementation: Modula-2 under VAX/UNIX 4.2 BSD
   Date Started:   June, 1986

   Description:
   Routines for reading random bytes and words from a PXL font file.
   DVItoVDU is currently the only client.
*)

EXPORT QUALIFIED
   OpenPXLFile,
   MoveToPXLByte, MoveToPXLDirectory,
   GetPXLByte, GetTwoPXLBytes, SignedPXLPair, SignedPXLQuad,
   ClosePXLFile;

PROCEDURE OpenPXLFile (filename : ARRAY OF CHAR) : BOOLEAN;
(* Return TRUE if given PXL file is successfully opened.
   This routine must be called before any of the following routines.
   Only one PXL file can be open at any given time.
*)

PROCEDURE MoveToPXLByte (offset : CARDINAL);
(* Client can move to a particular byte in the opened PXL file by supplying
   the desired offset (first byte is at offset 0).
   GetPXLByte and the other byte grabbing routines read from this position
   and then advance an appropriate number of bytes.
*)

PROCEDURE MoveToPXLDirectory;
(* Move to starting byte of the font directory. *)

PROCEDURE GetPXLByte () : INTEGER;
(* Return unsigned value of byte at current position and advance 1 byte. *)

PROCEDURE GetTwoPXLBytes () : INTEGER;
(* Return unsigned value in next 2 bytes and advance 2 bytes. *)

PROCEDURE SignedPXLPair () : INTEGER;
(* Return possibly signed value in next 2 bytes and advance 2 bytes. *)

PROCEDURE SignedPXLQuad () : INTEGER;
(* Return possibly signed value in next 4 bytes and advance 4 bytes. *)

PROCEDURE ClosePXLFile;
(* Close the currently open PXL file. *)

END pxlreader.
