Wenton's Linux xfontsel Page

by
Wenton L. Davis

What damn bonehead came up with this one? xfontsel is a nice program for browsing fonts defined by the X Logical Font Description (XLFD) structure (which is not all fonts installed for X11, but a lot of them).  But it's a little bit of a pain in that ass if you're not ready for its paculiarities.

Working the selection drop-down is not very difficult; just select which property of the XLFD descriptor you want to filter on, and it will do it.  The trick comes when you want to actually copy the text of the font you are selecting.

The first way I finally discovered was when invoking the program, you have to include the -print option:

  $ xfontsel -print
  

When invoking xfontsel in this way, the program will dump the selected font string to stdout when it exits... but not quite the way you'll expect.  When the program exits, it prints the font descriptor string, but it neglects to put the typical EOL (line feed) at the end, so the lext line in the terminal will be the font descriptor string, no space, and your usual terminal prompt string.  I have no idea if that is intentional or just forgetful in behalf of the programmers.  I just think it kinda sucks.

Alternatively, we have to understand how that "select" button works.  When the program is launched, the select button is not active (usually just a white box with black text).  The user can do whatever they want to explore fonts, and nothing really happens beyond the fonts being displayed.  However, once the user hits the select button, making it a black box with white text, the xfontsel program takes ownership of the "PRIMARY" selection.  In doing so, it controls the PRIMARY X11 variable.  Now, the user can press the middle button on the mouse, and it will print the text of the PRIMARY X11 variable, which should be the font descriptor string.  However, this will only be true until the xfontsel program is running.  Once the program exits, PRIMARY is no longer owned by that program, and it will revert to whatever value was previously stored in PRIMARY.  Likewise, of the user hits the select button again (turining it off), xfontsel no longer owns the PRIMARY variable, and clicking the middle mouse button pastes the same text iw would have before xfontsel was run.

I'm not entirely sure about this, or how to test it, but that behavior seems, to me, to imply that the PRIMARY X11 variable acts more like a stack than just a variable.

Wenton's email (wenton@ieee.org)

home