The FE 'Font Selector'
GUI utility

a Description
(a Guide)

(FE = Freedom Environment)

The FE Font Selector GUI ---
with a list of 'discovered' fonts
in the listbox on the left.

Larger, hi-res image is below.

FE Home page > FE Overview page >

FE 'xpg' description page >

This 'FE Font Selector' Description page

! Note !
This description may be revised ---
if I ever significantly change this utility.

'FE Font Selector' GUI UTILITY

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

    in the Tk GUI-making language

  • FEATURES of the 'FE Font Selector' utility

    • font families listbox

    • option menu for font size

    • checkbuttons
      for bold, italic, underline, overstrike

    • the sample text

    • the OK, Cancel, Help, and ColorMe buttons

    • the UpdateFontDisplay button

    the 'FE Font Selector'
    ('xpg', for example)

    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.

    Each user-selected font specification is displayed in a Tk text widget --- using lines of

    • uppercase alphabetic characters
    • lowercase alphabetic characters
    • numeric characters
    • special characters
  • return (to 'stdout') 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'.

    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 the 8.5 'wish' script interpreter.)

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, 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).

Hence 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. a Tk '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

  • a 'DownWin' button
    (to quickly downsize the window if it 'blew up' due to choosing a very large font size)

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' (or 'UseIt') 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.]

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


shown using another instance of 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 monitor 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 --- one of the FE (Freedom Environment) systems.

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.


  • 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.

of 'FE Font Selector' :

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.

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 --- and look for the string '', if he/she is interested.

Happy font browsing and font selection!

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

Poke this image to see the
Font-Selector GUI in a different color 'palette'
--- in a separate browser window or tab.

(Changing the 'palette' of the Tk window
changes the color of ALL the widgets.)

Use of the FE Font Selector
in the 'xpg' text viewer utility

The image above is of 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 'ColorMe' button

The Font-Selector GUI, like the 'xpg' GUI, has a 'Color' button, which when clicked invokes an FE RGB Color-Selector GUI.

That 'ColorMe' button is used to change the 'color palette' of the FE Font Selector GUI --- ALL of its widgets.

Tcl-Tk 8.5 (or higher) for
high-quality font rendering

These screenshots were taken of Tk GUI's rendered with Tcl-Tk 8.4.

With Tcl-Tk 8.5 comes the possibility of rendering the Tk window (in particular, the fonts) with the 'Xft' anti-aliasing system on Linux.

Much nicer displays of fonts should be possible with Tcl-Tk 8.5 --- similar to the display quality seen with Linux font-viewing utilities such as 'gnome-specimen', 'gnome-font-viewer', and KDE 'fontmatrix'.

Bottom of this
'FE Font Selector' Utility
Description / Guide

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. >

Page history:

Page was created 2010 Aug 29.

Page was changed 2010 Aug 31.

Page was changed 2018 Aug 15.
(Added css and javascript to try to handle text-size for smartphones, esp. in portrait orientation.)

Page was changed 2019 Jun 30.
(Specified image widths in percents to size the images according to width of the browser window. Also did some reformatting to improve readability.)