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.]
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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
Method 2
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
Method 3
- For fonts:
xterm -report-fonts. - For colours:
xterm -report-colors.
Method 4
Try this — it queries the X server resource database
% xrdb -q| grep -i font
See also
% man xrdb
Method 5
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 6×13, 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
Method 6
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 9×15 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.
Method 7
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.
Method 8
XTerm Control Sequences tells the developer how to obtain the font specification:
OSCPs ; PtSTSet 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
dttermcontrol 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
allowFontOpsresource. 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 thefaceName
resource.
The xtermcontrol program uses this feature (see the --get-font option).
Regarding the other answers:
- the
--report-fontsoption 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. appresonly tells what resources are read from external files. Besides compiled-in defaults, and theutf8fontsandfaceNameresources 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).
lsofcan show which TrueType fonts xterm is using.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0