PtFontSelection()

Display a modal dialog for selecting a font

Synopsis:

char *PtFontSelection( PtWidget_t *parent, 
                       const PhPoint_t *pos,
                       const char *title, 
                       const char *font,
                       long symbol,
                       unsigned flags,
                       const char *sample);

Library:

ph

Description:

This function displays a modal dialog that lets you select a text font.


Font-selection dialog


A font-selection dialog.

The dialog is parented off the parent widget, which may be NULL; if non-NULL, that parent widget is blocked and its cursor is changed to reflect this.

The dialog is positioned according to the pos parameter: if NULL, the dialog is centered on the screen; if parent is NULL, the dialog is placed at the absolute coordinates of pos; otherwise it's placed at the relative offset of pos within parent.

The title of the dialog is given by title; if this is NULL a default title of “Select Text Font” is used.

The initial font selected in the dialog is given by font. If this argument is NULL, the initial font is TextFont09. Otherwise, it should point to a font name created by PfGenerateFontName().

The symbol parameter specifies which character will be used to construct the list of available font families (refer to PfQueryFonts() in the Library Reference); if -1L is specified a default symbol 'A' (standard Latin fonts) is used.

The flags parameter is used to limit the inclusion of fonts based on certain characteristics:

To include: Use this flag:
Scalable fonts PHFONT_SCALABLE
Bitmapped fonts PHFONT_BITMAP
Proportional fonts PHFONT_PROP
Fixed-width fonts PHFONT_FIXED

You can OR the flags together to obtain a suitable mask. The default is PHFONT_ALL_FONTS (which is every option set).

The sample parameter sets the text string used to display a sample of the selected font; if NULL the default of AaBbCcXxYyZz is used.

The modal dialog is constructed and the user may select a text font using comboboxes for the family and size, and buttons for the style. A sample of text using the font is dynamically updated.

The user may click a Cancel button or close the window to cancel the selection, or click an OK button to accept it.

Returns:

A pointer to the new font string if one selected, NULL otherwise. This string is obtained using the strdup() function, so the application should free() it once finished with the font name.

Examples:

const char *fontname;
PhPoint_t pos= {10, 23};

fontname = PtFontSelection (widget, &pos,
   "Select a font!", "TextFont12", -1,
   PHFONT_ALL_FONTS, 
   "Who is Sylvia? what is she, that all our\
 swains commend her?");

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PfGenerateFontName(), PhPoint_t

PtFontSel in the Photon Widget Reference

Dialog modules in the Working with Modules chapter, and the Fonts chapter of the Photon Programmer's Guide