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 / About the Font Manager


How the Font Manager Calculates Glyph Widths

Integer glyph widths are measurements of a glyph's width that are in whole pixels. Fractional glyph widths are measurements that can include fractions of a pixel. For instance, instead of a glyph measuring exactly 5 pixels across, it may be 5.5 pixels across. Fractional glyph widths allow the sizes of glyphs as stored by the Font Manager to be closer in proportion to the original glyphs of the font than integer widths allow. Fractional widths also make it possible for high-resolution printers to print with better spacing.

You can enable or disable the use of fractional glyph widths in your application, as described in "Using Fractional Glyph Widths and Font Scaling" on page 4-34. As a default, fractional widths are disabled to retain compatibility with older applications.

When using fractional glyph widths, the Font Manager stores the locations of glyphs more accurately than any actual screen can display: since screen glyphs are made up of whole pixels, QuickDraw cannot draw a glyph that is 5.5 pixels wide. The placement of glyphs on the screen matches the eventual placement of glyphs on a page printed by the high-resolution printers more closely, but the spacing between glyphs and words is uneven as QuickDraw rounds off the fractional parts. The extent of the distortion that is visible on the screen depends on the font point size relative to the resolution of the screen.

The Font Manager communicates fractional glyph widths to QuickDraw through the global width table, which is a data structure that is allocated in the system heap. The Font Manager fills in this table by accessing data from one of several places:

The Font Manager looks for width data in the following sequence:

  1. For a bitmapped font, it first looks for a font glyph-width table in the font record, which is the record used to represent in memory the data in a bitmapped font resource. For an outline font, it first looks for data in the horizontal metrics table. The width table for bitmapped fonts is described in the section "The Bitmapped Font ('NFNT') Resource," which begins on page 4-62. The width table for outline fonts is described in "The Horizontal Device Metrics Table" on page 4-74.
  2. If it doesn't find this table, the Font Manager looks in the font family record for a family glyph-width table. The font family record is used to represent in memory the data in a font family resource. This is described in "The Family Glyph-Width Table" on page 4-92.
  3. If the Font Manager doesn't find a family glyph-width table, it derives the global character widths from the integer widths contained in the width/offset table in the bitmapped font record, as described in "The Bitmapped Font ('NFNT') Resource" on page 4-62.

Note
If you need to use different widths than those returned by the global width table, you should change the values in the global width table only. You should never change any values in the font resources themselves.
To use fractional glyph widths effectively, your application must get accurate widths when laying out text. Your application should obtain glyph widths either from the QuickDraw procedure MeasureText or by looking in the global width table. The MeasureText procedure is described in the chapter "QuickDraw Text" in this book. You can get a handle to the global width table by calling the FontMetrics procedure, which is described on page 4-50.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996