The FE 'Font Selector' GUI utility

a Description (a Guide)

(FE = Freedom Environment)

FE Home page > FE Overview page > FE 'xpg' description page > This 'FE Font Selector' Description page

! Preliminary ! This description may be touched up or revised occasionally.


of the FE (Freedom Environment) system

        A utility to rapidly
        • view font family names known to Tcl-Tk (and Linux), on your machine

        • show sample text (alphabetic, numeric, special characters) in a user-specified font as the user chooses font attributes such as family, size, bold, italic, underline, or overstrike

        • return a selected font specification to an application

Written: 2010 aug 27
Updated: 2010 aug 31

This HTML file is based on the text file
in [xpg-install-dir]/helps/select_tkFont.hlp

That text help file is shown via the 'Help' button
on the 'FE Font Selector' GUI interface.


    - INTRODUCTION to the 'FE Font Selector' utility
    - FONT SPECIFICATIONS in the Tk GUI-making language
    - FEATURES of the 'FE Font Selector' utility
    • font families listbox
    • option menu for size
    • checkbuttons for bold, italic, underline, overstrike
    • the sample text
    • the OK, Cancel, Help, and ColorMe buttons
    • the UpdateFontDisplay button
    - SOME APPLICATIONS using the 'FE Font Selector' ('xpg', for example)
    - INVOCATION/IMPLEMENTATION of the 'FE Font Selector'

Page 2

INTRODUCTION to the 'FE Font Selector' utility :

The 'FE Font Selector' utility is a GUI (Graphical User Interface) mini-application that provides 'widgets' (listbox, checkbuttons, sample text area, action buttons) to help a user quickly

  • see the font 'families' available --- examples :
    arial, courier, helvetica, verdana, 'dejavu sans mono', 'liberation.sans'

  • specify SIX font attributes: family, size, bold, italic, underline, overstrike
    --- plus ONE --- the Units of the size integer (pixels or printer-points)

  • examine the qualities of fonts with the user-specified attributes,
    as each font specification is displayed in a Tk text widget --- using lines of
    • uppercase alphabetic characters
    • lowercase alphabetic characters
    • numeric characters
    • special characters

  • return the specification values of the currently displayed font (family, size, bold, italic, underline, overstrike) to an application that called on the 'FE Font Selector' utility.

This utility is implemented via a Tcl-Tk script called ''. Hence, we sometimes refer to this utility as '' or simply 'select_tkFont' --- or more generically as the 'tkFontSelector' or the 'FE Font Selector' or simply the 'Font Selector'.

    (Note: The quality of font display will be much better in Tcl-Tk 8.5 than in Tcl-Tk 8.4 --- because the Linux Xft anti-aliasing system is available in 8.5.)

Page 3

FONT SPECIFICATIONS in the Tk GUI-making language

When specifying a font for a widget in a Tk GUI, the developer can specify the font by using (up to) six attributes.

The fastest way to indicate how these attributes are used is to simply show a single line of Tk code for assigning a font for the text in a widget, like a label or a button widget.

  label .frame1.label2 -text "Hello world!" -font \
                -family arial -size 12 -weight bold -slant italic

    [The back-slash indicates the command continues on the next line.]

    [In this example, since the specifiers '-underline 1' and '-overstrike 1' do not appear, it is assumed that underline and overstrike are not wanted.]

    [In fact, if the 'bold' and 'italic' specifications are left off, it is as if '-weight normal' and '-slant roman' were specified. They are the defaults.]

In actual programming practice, since a GUI may have a lot of labels and buttons (and entry-fields and list-boxes and other widgets that can have text associated with them, including checkbuttons and radiobuttons), it is good practice to use a Tk 'font create' command to create a (temporary) fontname to be used to specify a common font for labels and/or buttons, say.

So the above example would become something like the following.

      font create font4labsANDbutts -family arial -size 12 \
                                    -weight bold -slant italic


      label .frame1.label2 -text "Hello world!" -font font4labsANDbutts

So there you have it --- the reason why the 'FE Font Selector' GUI has facilities for specifying a font via SIX widgets (8 actually) :

  1. - a listbox for 'family'
  2. - an option menu for 'size' (with 2 'pixels' or 'points' radiobuttons)
  3. - a checkbutton for 'weight' (normal or bold)
  4. - a checkbutton for 'slant' (roman or italic)
  5. - a checkbutton for 'underline' (0 or 1)
  6. - a checkbutton for 'overstrike' (0 or 1)

Page 4

FEATURES of the 'FE Font Selector' utility

  • font families listbox
  • option menu for size (with 2 'pixels' or 'points' radiobuttons)
  • checkbuttons for bold, italic, underline, overstrike
  • the sample text area
  • the OK, Cancel, Help, and ColorMe buttons
  • the UpdateFontDisplay button

When the user selects any of the six basic attributes (or the units for the size attribute - an additional attribute), by a mouse click, the sample text area of the 'FE Font Selector' GUI immediately updates showing the sample text in a font with the currently specified font attributes.

The Buttons on the FE Font Selector :

