XmFontSelector(3) The Font Selector widget

SYNOPSIS

#include <Xm/FontS.h>

DESCRIPTION

                                                                 

The Font Selector widget allows users to easily choose a font by selecting the font family and size of the font. The bold and italic attributes may also be set for any font for which they are available. Any font may be passed to the font selector by the application as the initial value shown to the user. Advanced features greatly extend the widget's functionality.

Basic Features

The font selector widget presents the user with two combination box widgets, one with a list of choices for the font family, and the other with the choices for the font size. In addition there are two independent toggle buttons that allow the user to make the font bold or italic or bold/italic. Below the font choice area is a text widget that displays sample text of the chosen font to the user. This text area is editable, allowing the user to add or remove text to see how various characters appear in the chosen font. For the novice user this set of features allows access to all standard fonts on the system. The font selector dynamically removes choices that are inappropriate so the user is free to play around with different combinations and can always be assured that once they have selected a font that it will exist on the machine that the font selector is running on. For example if there is no Times Roman 14 point font available, and the user selects a point size of 14, then Times Roman will not be available in the family combination box. Likewise, if the user had chosen Times Roman from the family dialog box then a size of 14 would not be shown. To have all choices available simply choose a size and family of Any.

Advanced Features

For the advanced user the font selector provides tremendous flexibility in font choices. By activating the options button an additional panel of controls is presented to the user. This allows the user to gain access to non-XLFD fonts, control the resolutions of the fonts chosen, choose from fixed or proportional fonts only, remove the use of font scaling, allow non iso8859-1 fonts to be viewed, and see the XLFD name the font selector is constructing.

Non XLFD Fonts

By choosing the "Other Fonts" toggle from the option panel, the family and size lists, as well as the bold and italic toggles, are replaced with a combo box containing all non-XLFD fonts available on your system. This feature allows users to select non-XLFD fonts with the FontSelector. The text field of the combination box may be edited by the user and any string entered will be interpreted as a font name. It should be noted that XLFD names can be typed in by hand here. This feature allows the font selector to be used to get any font on the entire system.

Resolution Control

The font selector finds which of the two standard resolutions the current display is closest to and uses that as its default. To allow a wider range of choices a user may choose to access fonts of a different resolution, or both 75 and 100 dpi resolutions.

Fixed or Proportional

In most cases the fact that a font is fixed width or proportional is of no great interest to the user. But some applications require a fixed width font, such as terminal emulators, and most people find that proportional fonts look better. The Font selector allows users to limit the font choices to fixed width or proportional or to allow both.

Font Scaling

The font scaling technology that is available in X11R5 uses bitmap scaling which, although useful in some cases, generally results in very ugly fonts. We noticed that users often wanted to know which fonts are scaled and which ones exist as hand crafted bitmaps. To remove the scaled fonts from the list of choices, toggle the "Use Font Scaling" button off. This value is resource controllable and defaults to on, which uses font scaling.

Encoding

The programmer can specify which encidings are valid selctions. These encoding choices appear in an option menu. The list of font choices is restricted to those which use the current selected coding.

XLFD Name Display

Clicking the Show toggle displays the current font's XLFD name is shown at the bottom of the font selector.

Normal Resources

NameClassTypeInitialValue
100DPIstring100DPIStringXmString"100 dpi"
75DPIstring75DPIStringXmString"75 dpi"
anyLowerStringAnyLowerStringXmString"any"
anyStringAnyStringXmString"Any"
boldStringBoldStringXmString"Bold"
bothStringBothStringXmString"Both"
currentFontStringStringNULL
defaultEncodingStringDefaultEncodingStringString"iso8859-1"
encodingListEncodingListStringTable"iso8859-1"
encodingStringEncodingStringXmString"Encoding"
familyStringBothStringXmString"Family"
italicStringItalicStringXmString"Italic"
marginHeightMarginDimension0
monoSpaceStringMonoSpaceStringXmString"Fixed Width
Fonts"
optionStringOptionStringXmString"Options ..."
otherStringOtherStringXmString"Other Fonts"
propSpaceStringPropSpaceStringXmString"Proportional
Fonts"
sampleTextSampleTextXmString"abcdef..."
scalingStringScalingStringXmString"Use Font
Scaling"
showFontNameShowFontNameBooleanFalse
showNameStringShowNameStringXmString"Show Font
Name"
sizeStringSizeStringXmSring"Size"
spacingSpacingDimension2
textRowsTextRowsDimension8
useScalingBooleanBooleanTrue
valueChangedCallbackCallbackXtCallbackListNULL
xlfdStringXlfdStringXmString"Xlfd Fonts"

All resource names begin with XmN and all resource class names begin with XmC.

100DPSString

The label for the 100 DPI radio button.

