International Font Enumeration and Selection
In each major release of Windows, there are fonts added to support international languages and scripts. Please reference Script and Font Support in Windows for the fonts that have been added in each Windows version since Windows 2000, as well as their supported scripts, regions, and languages.
To enumerate international fonts in your application, you can use the EnumFontFamiliesEx function. EnumFontFamiliesEx allows you to enumerate fonts based on typeface name and charset by passing in a pointer to a LOGFONT structure that contains the typeface name and charset information. To call EnumFontFamiliesEx, you can either specify a typeface name or a charset, or you can ask for whatever is available. Setting the typeface name of the LOGFONT to NULL enumerates all typeface names. Setting the charset field to DEFAULT_CHARSET enumerates all charsets.
Note that charsets are a legacy notion corresponding to pre-Unicode character sets. At this time, there is no mechanism to enumerate fonts supporting arbitrary scripts or character ranges in Unicode. The NEWTEXTMETRICEX structure passed by EnumFontFamExProc includes the FONTSIGNATURE structure, which includes more detailed declarations provided by the font developer as to what code pages and what Unicode ranges the font supports. To determine more precisely what character ranges a given font supports, select the font into a device context and call GetFontUnicodeRanges. Note that this API does not support Unicode supplementary planes.
You can use the ChooseFont function to display a common dialog box that allows the user to select international fonts based on charset. You can specify one of three flags to determine, based on charset, which fonts are displayed in the ChooseFont dialog: CF_SCRIPTSONLY, CF_SELECTSCRIPT, or CF_NOSCRIPTSEL.
The CF_SCRIPTSONLY flag tells the API to list fonts for all character sets that are not Symbol or OEM.
If you want to display only fonts that cover a particular charset, you need to specify the flag CF_SELECTSCRIPT. Before calling ChooseFont, initialize the lfCharSet field of the LOGFONT structure. If you are interested in specifying only the charset, set the other fields of the LOGFONT structure to NULL. To have ChooseFont look at the LOGFONT structure, you also need to specify the CF_INITTOLOGFONTSTRUCT flag.
Finally, as with any other field in the Font dialog box, you might choose to display a blank script list box. This capability is useful if the user has highlighted several different fonts spanning several charsets. In this case, you would call ChooseFont with the CF_NOSCRIPTSEL flag.
Starting with Windows 7, ChooseFont implements support for the hiding of fonts from font selection lists. ChooseFont will only list the shown fonts and filter out the hidden fonts while displaying fonts in the list box. The additional flag (CF_INACTIVEFONTS) in the flags member of the CHOOSEFONT structure is added to allow you to display all the installed fonts in the font list, the same as ChooseFont behaved before Windows 7. For the details of behavior differences in Windows 7 for the ChooseFont function, please see ChooseFont() Win32 Common Dialog in the Windows 7 Application Quality Cookbook. Please reference ChooseFont function and CHOOSEFONT structure for the end user experience differences in Windows 7.
Note that charsets are a legacy notion corresponding to pre-Unicode character sets. At this time, there is no mechanism to filter fonts based on Unicode scripts or character ranges.
Windows 7 introduces the Windows Scenic Ribbon which comes with a set of controls targeted to font selection. These font controls support the new Windows 7 font hiding behavior. You can use those font controls to list only shown fonts and allow the user to select the font.
- CHOOSEFONT structure
- Font Controls in Windows Scenic Ribbon
- ChooseFont() Win32 Common Dialog