Home / Alt manpages / xfontsel(1)

  • xfontsel(1)
  • User command
  • linux

Choose and Copy an X11 Font Name with xfontsel

xfontsel lets you pick a font visually and walk away with its full X Logical Font Description name, ready to paste into a config file.

The examples match xfontsel 1.1.0 from x11-utils 7.7+6build2, installed on this machine. Allow about ten minutes. You need a running X display, the xfontsel command, and an X application to paste the result into. This is an ordinary user task; it needs no sudo.

Checkpoint

The useful outcome is a font name copied out of the running window, not merely a process that launched successfully.

1. Check the installed command and its display

Confirm the package is installed and your shell knows where the executable lives:

$ command -v xfontsel
/usr/bin/xfontsel
$ dpkg-query -W -f='${Package} ${Version}\n' x11-utils
x11-utils 7.7+6build2
$ printf 'display: %s\n' "${DISPLAY:-unset}"
display: :0

Your package revision and display value can differ. If DISPLAY is unset, or the command reports it cannot open the display, run it from the graphical session that owns the X server.

Warning

Do not try to repair an X connection by adding sudo. Root can have a different display authorisation and still cannot make a missing server appear.

2. Start with a narrow font pattern

With no pattern, xfontsel makes every font that has a 14-part XLFD name selectable, which on most systems is a genuinely large set of menus. A pattern narrows that down. It gets passed to the X server while the shell handles wildcard characters, so quote it:

$ xfontsel -pattern '*-m-*'

This requests names with m in the field position the pattern targets. The manual gives this form as a way to select a subset of monospaced fonts, though the actual result depends on what is installed and registered with your X server. The window opens and stays running until you activate its quit control.

Other useful starting points are partial or complete XLFD names:

$ xfontsel -pattern '*medium*'
$ xfontsel -pattern '-*-*-medium-*-*-*-*-*-*-*-*-*-*-*'

Warning

Do not leave the wildcard unquoted. In a directory containing matching file names, the shell can expand *-m-* before xfontsel ever sees it, handing it a completely different argument or an error.

Checkpoint

You should see the xfontsel window and a row of XLFD fields. If the window is nearly incomprehensible and a warning mentions a missing app-defaults file, check that /etc/X11/app-defaults/XFontSel is present; the installed program leans on that resource file for most of its interface.

3. Refine the XLFD fields

Click a field name to open its menu. Each field is one part of the font name, and earlier choices constrain later menus, so an entry can go missing after you pick something else.

  • Menu looks empty? Choose the * entry in whichever field is restricting the others. An empty-looking menu usually means a previous field combination has no matches, not that the server has no fonts.
  • Sample looks wrong? Pick a new value in one of the fields. The manual records this as a limitation of ambiguous patterns, not evidence the font file is damaged.
  • Need a fixed size? A scalable font can report zero in the pixel-size, point-size and average-width fields, which leaves the size implementation-dependent. Start with -scaled for selectable pixel and point sizes.
$ xfontsel -pattern '*-m-*' -scaled

Scaled mode adds sizes; it does not install a font or alter the server's font catalogue. The average-width menu can be unwieldy, so only touch it when you have a specific reason to change the font's horizontal scaling.

4. Copy the selected font name

Once the sample and fields show the font you want, activate the select widget. xfontsel places the selected name in both the PRIMARY text selection and the PRIMARY_FONT selection. On X that is normally pasted with the middle pointer button, not a clipboard shortcut.

Test the hand-off in another X application. An xterm is convenient if you have one:

$ xterm &

Click in the new terminal and paste with the middle button. The exact text depends on your choices, but it should be a complete XLFD-style name matching what xfontsel's fields showed. Activate select again while it is highlighted and xfontsel releases ownership of the selection; select once more if you need to make the name available again.

There is no persistent state to undo here. Closing xfontsel ends the process, and if another X application claims PRIMARY, xfontsel's select indicator de-highlights and its previous selection stops being available through PRIMARY.

5. Print the name when quitting

Want a shell-capturable result instead of an X selection? Add -print. xfontsel writes the selected font specifier to standard output when you activate its quit control:

$ xfontsel -pattern '*-m-*' -print
# choose fields, then activate select if you also want PRIMARY
# activate quit in the xfontsel window
-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso10646-1

The displayed font name is host-dependent, and the sample above shows the shape of the result, not a promise. Redirection changes no system configuration, but avoid overwriting a useful file with an unreviewed redirection; use a new destination if you want to keep the value:

$ xfontsel -pattern '*-m-*' -print > selected-font.txt

Do not expect the file to contain anything until you quit through the xfontsel window. Empty file means go back, confirm a font is actually selected, and activate quit. For a sample string in a non-default encoding, -sample, -sample16 and -sampleUCS change what text the window displays; they do not change the font name -print emits.

6. Diagnose a font that will not load

First check the fields still describe a matching font. Select * in a restrictive field, then choose a value again. Too many wildcards can lead to an ambiguous initial selection; a very specific pattern can legitimately match nothing at all on this server.

If menus appear before xfontsel has finished parsing the server's font names, the manual says a request can trigger a missing-menu message on standard error. Wait for parsing to finish and retry. If it persists, close and relaunch the program; that does not change the font catalogue.

Remember that xfontsel only examines fonts the current X server knows about. It does not search arbitrary font files, install fonts, or configure an application permanently. A font name copied from one server may not exist on another, even on the same desktop environment.

Done means

  • Opened cleanly: xfontsel opened on the intended X display without elevated privileges.
  • List narrowed: a quoted XLFD pattern cut a distracting full catalogue down to size.
  • Fields matched: you changed fields until the sample and complete font name matched your requirement.
  • Name captured: you copied the name through PRIMARY or printed it with -print and checked the result.
  • Scaled sizes understood: you know scaled sizes are optional, host-dependent, and not a permanent font install.
  • Nothing changed: no system files, font catalogue, service or user configuration was touched.