KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q99672: INFO: Complete Enumeration of System Fonts

Article: Q99672
Product(s): Microsoft Windows Software Development Kit
Version(s): WINDOWS:3.1,95; winnt:3.5,3.51,4.0
Operating System(s): 
Keyword(s): kbOSWinNT350 kbOSWinNT351 kbOSWinNT400 kbOSWin95 kbSDKWin16
Last Modified: 12-MAY-2001

3.10 4.00 | 3.50 3.51
WINDOWS   | WINDOWS NT
kbgraphic EnumFonts

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Windows Software Development Kit (SDK) 3.1 
- Microsoft Win32 Application Programming Interface (API) 
-------------------------------------------------------------------------------

SUMMARY
=======

Complete enumeration of system fonts is a two-phase process. Applications should
first call EnumFontfamilies with NULL as the family name to enumerate all the
font face names in the system. Applications should then take each face name and
call EnumFontFamilies again to obtain the style names (for TrueType fonts only)
or the supported point sizes (for raster fonts only). The style names are not
supported for the raster and vector fonts. Because TrueType and vector fonts are
continuously scalable, their point sizes are not enumerated.

MORE INFORMATION
================

The following steps detail the enumeration:

1. Call EnumFontFamilies with NULL as the family name (lpszFamily) to list one
  font from each available font family.

2. In the EnumFontFamProc callback function, look at the nFontType parameter.

3. If nFontType has the TRUETYPE_FONTTYPE flag set, then call EnumFontFamilies
  with the family name set to the font's type face name (lfFaceName of the
  ENUMLOGFONT structure). The callback function is called once for each style
  name. This enumeration is useful if the application is interested in finding
  a TrueType font with a specific style name (such as "Outline"). Because a
  TrueType font is continuously scalable, it is not necessary to enumerate a
  given font for point sizes. An application may use any desired point size. If
  the application is listing the enumerated TrueType fonts, it can simply
  choose some representative point sizes in a given range. The point sizes
  recommended by "The Windows Interface: An Application Design Guide" (page
  159, Section 8.4.1.4) are 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28,
  36, 48, and 72. All TrueType fonts are available on both displays and
  printers, so an application can be sure that the font appears the same on the
  display and the printer.

4. If nFontType has the RASTER_FONTTYPE flag set, then call EnumFontFamilies
  with the family name set to the font's type face name. The callback function
  is called once for each available point size. Raster fonts can be scaled only
  in multiples of the available point sizes. Because scaled raster fonts are
  usually not appealing to the user, applications may choose to limit
  themselves to the available sizes. Because Microsoft Windows version 3.1 does
  not define style names for raster fonts, there is no need to enumerate for
  style names.

  If the nFontType also has the DEVICE_FONTTYPE flag set, then the current font
  is a raster font available to the printer driver for use with the printer.
  The printer may have these fonts in hardware or be capable of downloading
  them when necessary. Applications that use such fonts should be aware that
  similar raster fonts may not be available on the display device. The converse
  is also true. If the DEVICE_FONTTYPE flag is not set, then applications
  should be aware that a similar font may not be available on the printer.
  Fonts generated by font packages such as Adobe Type Manager (ATM) are listed
  as device fonts.

5. If nFontType has neither the TRUETYPE_FONTTYPE nor the RASTER_FONTTYPE flags
  set, then the enumerated font is a vector font. Vector fonts are also
  continuously scalable so they do not have to be enumerated for point sizes.
  Because Windows 3.1 does not support style names for vector fonts, there is
  no need to enumerate them for style names. Vector fonts are generally used by
  devices such as plotters that cannot support raster fonts. These fonts
  generally have a poor appearance on raster devices, so many applications
  avoid them.

Additional query words: 3.10 4.00

======================================================================
Keywords          : kbOSWinNT350 kbOSWinNT351 kbOSWinNT400 kbOSWin95 kbSDKWin16 
Technology        : kbAudDeveloper kbWin3xSearch kbSDKSearch kbWin32sSearch kbWin32API kbWinSDKSearch kbWinSDK310
Version           : WINDOWS:3.1,95; winnt:3.5,3.51,4.0
Issue type        : kbinfo

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.