If the user settles on a font he/she likes (for the application calling this GUI script), a click on the 'OK' button returns the font attributes to the application.

    [The first application using this 'FE Font Selector' was the FE 'xpg' text browsing/searching/extract-all-matches GUI utility of the FE (Freedom Environment) system(s).]

In fact, a string like

 -family arial -size -12 -weight bold -slant italic -underline 0 -overstrike 0

is returned to the application.

    [A negative integer for size indicates units of 'pixels', rather than 'points'.
    A point is 1/72 of an inch.]

If a user is just 'browsing the fonts' with the 'Font Selector', he/she can simply click the 'Cancel' button.

    [Clicking the 'Cancel' button returns an empty string to a calling application. The application can respond accordingly --- usually, by not changing a font or fonts in the application.]

    [Note that this 'Font Selector' can also be used as a 'Font Browser'.]

A click on the 'Help' button shows a help text file --- the file [FE-install-dir]/helps/select_tkFont.hlp --- using the FE 'xpg' text-browser utility.

A click on the 'ColorMe' button brings up another FE Tk GUI --- an 'FE Color Selector' GUI --- by which the user may preview colors (via 3 slider bars, for red, green, blue). When the user clicks the OK/Accept button on that GUI, the color scheme (Tk 'palette') of the 'Font Selector' GUI is immediately changed according to the color shown in the 'Color Selector' GUI when the Ok/Accept button was clicked.

    [One nice feature of this color change is that if the user selects a very dark color, all the text in the GUI is automatically changed from black to white --- for readability.]

The 'DwnWin' button :

If the user displays a really large font size, like 48 or 60 or 72 points, the display window will go to maximum size. This may 'hog' the whole screen.

To downsize the window quickly, the user can click on the 'DwnWin' button. At each click, the 'FE Font Selector' window will be decreased in size about 10%, in both the x and y dimensions. --- down to a minimum size of about 650x400 pixels.

If that reduction of the window is too much, the user can simply grab a corner or side of the window with the mouse, and stretch the window out to a desired amount.

In the future, the way the 'DwnWin' button works may be changed somewhat, if it appears that there is a better way to implement that function.

Or, if that function does not really seem to be necessary, and a better function for a button arise, the function of that button may be changed.

Note that another feature of the GUI, to help handle display of huge font sizes, is the horizontal and vertical scroll bars that were added to the text widget that displays the sample text.

Page 5

SOME APPLICATIONS of the 'FE Font Selector' :       (in 'xpg', for example)

The 'FE Font Selector' utility was originally written to be used to offer the user a way to reset the font of the text area on the GUI of the 'xpg' utility of the FE (Freedom Environment) system.

The 'xpg' utility is meant for general users --- and for application supporters and developers --- and for Linux system administrators --- to quickly browse/search/extract-and-show-all-matching-lines in text files --- such as

  • long help documents,
  • long parameter files,
  • long scripts --- or long code source for compiled programs,
  • long message logs,
  • long lists of files or directories,
  • etc. etc.

As an interesting side note (well, to me it's interesting), note that Tk GUI scripts can call each other. Example:

  • the 'xpg' GUI (script '') calls the 'Font Selector' GUI (script '') when the user clicks the 'TxtFont' button on the 'xpg' GUI

  • the 'Font Selector' GUI (script '') calls the 'xpg' GUI (script '') when the user clicks on the 'Help' button on the FontSelector GUI


You can see an example of implementing the '' Tk script by looking at the source code for the Tk script '' --- which is the 'guts' of the 'xpg' text browse/search/extract-all-matches utility of the FE (Freedom Environment) system.

To avoid getting too technical for this introductory guide, we do not reproduce the pertinent (several) lines of code here. We leave it to the reader to look at the '' script, if he/she is interested.

Happy font browsing and font selection!

END OF GUIDE to the 'FE Font Selector' GUI utility

This is the Font-Selector GUI that is invoked when
the 'TxtFont' button on the 'xpg' GUI is clicked.
This is to change ONLY the font of the text widget, NOT the fonts
of the button, label, entry, and other widgets of the 'xpg' GUI.

The Font-Selector GUI, like the 'xpg' GUI, has a 'Color'
button, which when clicked invokes the FE Color-Selector GUI.
Click on this image to see the Font-Selector GUI in a different color 'palette'.

NOTE: These screenshots were taken of Tk GUIs rendered with Tcl-Tk 8.4.
With 8.5 comes the possibility of rendering the Tk window (in particular, the fonts)
with the Linux Xft anti-aliasing system. Much nicer displays of fonts
should be possible with Tcl-Tk 8.5 --- similar to the display quality
seen with gnome-specimen, gnome-font-viewer, and KDE fontmatrix.

Bottom of the 'FE Font Selector' utility Description page.

FE = Freedom Environment

To return to a previously visited web page, click on the
Back button of your web browser a sufficient number of times.
OR, use a History-list option of your web browser.
OR ...

< Go to Top of Page, above. >

OR ...

< Go to FE Home page >

Page created 2010 Aug 29. Changed 2010 Aug 31.