21

If I launch xterm with its default bitmap fonts and then select the 'Large' font from the 'VT Fonts' menu (via ctrl+right mouse), I get a very usable bitmap font with apparently good Japanese character support.

I'd like to know what this font is so that I can use it elsewhere. Unfortunately, I've found no information on what default settings XTerm uses (i.e. when none are explicitly specified). Lots of sites show how to use X resources to specify new settings (e.g. particular fonts), but none I've seen say what defaults are used if I do nothing.

I've tried eyeballing the font, and it looks similar to and is the same width as 9x15, but it uses more vertical space. It appears not to be 9x15 with different line spacing, though, as specifying this font directly fails to display some Japanese characters that 'Large' can handle just fine.

Although I'll be happy to know what this specific font is, I really want to know where to find what defaults XTerm uses for its resources more generally. If it makes any difference, I'm running Ubuntu 12.04 LTS, 64-bit.

[I have seen this question on the subject already, which is why I'm specifically asking about defaults rather than trying to get live values from a running XTerm.]

8 Answers 8

22

The appres utility lists the resources used by an application, both user and default.

appres XTerm xterm

The first argument is the class name (xterm -class Xxx). The second argument, which is optional, is the instance name (xterm -name xxx).

The “Large” font is .VT100.font5 or .VT100.utf8Fonts.font5. See the manual for whether .utf8Fonts is used, it's a bit complex. If you have more than one among *.VT100.font5 and ?.VT100.font5 and XTerm.VT100.font5 and xterm.VT100.font5, the last one in this list applies; see the X documentation for the gory details of resource name precedence.

appres XTerm | grep font5
2
  • When I do appres XTerm on my debian testing machine I only get *customization: -color :-/
    – user640916
    Feb 26, 2019 at 19:55
  • @user640916 maybe like me you mistyped and wrote "Xterm xterm" instead of "XTerm xterm?
    – Magnus
    Mar 10, 2021 at 15:40
14

You can use lsof to list all files by given process id and grep for fonts.

lsof  -p <process_id_of_xterm> | grep fonts

for example,

lsof -p `ps -a | grep xterm | cut -d' ' -f1` | grep fonts

sample output:

$ lsof -p `ps -a | grep xterm | cut -d' ' -f1` | grep fonts
xterm   17560 testuser  mem    REG  253,1    137272  9154732 /usr/share/fonts/liberation/LiberationSans-Bold.ttf
xterm   17560 testuser  mem    REG  253,1    139628  9154735 /usr/share/fonts/liberation/LiberationSans-Regular.ttf
2
  • Did not work for me, nothing at all output.
    – Owl
    Jul 14, 2021 at 18:23
  • It would not help for bitmap-fonts, since those are on the server. Dec 27, 2021 at 18:14
8
  • For fonts: xterm -report-fonts.
  • For colours: xterm -report-colors.
3

Try this -- it queries the X server resource database

% xrdb -q| grep -i font

See also

% man xrdb
2

Your can find the default font by running

$ fc-match mono

Here is the explanation (from the Arch-Wiki)

xterm's default font is the bitmap font named by the X Logical Font Description alias fixed, often resolving to

-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-?

This font, also aliased to the name 6x13, has remakably wide coverage for unicode glyphs. The default "TrueType" font is the 14‑point font matched by the name mono. The FreeType font that will be used can be found with this command:

$ fc-match mono
5
  • Welcome to the site, and thank you for your contribution. Please note that link-only answers are discouraged as they can become invalid when the link becomes dead or the page linked to changes. If possible, edit your post to add at least a summary of what the external page recommends to do to solve the OPs problem.
    – AdminBee
    Jul 10, 2020 at 15:18
  • Thank you. That ok. Jul 10, 2020 at 15:19
  • Thank you. I only took the liberty to apply a minor edit to your post to make it more readable.
    – AdminBee
    Jul 10, 2020 at 15:29
  • Glad for that. It teaches me for the next time. Thanks! Jul 10, 2020 at 15:44
  • 1
    All the misc unicode fonts... (ends in "-iso10646-1") have a very good set of glyphs, thanks the the hard work of the font maintainer Markus Kuhn back when unicode was still new. HOWEVER: bold bold fonts generally do not have all the glyphs. these out out put dotted boxes insead! EG try... echo $'●\e[1m●\e[m' to test normal and bold
    – anthony
    Jul 23, 2020 at 6:03
1

I had the exact same issue as OP. Trying appres gave me no input & editres didn't help for me either (the other stack overflow question).

anyway, I used xlsfonts with trial & error to just find the font from the big list of fonts. It wasn't one of the nice simple font names like 9x15 or anything.

xterm -fn -misc-fixed-bold-r-normal--18-120-100-100-c-90-iso8859-9 

on my system defaulted to the nice large size and printed unicode correctly. to prove a point,

xterm -fn -misc-fixed-bold-r-normal--0-0-75-75-c-0-iso8859-9 

defaulted to a small size that could not even print the unicode (oddly enough right clicking to large made it match the former).

for me, it wasn't very intuitive and it would have been nice to have someone reassure me as I struggled that 2 fonts in the list may look nearly identical but can still be rendered differently by xterm for some odd reason.

2
  • The xterm font selection code is very smart and will often automatically select normal bold, italic and bold italic fonts based on the font name you give. Are you sure you actually got BOLD and your main font!
    – anthony
    Jul 23, 2020 at 6:06
  • Also many of the bold 'misc' fonts do not have unicode glyphs, though the 'medium' or plain font, does. Instead they output doted boxes.
    – anthony
    Jul 23, 2020 at 6:07
0

I found the answer to this question while looking for something else. Since this question came up, I want to share that answer.

This answer comes from a comment by @Gilles_'SO-_stop_being_evil', actually a comment in response to their own answer. If @Gilles wants to take credit for this answer and post it as their own, they are welcome to do so.

I quote the relevant information with emphasis (in bold) added:

You can dump the resources with xrdb -query, but that shows the default settings applied when XTerm starts, not the current settings of an XTerm window.

When I ran xrdb -query, I got the same text as was in my ~/.Xresources file, just in a different order. So, as @Gilles said, it's the default when you launch xterm, which may be fed in by ~/.Xresources (or ~/.Xdefaults, if that's what you use). I was thinking it would show what I would call "the factory defaults". I'm not sure if you're looking for the starting defaults or the factory defaults, but this information has helped me.

