|##########|
|#MAGIC   #|CLABLNFE
|#PROJECT #|""
|#PATHS   #|"StdProject"
|#FLAGS   #|xx-x-x--x---x-x-----------------
|#USERSW  #|--------------------------------
|#USERMASK#|--------------------------------
|#SWITCHES#|x-xx-x----------
|##########|
DEFINITION MODULE DiskFont;

(* $A- *)
FROM System   IMPORT BITSET,BPTR,SysStringPtr,Regs;
FROM Exec     IMPORT Node,LibraryPtr;
FROM Graphics IMPORT FontGrp,TextAttr,TTextAttr;

CONST
  maxFontPath           = 256;
  maxFontName           = 32;
  fchId                 = $0F00;
  dfhId                 = $0F80;

TYPE
  AvailFontTypes        = (memory,disk,scaled,af15=15);
  AvailFontTypeSet      = SET OF AvailFontTypes;
  FontContents          = RECORD
                            fileName : ARRAY [maxFontPath] OF CHAR;
                            ySize    : CARDINAL;
                            style    : FontStyleSet;
                            flags    : FontFlagSet;
                          END;
  TFontContents         = RECORD
                            fileName : ARRAY [maxFontPath-2] OF CHAR;
                            tagCount : CARDINAL;
                            ySize    : CARDINAL;
                            style    : FontStyleSet;
                            flags    : FontFlagSet;
                          END;

  FontContentsHeaderPtr = POINTER TO FontContentsHeader;
  FontContentsHeader    = RECORD
                            fileId     : CARDINAL;
                            numEntries : CARDINAL;
                          END;


  DiskFontHeaderPtr     = POINTER TO DiskFontHeader;
  DiskFontHeader        = RECORD OF Node
                            fileId    : CARDINAL;
                            revision  : CARDINAL;
                            segment   : BPTR;
                            name      : ARRAY [maxFontName] OF CHAR;
                            tf        : TextFont;
                          END;

  AvailFont             = RECORD
                            type      : AvailFontTypeSet;
                            attr      : TextAttr;
                          END;
  TAvailFont            = RECORD
                            type      : AvailFontTypeSet;
                            attr      : TTextAttr;
                          END;

  AvailFontHeader       = RECORD
                            numEntries  : CARDINAL;
                          END;

  AvailFontHeaderPtr    = POINTER TO AvailFontHeader;

VAR
  DiskFontBase   : LibraryPtr;

LIBRARY DiskFontBase BY -36
  PROCEDURE AvailFonts(buffer IN A0 : ANYPTR;
                       len    IN D0 : LONGINT;
                       modus  IN D1 : BITSET):LONGINT;

LIBRARY DiskFontBase BY -48
  PROCEDURE DisposeFontContents(header IN A1 : FontContentsHeaderPtr);

LIBRARY DiskFontBase BY -42
  PROCEDURE NewFontContents(fontsLock IN A0 : ANYPTR;
                            name      IN A1 : SysStringPtr):FontContentsHeaderPtr;

LIBRARY DiskFontBase BY -30
  PROCEDURE OpenDiskFont(REF tAttr IN A0 : TextAttr):TextFontPtr;

LIBRARY DiskFontBase BY -54
  PROCEDURE NewScaledDiskFont(    font  IN A0 : TextFontPtr;
                              REF tAttr IN A1 : TextAttr):DiskFontHeaderPtr;


GROUP
  DiskFontGrp     =  AvailFonts,OpenDiskFont,Graphics.FontGrp,
                     AvailFontTypes,AvailFontTypeSet,DiskFontHeaderPtr;

  All             =  DiskFontGrp,maxFontPath,maxFontName,fchId,dfhId,
                     FontContents,FontContentsHeader,FontContentsHeaderPtr,
                     DiskFontHeader,AvailFont,AvailFontHeader,
                     AvailFontHeaderPtr,DisposeFontContents,NewFontContents,
                     NewScaledDiskFont;

END DiskFont.

