Important: The information in this document is obsolete and should not be used for new development.
Using Width Tables
When the Font Manager responds to a request to make a font available, the font resource is loaded into memory and the Font Manager allocates memory for various tables that are needed to use the font. To make font usage more efficient, the Font Manager maintains a cache of the tables for the most recently used fonts, so that it does not have to reread the resources and rebuild the tables more often than necessary. The Font Manager can cache the tables for up to 12 fonts. For outline fonts, the cached information includes the width tables and any bitmaps that have been created from the outlines.The global width table contains the widths of all the glyphs of one font. If you are measuring text to be displayed on the screen, you can use the QuickDraw procedure
MeasureText
to determine glyph widths; however, if you are printing text and need to determine glyph widths, you have to use widths from the global width table. TheOutlineMetrics
function returns the individual widths of glyphs for an outline font and theFontMetrics
procedure returns the width of the largest glyph in a bitmapped font. You can also directly access the global width table, which is defined by theWidthTable
data type. This data type is described in the section "The Global Width Table" beginning on page 4-39.To use the global width table, you can get a handle to it from the
FontMetrics
procedure, or you can use the handle stored in the global variableWidthTabHandle
. The global variableWidthPtr
contains a pointer to the global width table; however, this variable is reliable only immediately after a call toFMSwapFont
. Like all pointers to data in handles,WidthPtr
may become invalid after a call to the Memory Manager. In general, use theWidthTabHandle
global variable instead of theWidthPtr
global variable.The global variable
WidthListHand
is a handle to a list of up to 12 handles to recently used width tables. You can scan this list and look for width tables that match the font family ID, size, and style of the font you wish to measure. If you reach a width-table handle that contains -1 in thetabFont
,fID
, andaFID
fields, that width table is invalid. When you reach a handle that is equal toNIL
, you have reached the end of the list.
If your application directly manipulates data in a font resource (for example, if your application edits fonts), you may need to flush the Font Manager's cache, so that the cached information reflects any changes that your application makes. The
- IMPORTANT
- Do not use the values from the global width table if your application is running on a computer on which non-Roman script systems are installed. You can check to see if a non-Roman script system is present by calling the
GetScriptManagerVariable
function with a selector ofsmEnabled
; if the function returns a value greater than 0, at least one non-Roman script system is present and you need to callMeasureText
to measure text that is displayed on the screen. Measuring text from a non-Roman script system for printing is handled by the printer driver.FlushFonts
function, which is described on page 4-62, erases all of the Font Manager's caches. The Font Manager then rebuilds the cache as new fonts are called into use again.Normally, fonts are purgeable, which means that the space used for each font's resource information can be released from memory. You can temporarily prevent a font from being purged by locking it with a call to the
SetFontLock
procedure. A subsequent call toSetFontLock
unlocks the font, allowing the Font Manager to purge it from memory. TheSetFontLock
procedure is described on page 4-61.If you are calculating the amount of extra width that is added to a glyph as a result of adding a font style, you can choose how you want the Font Manager to determine the extra pixels needed. It can find the information in the style property field of the font family resource or from the style extra field in the Font Manager's internal tables. If the value of the global variable
FDevDisable
is 0, the Font Manager uses the style extra value from its internal tables; ifFDevDisable
is any other value, the Font Manager uses the value from the style property field, which is described on page 4-88.