27

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.]

9 Answers 9

29

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
    Commented Feb 26, 2019 at 19:55
  • @user640916 maybe like me you mistyped and wrote "Xterm xterm" instead of "XTerm xterm?
    – Magnus
    Commented Mar 10, 2021 at 15:40
16

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
    Commented Jul 14, 2021 at 18:23
  • 2
    It would not help for bitmap-fonts, since those are on the server. Commented Dec 27, 2021 at 18:14
12
  • 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
3

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
7
  • 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
    Commented Jul 10, 2020 at 15:18
  • Thank you. That ok. Commented 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
    Commented Jul 10, 2020 at 15:29
  • Glad for that. It teaches me for the next time. Thanks! Commented 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
    Commented 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
    Commented 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
    Commented 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.
0

I have an ANSI-art image viewer which runs on 'xterm' and uses the Unicode block glyphs and TrueColor 24-bit RGB.

Funny things started happening when running on a Mac, particularly after updating Sonoma.

If I use the default font options, it looks nice, albeit with a retro dot-matrix look. If I specify a font, the block characters have lines between them. I often see a greenish line between the block glyphs. I also get an occasional dark character glitch. These can disappear by themselves after a few seconds, or when you move the window. Turn off TrueColor and things are okay. Turn off TrueType, and you get the default font and that's okay. This suggests that the fault is not in 'xterm' but in the Mac windowing software.

I have tried using the various fonts. Nothing seems quote the same as the default settings.

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

If you select the Small font option, then this looks like the default, and I don't get any of the faults, but the Default option has missing characters and an odd aspect ratio.

I even tried writing my own BDF font with just the characters I needed. 'xterm' loaded them, but got turned into TrueType fonts, and that broke them.

For now I am sticking to the 'xterm' default settings. They seem to be a robust choice. No other settings seem to quite reproduce them. I suspect the default settings may be different when 'xterm' is compiled to run in a different OS. That would explain why we are all seeing slightly different things.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .