AFont()

This function asks Windows for font information and creates an array containing the results. It's a maddeningly schizophrenic function: the format of the array changes depending on how many parameters you pass. You can ask for a list of fonts, for font sizes for a particular font, or whether a particular font and size is installed. In each case, the form of the answer is different.

Usage

lReturnValue = AFONT( FontArray [, cFontName [, nFontSize ] ])

Parameter

Value

Meaning

FontArray

Array Name

The array to contain the font information.

cFontName

Omitted

Create a list of all installed fonts.

Character

Get information for the specified font.

nFontSize

Omitted

Get all font sizes available for cFontName; if cFontName is scalable, create a single row containing -1.

Numeric

Determine if cFontName is available in nFontSize. If so, create a single row containing .T.

lReturnValue

.T.

The array was created containing the specified information.

.F.

The specified font/size combination doesn't exist and no array was created.


There are several strange things about AFONT(). First, unlike all the other array functions that get information and stuff it in an array, this one returns a logical value. The rest return the number of rows in the resulting array (or 0, if they fail).The contents of the array created depend on the parameters passed. If cFontName and nFontSize are both omitted, the array contains as many items as installed fonts, with each element containing one font name.If cFontName is specified, but nFontSize is omitted, the array elements are numeric. For scalable fonts, a single element is created with a value of -1. For non-scalable fonts, the array contains one row for each size of cFontName available. If there is no such font, the array doesn't get created.If both parameters are specified, the array contains a single logical element (set to .T.) if cFontName is available in nFontSize. If not, the array doesn't get created at all. If the font isn't available in the specified size and the array already exists, it's not resized, but the first element is changed to .F.We think this design is horribly confusing. It would be better either to return results in the same format regardless, or to have several different functions for this task. This setup ensures that we have to look up this function every time we use it.

Example

? AFONT(aFonts)  && Create a list of all available fonts
? AFONT(aCourier, "Courier")  && Check sizes for Courier
? AFONT(aAvailable, "MS Sans Serif",8)  && Check for particular
                                        && font/size combination

See Also

Array Manipulation, GetFont()


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .