ChooseFont

Like EnumFontFamiliesEx, the common dialog API function ChooseFont has been extended to handle charsets. Figure 6-6 shows the new common dialog for Windows 95. As you can see, it includes a list box for scripts.

Figure 6-6 The Windows 95 Font common dialog.

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 replaces the CF_ANSIONLY flag. Because Windows 95 accommodates more character sets than ANSI does, a flag labeled ANSIONLY is obsolete. 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 new flag CF_SELECTSCRIPT. Before calling ChooseFont, initialize the lfCharSet field of the LOGFONT. If you are interested only in specifying the charset, set the other fields of the LOGFONT to NULL. So that ChooseFont knows to look at the LOGFONT, 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.