0

XTerm Control Sequences tells the developer how to obtain the font specification:

OSC Ps ; Pt ST
Set Text Parameters. Some control sequences return information:

  • For colors and font, if Pt is a "?", the control sequence elicits a response which consists of the control sequence which would set the corresponding value.
  • The dtterm control sequences allow you to determine the icon name and window title.

and for OSC 50:

Ps = 5 0 ⇒ Set Font to Pt.
These controls may be disabled using the allowFontOps resource. If Pt begins with a "#", index in the font menu, relative (if the next character is a plus or minus sign) or absolute. A number is expected but not required after the sign (the default is the current entry for relative, zero for absolute indexing).

The same rule (plus or minus sign, optional number) is used when querying the font. The remainder of Pt is ignored. A font can be specified after a "#" index expression, by adding a space and then the font specifier.

If the TrueType Fonts menu entry is set (the renderFont resource), then this control sets/queries the faceName resource.

The xtermcontrol program uses this feature (see the --get-font option).

Regarding the other answers:

  • the --report-fonts option would give useful data, though OP might find it too much data. An answer using that option should illustrate it with sample output to show what to look for.
  • appres only tells what resources are read from external files. Besides compiled-in defaults, and the utf8fonts and faceName resources preclude a simple answer using that route.
  • by default xterm uses bitmap fonts, and does not actually open those files (the X server does that). lsof can show which TrueType fonts xterm is using.

Not the answer you're looking for? Browse other questions tagged or ask your own question.