Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Text /
Chapter 4 - Font Manager


Summary of the Font Manager

Pascal Summary

Constants

CONST
   systemFont = 0;
   applFont = 1;
   newYork = 2;
   geneva = 3;
   monaco = 4;
   venice = 5;
   london = 6;
   athens = 7;
   sanFran = 8;
   toronto = 9;
   cairo = 11;
   losAngeles = 12;
   times = 20;
   helvetica = 21;
   courier = 22;
   symbol = 23;
   mobile = 24;

Data Types

TYPE FMInput =
PACKED RECORD
   family:        Integer;       {font family ID}
   size:          Integer;       {requested point size}
   face:          Style;         {requested font style}
   needBits:      Boolean;       {if bitmaps need to be constructed}
   device:        Integer;       {device driver ID}
   numer:         Point;         {scaling factor numerators}
   denom:         Point;         {scaling factor denominators}
END;
TYPE FMOutput =
PACKED RECORD
   errNum:        Integer;       {reserved for internal use}
   fontHandle:    Handle;        {handle to font}
   bold:          Byte;          {for drawing of bold style}
   italic:        Byte;          {for drawing of italic style}
   ulOffset:      Byte;          {for drawing of underline style}
   ulShadow:      Byte;          {for drawing of underline shadow style}
   ulThick:       Byte;          {for drawing of underline thickness}
   shadow:        Byte;          {for drawing of shadow style}
   extra:         SignedByte;    {# of pixels added for styles}
   ascent:        Byte;          {ascent measurement of font}
   descent:       Byte;          {descent measurement of font}
   widMax:        Byte;          {maximum width of glyphs in font}
   leading:       SignedByte;    {leading value for font}
   fOutCurStyle:  Byte;          {actual output font style}
   numer:         Point;         {scaling factor numerators}
   denom:         Point;         {scaling factor denominators}
END;
Type WidthTable =
PACKED RECORD
   tabData:       ARRAY [1..256] OF Fixed;
                                 {character widths}
   tabFont:       Handle;        {font record used to build table}
   sExtra:        LongInt;       {extra line spacing}
   style:         LongInt;       {extra line spacing due to style}
   fID:           Integer;       {font family ID}
   fSize:         Integer;       {font size request}
   face:          Integer;       {style (face) request}
   device:        Integer;       {device requested}
   inNumer:       Point;         {scale factors requested}
   inDenom:       Point;         {scale factors requested}
   aFID:          Integer;       {actual font family ID for table}
   fHand:         Handle;        {family record used to build up table}
   usedFam:       Boolean;       {used fixed-point family widths}
   aFace:         Byte;          {actual face produced}
   vOutput:       Integer;       {vertical scale output value}
   hOutput:       Integer;       {horizontal scale output value}
   vFactor:       Integer;       {vertical scale output value}
   hFactor:       Integer;       {horizontal scale output value}
   aSize:         Integer;       {size of actual font used}
   tabSize:       Integer;       {total size of table}
END;
TYPE FontRec =
RECORD
   fontType:      Integer;       {font type}
   firstChar:     Integer;       {character code of first glyph}
   lastChar:      Integer;       {character code of last glyph}
   widMax:        Integer;       {maximum glyph width}
   kernMax:       Integer;       {negative of maximum glyph kern}
   nDescent:      Integer;       {negative of descent}
   fRectWidth:    Integer;       {width of font rectangle}
   fRectHeight:   Integer;       {height of font rectangle}
   owTLoc:        Integer;       {location of width/offset table}
   ascent:        Integer;       {ascent}
   descent:       Integer;       {descent}
   leading:       Integer;       {leading}
   rowWords:      Integer;       {row width of bit image / 2 }
END;
TYPE FamRec =
RECORD
   ffFlags:       Integer;       {flags for family}
   ffFamID:       Integer;       {family ID number}
   ffFirstChar:   Integer;       {ASCII code of 1st character}
   ffLastChar:    Integer;       {ASCII code of last character}
   ffAscent:      Integer;       {maximum ascent for 1 pt font}
   ffDescent:     Integer;       {maximum descent for 1 pt font}
   ffLeading:     Integer;       {maximum leading for 1 pt font}
   ffWidMax:      Integer;       {maximum widMax for 1 pt font}
   ffWTabOff:     LongInt;       {offset to width table}
   ffKernOff:     LongInt;       {offset to kerning table}
   ffStylOff:     LongInt;       {offset to style-mapping table}
   ffProperty:    ARRAY [1..9] OF Integer;
                                 {style property info}
   ffIntl:        ARRAY [1..2] OF Integer;
                                 {for international use}
   ffVersion:     Integer;       {version number}
END;
TYPE FontAssoc = 
RECORD
   numAssoc:      Integer;       {number of entries - 1}
END;
TYPE AsscEntry =
RECORD
   fontSize:      Integer;       {point size of font}
   fontStyle:     Integer;       {style of font}
   fontID:        Integer;       {font resource ID}
END;
TYPE WidTable = 
RECORD
   numWidths:     Integer;       {number of entries - 1}
END;
TYPE WidEntry =
RECORD
   widStyle:      Integer;       {style that entry applies to}
END;
TYPE StyleTable =
RECORD
   fontClass:     Integer;       {the font class of this table}
   offset:        LongInt;       {offset to glyph-encoding subtable}
   reserved:      LongInt;       {reserved}
   indexes:       PACKED ARRAY [0..47] OF SignedByte;
                                 {indexes into the font suffix name }
                                 { table that follows this table}
END;
TYPE NameTable = 
RECORD
   stringCount:   Integer;       {number of entries}
   baseFontName:  Str255;        {font family name}
END;
TYPE KernTable = 
RECORD
   numKerns:      Integer;    {number of subtable entries}
END;
TYPE KernEntry =
RECORD
   kernStyle:     Integer;    {style the entry applies to}
   kernLength:    Integer;    {length of this entry}
END;
TYPE KernPair =
RECORD
   kernFirst:     Char;       {Code of 1st character of kerned pair}
   kernSecond:    Char;       {Code of 2nd character of kerned pair}
   kernWidth:     Integer;    {kerning value in 1pt fixed format}
END;
Type FMetricRec =
RECORD
   ascent:        Fixed;         {baseline to top}
   descent:       Fixed;         {baseline to bottom}
   leading:       Fixed;         {leading between lines}
   widMax:        Fixed;         {maximum glyph width}
   wTabHandle:    Handle;        {handle to global width table}
END;

Routines

Initializing the Font Manager

PROCEDURE InitFonts;

Getting Font Information

PROCEDURE GetFontName    (familyID: Integer;VAR theName: Str255);
PROCEDURE GetFNum        (theName: Str255;VAR familyID: Integer);
FUNCTION RealFont        (fontNum: Integer;size: Integer): Boolean;

Using the Current, System, and Application Fonts

FUNCTION GetDefFontSize: Integer;
FUNCTION GetSysFont: Integer;
FUNCTION GetAppFont: Integer;

Getting the Characteristics of a Font

PROCEDURE FontMetrics    (theMetrics: FMetricRec);
FUNCTION OutlineMetrics  (byteCount: Integer; textPtr: UNIV Ptr;
                          numer: Point; denom: Point; VAR yMax: Integer;
                          VAR yMin: Integer; awArray: FixedPtr; 
                          lsbArray: FixedPtr; boundsArray: RectPtr): 
OSErr; 

Enabling Fractional Glyph Widths

PROCEDURE SetFractEnable (fractEnable: Boolean);

Disabling Font Scaling

PROCEDURE SetFScaleDisable(fscaleDisable: Boolean);

Favoring Outline Fonts Over Bitmapped Fonts

PROCEDURE SetOutlinePreferred
                         (outlinePreferred: Boolean);
FUNCTION GetOutlinePreferred: Boolean;
FUNCTION IsOutline       (numer,denom: Point) : Boolean;

Scaling Outline Fonts

PROCEDURE SetPreserveGlyph (preserveGlyph: Boolean);
FUNCTION GetPreserveGlyph  : Boolean;

Accessing Information About a Font

FUNCTION FMSwapFont      (inRec: FMInput): FMOutPtr;

Handling Fonts in Memory

PROCEDURE SetFontLock    (lockFlag: Boolean);
FUNCTION FlushFonts      : OSErr;

C Summary

Constants

enum {
   systemFont = 0,
   applFont = 1,
   newYork = 2,
   geneva = 3,
   monaco = 4,
   venice = 5,
   london = 6,
   athens = 7,
   sanFran = 8,
   toronto = 9,
   cairo = 11,
   losAngeles = 12,
   times = 20,
   helvetica = 21,
   courier = 22,
   symbol = 23,
   mobile = 24,
};

Data Types

struct FMInput {
   short          family;        /*font family ID*/
   short          size;          /*requested point size*/
   Style          face;          /*requested font style*/
   Boolean        needBits;      /*if bitmaps need to be constructed*/
   short          device;        /*device driver ID*/
   Point          numer;         /*scaling factor numerators*/
   Point          denom;         /*scaling factor denominators*/
};
typedef struct FMInput FMInput;
struct FMOutput {
   short          errNum;        /*reserved for internal use*/
   Handle         fontHandle;    /*handle to font*/
   unsigned char  bold;          /*for drawing of bold style*/
   unsigned char  italic;        /*for drawing of italic style*/
   unsigned char  ulOffset;      /*for drawing of underline style*/
   unsigned char  ulShadow;      /*for drawing of underline shadow style*/
   unsigned char  ulThick;       /*for drawing of underline thickness*/
   unsigned char  shadow;        /*for drawing of shadow style*/
   char           extra;         /*# of pixels added for styles*/
   unsigned char  ascent;        /*ascent measurement of font*/
   unsigned char  descent;       /*descent measurement of font*/
   unsigned char  widMax;        /*maximum width of glyphs in font*/
   char           leading;       /*leading value for font*/
   char           fOutCurStyle;  /*actual output font style*/
   Point          numer;         /*scaling factor numerators*/
   Point          denom;         /*scaling factor denominators*/
};
typedef struct FMOutput FMOutput;
struct WidthTable {
   Fixed          tabData[256];
                                 /*character widths*/
   Handle         tabFont;       /*font record used to build table*/
   long           sExtra;        /*extra line spacing*/
   long           style;         /*extra line spacing due to style*/
   short          fID;           /*font family ID*/
   short          fSize;         /*font size request*/
   short          face;          /*style (face) request*/
   short          device;        /*device requested*/
   Point          inNumer;       /*scale factors requested*/
   Point          inDenom;       /*scale factors requested*/
   short          aFID;          /*actual font family ID for table*/
   Handle         fHand;         /*family record used to build up table*/
   Boolean        usedFam;       /*used fixed-point family widths*/
   unsigned char  aFace;         /*actual face produced*/
   short          vOutput;       /*vertical scale output value*/
   short          hOutput;       /*horizontal scale output value*/
   short          vFactor;       /*vertical scale output value*/
   short          hFactor;       /*horizontal scale output value*/
   short          aSize;         /*size of actual font used*/
   short          tabSize;       /*total size of table*/
};
typedef struct WidthTable WidthTable;
struct FontRec {
   short          fontType;      /*font type*/
   short          firstChar;     /*character code of first glyph*/
   short          lastChar;      /*character code of last glyph*/
   short          widMax;        /*maximum glyph width*/
   short          kernMax;       /*negative of maximum glyph kern*/
   short          nDescent;      /*negative of descent*/
   short          fRectWidth;    /*width of font rectangle*/
   short          fRectHeight;   /*height of font rectangle*/
   short          owTLoc;        /*location of width/offset table*/
   short          ascent;        /*ascent*/
   short          descent;       /*descent*/
   short          leading;       /*leading*/
   short          rowWords;      /*row width of bit image / 2 */
};
typedef struct FontRec FontRec;
struct FamRec {
   short          ffFlags;       /*flags for family*/
   short          ffFamID;       /*family ID number*/
   short          ffFirstChar;   /*ASCII code of 1st character*/
   short          ffLastChar;    /*ASCII code of last character*/
   short          ffAscent;      /*maximum ascent for 1 pt font*/
   short          ffDescent;     /*maximum descent for 1 pt font*/
   short          ffLeading;     /*maximum leading for 1 pt font*/
   short          ffWidMax;      /*maximum widMax for 1 pt font*/
   long           ffWTabOff;     /*offset to width table*/
   long           ffKernOff;     /*offset to kerning table*/
   long           ffStylOff;     /*offset to style-mapping table*/
   short          ffProperty[9]; /*style property info*/
   short          ffIntl[2];     /*for international use*/
   short          ffVersion;     /*version number*/
};
typedef struct FamRec FamRec;
struct FontAssoc {
   short          numAssoc;      /*number of entries - 1*/
};
typedef struct FontAssoc FontAssoc;
struct AsscEntry {
   short          fontSize;      /*point size of font*/
   short          fontStyle;     /*style of font*/
   short          fontID;        /*font resource ID*/
};
typedef struct AsscEntry AsscEntry;
struct WidTable {
   short          numWidths;     /*number of entries - 1*/
};
typedef struct WidTable WidTable;
struct WidEntry {
   short          widStyle;      /*style that entry applies to*/
};
typedef struct WidEntry WidEntry;
struct StyleTable {
   short          fontClass;     /*the font class of this table*/
   long           offset;        /*offset to glyph-encoding subtable*/
   long           reserved;      /*reserved*/
   char           indexes[47];   /*indexes into the font suffix name table*/
};
typedef struct StyleTable StyleTable;
struct NameTable {
   short          stringCount;   /*number of entries*/
   Str255         baseFontName;  /*font family name*/
};
typedef struct NameTable NameTable;
struct KernTable{
   short          numKerns;      /*number of subtable entries*/
};
typedef struct KernTable KernTable;
struct KernEntry {
   short          kernLength;    /* length of this entry*/
   short          kernStyle;     /* style this entry applies to*/
}
typedef struct KernEntry KernEntry;
struct KernPair {
   char        kernFirst;        /*Code of 1st character of kerned pair*/
   char        kernSecond;       /*Code of 2nd character of kerned pair*/
   short       kernWidth;        /*kerning value in 1pt fixed format*/
};
typedef struct KernPair KernPair;
struct FMetricRec {
   Fixed          ascent;        /*baseline to top*/
   Fixed          descent;       /*baseline to bottom*/
   Fixed          leading;       /*leading between lines*/
   Fixed          widMax;        /*maximum glyph width*/
   Handle         wTabHandle;    /*handle to global width table*/
};
typedef struct FMetricRec FMetricRec;

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996