4

We all know how to change the standard font for (u)xterm, just put something like the following in .Xresources:

xterm*font: -*-terminus-*-*-*-*-24-*-*-*-*-*-*-*

But, for example, ctrl + right-click on an xterm window opens up a menu in which the font size can be set in six levels, from "Unreadable" to "Huge", excluding a "Default" setting, which sets the font to what is given by the xterm*font option.

And these menu options are completely unaffected by what is set by xterm*font in .Xresources. So "Huge" may actually result in a smaller font than "Default".

How can I set the font type and size for the six options?

viuser
  • 2,614

2 Answers2

6

At startup, xterm calculates the relative sizes of the bitmap fonts (which may be unrelated to the names in the menu). You can see this order using the default translation for shifted keypad plus and minus, which switch to larger or smaller fonts, respectively.

xterm does not associate any particular meaning to the names on the menu. Here is the section of the resource-file which deals with the (non-Unicode) fonts:

*fontMenu.Label:  VT Fonts
*fontMenu*fontdefault*Label:    Default
*fontMenu*font1*Label:  Unreadable
*VT100.font1:       nil2
*IconFont:      nil2
*fontMenu*font2*Label:  Tiny
*VT100.font2:       5x7
*fontMenu*font3*Label:  Small
*VT100.font3:       6x10
*fontMenu*font4*Label:  Medium
*VT100.font4:       7x13
*fontMenu*font5*Label:  Large
*VT100.font5:       9x15
*fontMenu*font6*Label:  Huge
*VT100.font6:       10x20

Those numbers, e.g., 10x20 are aliases for longer names such as

-misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1

Most of the ten-thousand or so fonts (seen with xlfonts) on my system have no aliases. The Unicode fonts assumed by the uxterm script do not use aliases:

*VT100.font2:   -misc-fixed-medium-r-normal--8-80-75-75-c-50-iso10646-1
*VT100.font:    -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1
*VT100.font3:   -misc-fixed-medium-r-normal--14-130-75-75-c-70-iso10646-1
*VT100.font4:   -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso10646-1
*VT100.font5:   -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1
*VT100.font6:   -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1

The first number in each of those (XLFD) font specifications is the point-size, making it simple to see which are larger.

On my machine, I have a terminus font-package installed. Some of the aliases and XLFD (full) font specifications are (as listed in the xfonts-terminus.alias file):

terminus-12     -xos4-terminus-medium-r-normal--12-120-72-72-c-60-iso10646-1
terminus-14     -xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso10646-1
terminus-16     -xos4-terminus-medium-r-normal--16-160-72-72-c-80-iso10646-1
terminus-18     -xos4-terminus-medium-r-normal--18-180-72-72-c-100-iso10646-1
terminus-20     -xos4-terminus-medium-r-normal--20-200-72-72-c-100-iso10646-1
terminus-22     -xos4-terminus-medium-r-normal--22-220-72-72-c-110-iso10646-1
terminus-24     -xos4-terminus-medium-r-normal--24-240-72-72-c-120-iso10646-1
terminus-28     -xos4-terminus-medium-r-normal--28-280-72-72-c-140-iso10646-1
terminus-32     -xos4-terminus-medium-r-normal--32-320-72-72-c-160-iso10646-1

So one could make a resource-file using either name.

*VT100.font2:   terminus-12
*VT100.font:    terminus-14
*VT100.font3:   terminus-16
*VT100.font4:   terminus-18
*VT100.font5:   terminus-20
*VT100.font6:   terminus-22

though the names will not be useful unless you redo those as well:

*fontMenu.Label:  VT Fonts
*fontMenu*fontdefault*Label:    Default
*fontMenu*font1*Label:  Unreadable
*fontMenu*font2*Label:  12-points
*fontMenu*font3*Label:  16-points
*fontMenu*font4*Label:  18-points
*fontMenu*font5*Label:  20-points
*fontMenu*font6*Label:  22-points

I put those in a regular app-defaults file, omitting the instance or class name. For your .Xdefaults file, you probably should prefix those with "xterm" (in case some other application cares about its font).

If you have no bitmap fonts (aside from the fixed font which is more-or-less guaranteed), you should still be able to switch font sizes by using a TrueType font. By default, xterm does not use TrueType fonts; you can tell it to use TrueType fonts using the -fa command-line option or the faceName resource.

Once configured, you can switch between bitmap- and TrueType-fonts using the fonts menu.

Further reading:

Thomas Dickey
  • 76,765
  • Thanks for the detailed explanation. I'm using the faceName resource to set a TrueType font. Can you please give an example of what the *VT100*font* resource should be set to in this case? – kshenoy Mar 06 '18 at 20:02
  • 1
    That would be a different question (the further-reading is a good place to start). – Thomas Dickey Mar 06 '18 at 21:28
4

Set the options for font1, font2, ... font6 (classname Font1, ... Font6) to correspond with unreadable, tiny, small, medium, large, and huge in the .Xresources, e.g.

xterm*font2: -*-terminus-*-*-*-*-12-*-*-*-*-*-*-*

This is in the manual Search for font2

Thomas Dickey
  • 76,765
icarus
  • 17,920