75DPSString

The label for the 75 DPI radio button.

anyLowerString

The label for the any button.

anyString

The label for the Any button.

boldString

The label for the Bold toggle button.

bothString

The labels for the Both radio buttons controlling both the dpi and width of the fonts displayed. The same resource is used to ensure consistent labels.

currentFont

This resource provides the main application input and output to the font selector. If the programmer sets the value at creation time or with XtSetValues then the currently displayed family, size, bold and italic will be changed to correspond to the values shown in the current font. Otherwise, the name of the font will be shown. The Font Selector's mode will be set to correspond to the type of font passed.

Note: currentFont must contain 14 hyphens (-) to be considered an XLFD font. This resource is also used to retrieve the font the user has selected from the font selector. The value returned is only valid until the next time XtGetValues is called on this instance of the font selector widget.

defaultEncodingString

This resource is the default selection from the Encoding options menu.

encodingList

This resource is the list of encodings available from the FontSelector Encoding options menu.

encodingString

This resource is the default selection from the Encoding options menu.

familyString

This resource is the default selection from the Family options menu.

isoFontsOnly

This resource controls and maintains the state of the iso8859-1 fonts only toggle button.

italicString

This resource is the default selection from the Italic toggle button.

marginHeight

The margin height for all subwidgets of the Font Selector.

monoSpaceString

The label of the Fixed Width Fonts radio button.

optionString

The label for the Options... push button.

otherString

The label for the Other Fonts radio button.

propSpaceString

The label for the Proportional Fonts radio button.

sampleText

The string which appears in the sample text area.

scalingString

The label for the Use Font Scaling toggle button.

showFontName

This boolean resource controls and maintains the state of Show Font Name toggle button.

showNameString

The label of the Show Font Name toggle button.

sizeString

The label for the Size option menu.

spacing

The space between the toggle indicator and the toggle label.

textRows

This resource controls the number of rows that are shown in the text widget that displays sample text in the currently selected font. Since this is a scrolled text widget it will never dynamically change size, regardless of the font displayed. Unless the initial font is large this value should be at least 4 or the user interaction may be poor.

useScaling

This resource controls and maintains the state of the Use Font Scaling toggle button.

valueChangedCallback

The list of callbacks called when the XmNcurrentFont value is changed.

xlfdString

The label for the Xlfd Fonts radio button.

Convenience Routine

XmCreateFontSelector - Widget creation convenience routine


Widget XmCreateFontSelector( Widget parent, /* Widget id of parent for FontSelector */ String name, /* Name of the created widget */ ArgList args, /* argument list */ Cardinal num_args /* number of items in argument list */ )

Children

The font selector is composed of many sub-widgets. As with all widgets, most values passed to this widget through the argument list at creation time or via set values are passed to each of this widget's children. Get values requests must be made on a child by child basis. The children of the font selector are listed below. The documentation for each of the children should be consulted for a list of resources for each child.

XiFontSelector<named by application>

     XiPanedtopPane

     XmComboBoxfamilies

     < See XmComboBox for list of children >

     XmSeparatorseparator

     XiComboBoxsizes

     < See XmComboBox for list of children >

     XmSeparatorseparator

     XmButtonBoxboldItalicBox

     XmToggleButtonboldButton

     XmToggleButtonitalicButton

     XmSeparatorseparator

     XmToggleButtonoptionButton

     XmSeparatorseparator

     XmPanedmiddlePane

     XmPanedleftPane

     XmButtonBoxchoiceBox

     XmToggleButtonxlfdButton

     XmToggleButtonotherButton

     XmSeparatorseparator

     XmButtonBoxresolutionBox

     XmToggleButtondpi75Button

     XmToggleButtondpi100Button

     XmToggleButtonanyButton

     XmSeparatorseparator

     XmSeparatorseparator

     XmButtonBoxspacingBox

     XmToggleButtonproportionalButton

     XmToggleButtonmonoButton

     XmToggleButtonbothButton

     XmSeparatorseparator

     XmButtonBoxotherChoiceBox

     XmToggleButtonscalingButton

     XmToggleButtonisoButton

     XmToggleButtonshowNameButton

     XmRowColum encodingOptionMenu

     XmLabelGadget OptionLabel

     XmCascadeButtonGadget OptionButton

     XmMenuShell menuShell

     XmRowColum pulldownMenu

     <dependent on XmNencoding>

     XmSeparatorseparator

     XmSeparatorseparator

     XmButtonBoxbox

     XmScrolledWindowtextSW

     XmScrollBarvbar

     XmTexttext

     XmSeparatorseparator

     XmLabelnameLabel

     XmSeparatorseparator

COPYRIGHT

Copyright (c) 1992 by Integrated Computer Solutions, Inc.