Unix Power ToolsUnix Power ToolsSearch this book

5.18. Changing Fonts Dynamically

Ideally, you want to set up your environment so that xterm windows (and other clients) come up automatically with the characteristics you prefer, including the display font. I use the very large 10×20-pixel font (Section 5.16) for all my xterm windows by specifying the resource variable (Section 6.3):

XTerm*font: 10x20

But if you start an xterm and then decide you want a different font, you do have an option.

5.18.1. VT Fonts Menu

The xterm VT Fonts menu (Section 5.17) allows you to change a window's font on the fly, which is a very handy capability. You can change the font any number of times to accommodate a variety of uses. You might choose to use a large font for text editing; you could then change to a smaller font while a process is running, since you don't need to be reading or typing in that xterm. Since xterm's dimensions are determined by the number of characters wide by the number of lines high, changing the font also changes the size of the window.

When the focus is on an xterm, you display the menu by pressing CTRL and then the third pointer button. The default menu is shown in Figure 5-3.

Figure 5-3

Figure 5-3. xterm's VT Fonts menu lets you change fonts dynamically

The items on the VT Fonts menu are toggles, each of which provides a different size display font. If you have not toggled any items on this menu, a check mark will appear next to Default, which is the font specified when the xterm was run. This font could have been specified on the xterm command line or in a resource file. Whatever the case, this font remains the Default for the duration of the current xterm process.

By default, the Unreadable, Tiny, Small, Medium, Large, and Huge menu choices toggle the constant-width fonts shown in Table 5-4.

Table 5-4. VT Fonts menu defaults

Menu item

Default font

Unreadable

nil2

Tiny

5×7

Small

6×10

Medium

7×13

Large

9×15

Huge

10×20

Bring up the VT Fonts menu, and toggle some of these fonts to see what they look like. The first choice is not called Unreadable for nothing, but it does have a practical use.

You can specify your own Unreadable, Tiny, Small, Medium, Large, and Huge fonts using the xterm resource variables font1, font2, font3, font4, font5, and font6. You might want to specify bold alternatives to some of the default fonts. For example, 7×13 bold is somewhat more readable than the standard Medium font.

All of the references to fonts and command-line options also apply to rxvt, which does not, however, support the VT Fonts menu supported by xterm.

5.18.2. Enabling Escape Sequence and Selection

When you first run an xterm window, the final two choices on the VT Fonts menu, Escape Sequence and Selection, are not functional. (They will appear in a lighter typeface than the other selections.) The average user may not care about these items, but if you're experimenting with fonts, they are sometimes useful.

To enable Selection, you first have to select a font name. You can do this simply by highlighting a font name with the pointer, as you would any text selection (Section 5.13). However, it's more likely that you'll use Selection in concert with the xfontsel client. [This is a client that does point-and-click selection of X11 font names; see its manpage. -- JP] Once you've selected a font name, you can toggle it using the Selection menu item. A serious limitation: Selection tries to use the last selected text as a font name. If the last selected text was not a valid font name, toggling Selection will get you nothing more than a beep. When there is no primary text selection in memory, the menu item is grayed out again.

The Escape Sequence item is a little more complicated, but once set up it will be available for the duration of the xterm process. To make it available, you first need to change the font by a more primitive method, using a literal escape sequence that you send to the xterm using echo:

val@ruby 181% echo "Esc]50;7x13boldControl-g"

These are the literal keys you type to change the font to 7×13bold. But pressing ESC actually generates the symbol ^[, and CTRL-g appears as ^G, so you'll get a line that looks like this:

val@ruby 181% echo "^[ ]50;7x13bold^G"

If you don't get this string, try typing the CTRL-v character before both the ESC and CTRL-g characters, letting the system know you intend for the following character to be a literal.

I've used a short font name alias (Section 5.16), but you could use a full name or a name with wildcards. Once you've changed the font in this manner, you can toggle it using the Escape Sequence menu item. If you change the font again using the literal escape sequence, that font will be available via the menu item. Note that the trick for changing the font discussed earlier also works in rxvt, but does not enable any font menus.

--VQ and SJC



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.