Name
FontRequest -- ask user to select a font (V5.0)
Synopsis
t = FontRequest(title$[, font$, size])
Function
This command will pop up a requester that will list all fonts currently available in the system. The user is then prompted to select a font from this list. The user can also choose an output size for the font, as well as the font style and font color. Note that the color selection is not supported on every platform. FontRequest() accepts three arguments. The first argument specifies the title text for the requester's dialog window. The second and third arguments are optional and can be used to preselect a font. If you want this command to preselect a font, pass its name and desired size in these two optional arguments.

Upon return, FontRequest() initializes a table containing all parameters selected by the user and passes this table back to the caller. The return table will have the following fields initialized:

Name:
The complete font name (i.e. family name plus style). For example, "Arial Bold Italic". This is a string you could pass directly to SetFont() or OpenFont().

Family:
The family name of this font, e.g. "Arial".

Size:
Contains the selected font size (e.g. 36).

Weight:
The weight of the font. This will be set to one of the following weight constants:

 
#FONTWEIGHT_THIN
#FONTWEIGHT_EXTRALIGHT
#FONTWEIGHT_ULTRALIGHT
#FONTWEIGHT_LIGHT
#FONTWEIGHT_BOOK
#FONTWEIGHT_NORMAL
#FONTWEIGHT_REGULAR
#FONTWEIGHT_MEDIUM
#FONTWEIGHT_SEMIBOLD
#FONTWEIGHT_DEMIBOLD
#FONTWEIGHT_BOLD
#FONTWEIGHT_EXTRABOLD
#FONTWEIGHT_ULTRABOLD
#FONTWEIGHT_HEAVY
#FONTWEIGHT_BLACK
#FONTWEIGHT_EXTRABLACK
#FONTWEIGHT_ULTRABLACK

Slant:
The slant style of the font. This will be set to one of the following slant constants:

 
#FONTSLANT_ROMAN
#FONTSLANT_ITALIC
#FONTSLANT_OBLIQUE

Bold:
True if the user chose a bold font style.

Italic:
True if the user chose an italic font style.

Underline:
True if the user chose an underlined font style.

StrikeOut:
True if the user chose a striked out font style.

Color:
The font color chosen by the user in RGB format.

Please note that the Underline, StrikeOut, and Color fields are not supported on all platforms. If the host operating system's font dialog does not support them, they will all be set to False.

Inputs
title$
title for the requester
font$
optional: name of the font that shall be initially selected (defaults to "" which means do not select a font)
size
optional: size of the font that shall be initially selected
Results
t
a table containing all parameters chosen by the user (see above for a description of the table fields)
Example
t = FontRequest("Select a font")
NPrint("Font:", t.name)
NPrint("Family:", t.family)
NPrint("Size:", t.size)
NPrint("Weight:", t.weight)
NPrint("Slant:", t.slant)
NPrint("Underline:", t.underline)
NPrint("Strike:", t.strikeout)
NPrint("Color:", HexStr(t.color))
The code above pops up a font requester and then prints out all information gathered from the user.

Show TOC