Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Thread Tools Display Modes
  #1   (View Single Post)  
Old 21st December 2011
J65nko J65nko is offline
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,254
Thanked 182 Times in 149 Posts
Default Changing font size in xterm

Several years ago, on what used to be my workstation, I wrote a small script to create some xterms with a different and larger font size then the default. Yes, older age comes with diminishing eyesight for me

This proved to be handy when creating complex regular expressions for grep or friends. Being too lazy to go to the garage through the cold, to unpack that box, connect a keyboard and monitor to it, I decided to google for 'xterm font size unix'.
The most helpful was http://invisible-island.net/xterm/xt....html#how_do_i
How do I change the font size?
Xterm uses fonts given as resource settings. You can switch between these fonts at runtime, using a menu. This is documented in the manpage, in the MENUS section.

X Consortium xterm provides popup menus, by pressing the control key together with the mouse button. Control right mouse button pops up the VT FONTS menu, from which you can select fonts that are specified in xterm's resources. Usually these are in increasing order of size.

Modern xterm provides the menu, plus a feature adapted from rxvt: pressing the shifted keypad plus or minus keys steps through the font menu selections, in order of their size.

Xterm's manpage does not document the syntax for X resources; it is done in the X documentation. If you are instead asking about a problem displaying a given font, it may be due to a problem with your resource settings.
In my case the "shifted keypad plus or minus keys" only made the fonts smaller, not larger, so my quest for a larger font size continued.

The xterm man page is quite long but this site also has a nice version of the xterm man page : http://invisible-island.net/xterm/manpage/xterm.html

The MENU section : http://invisible-island.net/xterm/manpage/xterm.html

If you use 'less' as pager for the man pages .....
 $ grep PAGER .profile      
export PAGER=/usr/bin/less
then you can move that section of xterm(1) with a simple /MENUS

       Xterm  has  four  menus, named mainMenu, vtMenu, fontMenu,
       and tekMenu.  Each menu pops up under the correct combina-
       tions  of  key  and  button presses.  Each menu is divided
       into sections, separated by a horizontal line.  Some  menu
       entries  correspond to modes that can be altered.  A check
       mark appears next to a  mode  that  is  currently  active.
       Selecting  one  of  these  modes toggles its state.  Other
       menu entries are commands; selecting one of these performs
       the indicated function.

       All  of  the menu entries correspond to X actions.  In the
       list below, the  menu  label  is  shown  followed  by  the
       action's name in parenthesis.
A summary of these CONTROL:key and mouse button presses:
  1. Code:
     Main Options
        The  xterm  mainMenu  pops  up  when the "control" key and
           pointer button one are pressed in  a  window.   This  menu
           contains  items that apply to both the VT102 and Tektronix
           windows.  There are several sections: ........
  2. Code:
       VT Options
           The vtMenu sets various modes in the VT102 emulation,  and
           is popped up when the "control" key and pointer button two
           are pressed in the VT102 window.
  3. Code:
       VT Fonts
           The  fontMenu  pops  up  when  when  the "control" key and
           pointer button three are pressed in a window.  It sets the
           font  used  in  the  VT102 window, or modifies the way the
           font is specified or displayed.  There  are  several  sec-
  4. Code:
       TEK Options
           The tekMenu sets various modes in the Tektronix emulation,
           and is popped up when the "control" key and pointer button
           two are pressed in the Tektronix window.  The current font
           size is checked in the modes section of the menu.

So to change the the font size: press the CONTROL key with one hand, and click the right mouse button. A menu appears, with the following font alternatives:
              Default (fontdefault)
                     Set the font  to  the  default,  i.e.,  that
                     given by the *VT100.font resource.

              Unreadable (font1)
                     Set   the   font   to   that  given  by  the
                     *VT100.font1 resource.

              Tiny (font2)
                     Set  the  font  to   that   given   by   the
                     *VT100.font2 resource.

              Small (font3)
                     Set   the   font   to   that  given  by  the
                     *VT100.font3 resource.

              Medium (font4)
                     Set  the  font  to   that   given   by   the
                     *VT100.font4 resource.

              Large (font5)
                     Set   the   font   to   that  given  by  the
                     *VT100.font5 resource. 

             Huge (font6)
                     Set  the  font  to   that   given   by   the
                     *VT100.font6 resource.
Problem solved
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump

Last edited by J65nko; 21st December 2011 at 06:55 AM. Reason: fixing some VBulletin codes
Reply With Quote
  #2   (View Single Post)  
Old 21st December 2011
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 577
Thanked 14 Times in 13 Posts

Thanks for this post, it's a topic that's been in the back of my mind (among many others). One reason is that with a laptop, everything is different than the 17" CRT, and bigger fonts are needed on the higher resolution screen.

I had forgotten about the Shift-Keypad[Plus|Minus] method. Though, my laptop has no numeric keypad, so unfortunately this won't work, at least not without some serious X key remapping.

The font menu through Ctrl-Button3 is also problematical. Like a lot of laptops, mine has just two buttons, although you can press both (where they join) to get a 3rd. There are lots of programs competing for convenient mouse button usage though, so while that works I'm not really happy with it either. And the touchpad button emulation is no help.

Also I'd like to have the xterm come up with the right font to begin with, rather than having to set it each time. One way is with a command-line option, e.g.,

$ xterm -fn '-*-terminus-bold-*-*-*-14-*-*-*-*-*-*-*' ...

