AFONT( ) Function

Places information about available fonts into an array.

AFONT(ArrayName [, cFontName [, nFontSize]])

Return Values

Logical

Parameters

  • ArrayName
    Specifies the variable array into which the names of available fonts are placed. If the array is not large enough to contain all the fonts, Visual FoxPro automatically increases the size of the array. If you specify an existing two-dimensional array, Visual FoxPro changes the array to a one-dimensional array.

    If the array is successfully created, AFONT( ) returns True (.T.); otherwise, AFONT( ) returns False (.F.).

  • cFontName
    Specifies a font for which information is placed into the array.

    If the font you specify supports only discrete font sizes (8-point, 10-point, ...), the font sizes are stored to the array and AFONT( ) returns True (.T.). If the font you specify in cFontName is scalable (supports fractional font-size values), the array has a single element containing –1 and AFONT( ) returns True (.T.).

    If the font you specify is not available, the array isn't created and AFONT( ) returns False (.F.).

  • nFontSize
    Specifies a size for the font specified in cFontName.

    If the font size nFontSize is available for the font specified in cFontName, the array has a single element containing a True (.T.) value and AFONT( ) returns True (.T.). If the font size is not available for the specified font, the array is not created and AFONT( ) returns False (.F.).

Remarks

AFONT( ) places the names of available fonts into an array. It can also be used to determine available font sizes or if a font is scalable. Use GETFONT( ) to display a dialog containing available fonts, font sizes, and styles.

Example

The following example uses AFONT( ) to create an array containing the names of all available fonts. The name of each font is displayed, along with an example of the font. If there are more than 10 fonts installed, only the first 10 are displayed.

CLEAR
=AFONT(gaFontArray)  && Array containing font names
gnNumFonts = ALEN(gaFontArray)  && Number of fonts
IF gnNumFonts > 10
   gnNumFonts = 10  && Display first 10 fonts
ENDIF

FOR nCount = 1 TO gnNumFonts
   ? ALLTRIM(gaFontArray(nCount))  && Display font name
   ?? '  This is an example of ' ;
      + ALLTRIM(gaFontArray(nCount)) FONT gaFontArray(nCount), 8
ENDFOR

See Also

FONTMETRIC( ) | GETFONT( ) | TXTWIDTH( ) | SYSMETRIC( ) | WFONT( )