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 / Font Manager Reference
Routines / Accessing Information About a Font


FMSwapFont

The FMSwapFont function returns a handle to a font and information about that font. This function is used by QuickDraw and other parts of the system software to access
font handles.

FUNCTION FMSwapFont (inRec: FMInput): FMOutPtr;
inRec
A font input record, which contains the font family ID, the style requested, scaling factors, and other information.
DESCRIPTION
The FMSwapFont function takes a font request and returns a pointer to a font output record. FMSwapFont is the heart of the Font Manager: it does all of the hard work of preparing font data for text measuring and text drawing.

The inRec parameter specifies the characteristics of the font that is requested. QuickDraw fills in the fields of the CurFmInput global variable and passes that record in this parameter.

The font output record contains a handle to a font resource that fulfills the font request, along with information about the font, such as the ascent, descent, and leading measurements. You supply the FMSwapFont function with the font request in the inRec parameter, using a font input record, and the Font Manager returns the font handle and the other information in a font output record.

QuickDraw calls the FMSwapFont function every time a QuickDraw text routine is used. If you want to call the FMSwapFont function in order to get a handle to a font resource or information about that font, you must build a font input record and then use the pointer returned to access the resulting font output record.

You cannot assume that the font resource pointed to by the fontHandle field of the font output record returned by this function is of any particular type, such as 'NFNT' or 'sfnt'. If you need to access specific information in the font resource, call the Resource Manager procedure GetResInfo with the handle returned in the font output record to determine the font resource type.

IMPORTANT
The pointer to the font output record returned as the value of FMSwapFont points to a record allocated in low memory by the Font Manager. The same record is reused for each call made to FMSwapFont. Do not free the memory allocated for this record.
ASSEMBLY-LANGUAGE INFORMATION
The trap macro for the FMSwapFont function is
Trap macro
_FMSwapFont

SEE ALSO
For more information about the font input record, see "How QuickDraw Requests a Font" on page 4-16. For more information about the font output record, see
"How the Font Manager Responds to a Font Request" on page 4-17. For descriptions
of the records themselves, see "The Font Input Record" on page 4-36 and "The Font Output Record" on page 4-37.

The GetResInfo procedure is described in the Resource Manager chapter in
Inside Macintosh: More Macintosh Toolbox.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996