JavaScript Editor js editor     Web development 



Main Page

Displays the Font dialog box and returns information about the font you choose.

GETFONT([cFontName [, nFontSize [, cFontStyle [, nFontCharSet]]]])

Parameters

cFontName


Specifies the name of the font initially selected in the Font dialog box. If the font you specify is not installed, the default font is selected initially.
nFontSize


Specifies the font size selected initially in the Font dialog box. If the font size you specify is not supported, the default font size is selected initially. If you omit nFontSize or if nFontSize is less than or equal to zero, the font size selected defaults to 10 point.
Note:
The dialog box permits you to select sizes between 4 and 127, inclusive. You can specify other values for nFontSize when calling the GETFONT function; no error occurs. If you do so, however, the user must select a size within the designated range of values before clicking OK in the dialog box. Otherwise, the dialog box displays an alert and does not accept the value.

cFontStyle


Specifies the font style selected initially in the Font dialog box or to display only those fonts available on the selected printer. If the font style you specify is not supported, the default font style is selected initially. The following table lists the values available for cFontStyle.

cFontStyle Description

B

Select Bold font style initially.

I

Select Italic font style initially.

BI

Select Bold Italic font style initially.

P

Display only those fonts available on the current default printer.

nFontCharSet


Specifies a value for the language script. The values you can specify differ depending on your version of Windows.
Note:
Omitting this value disables the script drop-down list in the dialog box.

The following table describes some example values for nFontCharSet.

nFontCharSet Language script

0

Western

1

Default

2

Symbol

128

Japanese

161

Greek

162

Turkish

163

Vietnamese

177

Hebrew

178

Arabic

186

Baltic

204

Cyrillic

238

Central European

Note:
If you specify 1 for nFontCharSet, the dialog box that GETFONT(В ) opened displays the default language script on the operating system. GETFONT(В ) never returns 1 because it returns the value for the language script selected in the GETFONT(В ) dialog box.

For more information, see FontCharSet Property.

Return Value

Character. GETFONT(В ) returns one of the following, depending on certain conditions:

  • A character string containing three types of font information with commas separating the items returned: font name, size and style. This behavior occurs when you choose one in the Font dialog box and you have not included the fourth optional argument when calling the GETFONT(В ) function.

  • A character string containing four types of font information with commas separating the items returned: font name, size, style and language script. This behavior occurs if you include a value for the nFontCharSet parameter.

Note:
In versions of Visual FoxPro previous to Visual FoxPro 9.0, if you included a value of 0 as the fourth argument to GETFONT(), you received the same return information as if you did not include the fourth argument at all. The script drop-down list was not enabled, and the return value contained only three types of font information. In Visual FoxPro 9.0, a value of 0 explicitly indicates the numeric value corresponding to Western script. The script drop-down list might also initially display Western if you specify 1 for this value, but only if Western is the default script for your regional settings.

  • An empty string if you exit the Font dialog box by clicking Cancel, Close on the Control menu, or pressing the ESC key.

Remarks

Tip:
You can abbreviate some Visual FoxPro commands and functions to four characters when conflicts with other commands and functions do not exist. In the case of GETFONT(В ) and GETFILE(В ), which both begin with the same four letters, precedence is given to GETFILE(В ); therefore, issuing GETF(В ) displays the Open dialog box.

Example

The following example illustrates different types of return values you can get from the GETFONT(В ) function.

В Copy Code
* Invoke the dialog with script drop-down list disabled:
? GETFONT("Arial",12,"B") && press OK in the dialog box
* return value is the string:
* "Arial,12,B"

* Enable the script drop-down list, Western script selected:
? GETFONT("Arial",12,"B",0) && press OK after selections
* sample return value is the string:
* "Verdana,16,N,161"

* Return from the dialog box without making a selection:
? GETFONT("Arial",12,"B") && press Cancel in the dialog box
* return value is an empty string
? GETFONT("Arial",12,"B",0) && press Cancel in the dialog box
* return value is still an empty string

See Also



JavaScript Editor js editor     Web development