but better would be to put something in ~/.Xresources. I haven't gotten to mucking around with that yet, but if I come up with anything good I'll try to remember to post it here.

Last edited by IdOp; 22nd December 2011 at 04:33 AM. Reason: add egg sample
Reply With Quote
  #3   (View Single Post)  
Old 3rd January 2012
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 577
Thanked 14 Times in 13 Posts

Finally had a chance to play with this a bit and collect some basic information about changing the fonts used by xterm, such as using larger ones. This will be useful if you want xterm to come up a certain way every time it's run, without using key combinations (you may have no Numeric Keypad) or tedious command line arguments.

There are two approaches to this, depending on whether or not your xterm binary was compiled with FreeType support. To check for this support you can do (substitute the path to your xterm)

% ldd /usr/X11R7/bin/xterm | grep freetype

If this shows anything, you can use either the FreeType or regular method; otherwise you have to use the regular method.

FreeType method

A number of prerequisites need to be in place, including:

(a) xterm supports FreeType (see above),

(b) the renderFont resource is true; it is by default, but to be sure you can add this to ~/.Xresources

XTerm.VT100.renderFont: true
(c) the resource faceName is set. By default it is unset so you must take action here, for example

XTerm.VT100.faceName: terminus
The above sets the normal FreeType font to the "terminus" font. Change to your liking.

(d) on the VT Fonts menu (Ctrl-Button3) be sure the "TrueType Fonts" entry is selected.

In addition to the font, the desired size can be specified. The default for the normal font is 14pt but can be changed with the faceSize option. Also, there are six alternative font sizes. These will be the ones referred to in the VT Font menu as "Unreadable", ..., "Huge". They can all be set in this way:

! Face size for normal:                                                                                         
XTerm.VT100.faceSize:  14                                                                                       
! Face sizes for alternates:                                                                                    
! Unreadable:                                                                                                   
XTerm.VT100.faceSize1:  12 
! Tiny:                                                                                                         
XTerm.VT100.faceSize2:  14 
! Small:                                                                                                        
XTerm.VT100.faceSize3:  20
! Medium:                                                                                                       
XTerm.VT100.faceSize4:  24
! Large:                                                                                                        
XTerm.VT100.faceSize5:  28
! Huge:                                                                                                         
XTerm.VT100.faceSize6:  32
Do yourself a favour and ensure the alternates have increasing sizes for 1,...,6. Anything else may result in confusion.

Regular method

This will be used if xterm doesn't support FreeType or if faceName is unset.

First, to change the default font, put something like this in your ~/.Xresources

! Default:                                                                                                      
XTerm.VT100.font: -*-terminus-*-*-*-14-*-*-*-*-*-*-*
Obviously, pick whatever font and size you prefer here. This font will be the one referred to as "Default" in the VT Font menu. By tinkering with at least the Default font, you can have all xterms come up how you prefer.

In addition, there are six alternate fonts, that can be specified like this:

XTerm.VT100.font1: -*-terminus-*-*-*-12-*-*-*-*-*-*-*
XTerm.VT100.font2: -*-terminus-*-*-*-14-*-*-*-*-*-*-*                          
XTerm.VT100.font3: -*-terminus-*-*-*-20-*-*-*-*-*-*-*                          
XTerm.VT100.font4: -*-terminus-*-*-*-24-*-*-*-*-*-*-*
XTerm.VT100.font5: -*-terminus-*-*-*-28-*-*-*-*-*-*-*                          
XTerm.VT100.font6: -*-terminus-*-*-*-32-*-*-*-*-*-*-*
These fonts will be cycled through according to their sizes when you select Font Menu items such as "Unreadable", ..., "Huge". Again, define them in order of size to avoid confusion.

There's quite a bit more about fonts in xterm(1) which I haven't tried to understand but the above is enough to get started. I hope it is mostly correct but I haven't tested every detail. Additions and corrections are welcome.

Last edited by IdOp; 3rd January 2012 at 12:37 AM.
Reply With Quote
  #4   (View Single Post)  
Old 4th February 2012
thirdm thirdm is offline
Package Pilot
Join Date: May 2009
Posts: 212
Thanked 3 Times in 3 Posts

Under the category of regular method, I had luck with the following resource too. The terminus font is neat, but if you want to make only a minimal change to xterm's default look the resource below is the equivalent to picking Huge from the vt100 font menu.

xterm*vt100.initialFont: 6
Use 5 if you only need Large and so on down the line.
Reply With Quote
  #5   (View Single Post)  
Old 4th February 2012
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 577
Thanked 14 Times in 13 Posts

Thanks thirdm, that is a perfect minimalist solution to do what I was originally after, as it doesn't require installing an alternate font.

I think the reason I got detoured with terminus is that, I needed a solution on the Laptop, and that's been more of a sandbox to experiment and change things more than I usually do.
Once I had something that worked and looked good, I stopped reading the man page for other parameters.
Reply With Quote

font size, x window, xterm

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change the font size? atop xterm, aterm, etc jb_daefo General software and network 12 13th July 2010 10:42 AM
font-misc-ethiopic & font-misc-meltho Beastie General software and network 0 27th February 2009 11:21 AM
CLI font size idefix FreeBSD General 3 7th February 2009 11:19 AM
changing Firefox's font(s)? spiderpig General software and network 4 5th June 2008 03:09 PM
Wrong screen resolution, font size etc. PatrickBaer FreeBSD General 10 14th May 2008 10:00 AM

All times are GMT. The time now is 08:33 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick