Zoom in/out in Xterm

Yes.
Well, maybe not in so many discrete, but fully sufficient amount of steps, and dependig on the sizes the font you picked as default supports you may get another font at other sizes,
but when you do CTRL+RM xterm's menu opens, and you can select another size.
 
There is this nifty x11/xtermcontrol port that lets you send control sequences to manipulate xterm programmatically. I wrote a perl script to use it for changing the font size or face. You can map it to CTRL+KeypadPlus in vi or maybe even to a translation within xterm to do what you want.
Perl:
#!/usr/bin/env perl
#
# changefont - select the next or previous font or change font size in XTerm
#
# usage:  changefont +face
#         changefont -face
#         changefont +size
#         changefont -size
#
# $Id: changefont,v 1.5 2022/03/17 19:30:48 schweikh Exp schweikh $

use warnings;
use strict;
use diagnostics;

my $CURRENT_FONT;
my $CURRENT_FACE;
my $CURRENT_SIZE;

$CURRENT_FONT = `xtermcontrol --get-font`;
chop $CURRENT_FONT;
$CURRENT_FONT .= ":size=12" unless $CURRENT_FONT =~ /:/;
($CURRENT_FACE, $CURRENT_SIZE) = split (/:/, $CURRENT_FONT);
$CURRENT_SIZE =~ s/size=//;

push @ARGV, '+face';    # Default: next face.

if ($ARGV[0] eq '+size') {
    &setfont ($CURRENT_FACE, $CURRENT_SIZE + 1);
}
elsif ($ARGV[0] eq '-size') {
    &setfont ($CURRENT_FACE, $CURRENT_SIZE - 1) unless $CURRENT_SIZE < 7;
}
else {
    my @FONT;
    my $font = -1;
    my $i    = 0;
    my @mono = split (/\n/, `fc-list :scalable=true:spacing=mono:slant=0: family|sed s:,.\*::|sort -u`);
    foreach my $face (sort @mono) {
        next if $face =~ /(Cursor|dings$|Untitled|^Marlett|^Scratch|Bold|Italic|Obl|^Courier$)/;
        push @FONT, $face;
        $font = $i if $face eq $CURRENT_FACE;
        ++$i;
    }
    if ($font == -1) {
        $font = 0;
    }
    elsif ($ARGV[0] eq '+face') {
        $font = ($font + 1) % ($#FONT + 1);
    }
    elsif ($ARGV[0] eq '-face') {
        $font = ($font + $#FONT) % ($#FONT + 1);
    }
    &setfont ($FONT[$font], $CURRENT_SIZE);
}

sub setfont {
    my ($face, $size) = @_;
    print "$face:size=$size\n";
    system 'xtermcontrol', '--font', $face . ":size=" . $size;
}

# vi: set syntax=perl tabstop=4 shiftwidth=4 expandtab
 
I found this nice page the other day that has a list of some useful hacks you can do with xterm. It's got quite a lot of useful hidden features.
 
Alternatively, you can use 'terminology' from enlightenment which lets you zoom in or out using ctrl + wheel (mouse wheel). (Although that's cheating, because it's not xterm, the one true X11 terminal).

 
Speaking of that, how do I configure which fonts and sizes show up in that menu?
Code:
! VT Font Menu: Unreadable
xterm*faceSize1: 8

! VT font menu: Tiny
xterm*faceSize2: 10

! VT font menu: Medium
xterm*faceSize3: 12

! VT font menu: Large
xterm*faceSize4: 16

! VT font menu: Huge
xterm*faceSize5: 22

xterm*vt100.Translations: #override \
  Meta <Key>C: copy-selection(PRIMARY) \n\
  Ctrl <Key>V: insert-selection(PRIMARY) \n\
  Meta <Key>V: insert-selection(PRIMARY) \n\
  Ctrl <Key> minus: smaller-vt-font() \n\
  Meta <Key> minus: smaller-vt-font() \n\
  Ctrl <Key> plus: larger-vt-font() \n\
  Meta <Key> plus: larger-vt-font() \n\
  Ctrl <Key> KP_Subtract: smaller-vt-font() \n\
  Meta <Key> KP_Subtract: smaller-vt-font() \n\
  Ctrl <Key> KP_Add: larger-vt-font() \n\
  Meta <Key> KP_Add: larger-vt-font()

I learned this from: https://vermaden.wordpress.com/2021...-part-25-configuration-random-terminal-theme/
 
Code:
! VT Font Menu: Unreadable
xterm*faceSize1: 8

! VT font menu: Tiny
xterm*faceSize2: 10

! VT font menu: Medium
xterm*faceSize3: 12

! VT font menu: Large
xterm*faceSize4: 16

! VT font menu: Huge
xterm*faceSize5: 22

xterm*vt100.Translations: #override \
  Meta <Key>C: copy-selection(PRIMARY) \n\
  Ctrl <Key>V: insert-selection(PRIMARY) \n\
  Meta <Key>V: insert-selection(PRIMARY) \n\
  Ctrl <Key> minus: smaller-vt-font() \n\
  Meta <Key> minus: smaller-vt-font() \n\
  Ctrl <Key> plus: larger-vt-font() \n\
  Meta <Key> plus: larger-vt-font() \n\
  Ctrl <Key> KP_Subtract: smaller-vt-font() \n\
  Meta <Key> KP_Subtract: smaller-vt-font() \n\
  Ctrl <Key> KP_Add: larger-vt-font() \n\
  Meta <Key> KP_Add: larger-vt-font()

I learned this from: https://vermaden.wordpress.com/2021...-part-25-configuration-random-terminal-theme/
Thank you so much! I have been wondering for years.
 
I don't like truetype fonts much, I much prefer good quality bitmapped fonts. There is a page here that has bitmapped VGA fonts for X, that are faithful copies of the original VGA ROM font.

On my 4K screen, the "vga11x19" looks very nice and readable. Here is what this evening's slashdot looks like, for example.
Screenshot_20251104_185308.jpg



Looks like I clipped the left edge a bit too much... anyway you get the idea. It's a nice monospaced font, the closest approximation I can get now to a greenscreen CRT with VGA.
After installation I just say:-
$ xterm -fg green -bg black -fn vga11x19

The 'fixed' "10x20" looks pretty good on the 4K screen too, but I think I prefer the VGA font overall. I always did like the VGA font, designed by someone who knew what they were doing. :)
 
Sometimes the Xresources are named "XTerm*" not just "xterm*"
It depends if you're putting the values in the .Xresources/.Xdefaults file or in the app-defaults file whose name is XTerm (it used to be in /usr/share/X11/app-defaults/XTerm, but different implementations put it in different places, the manpage should tell you where). In the app-defaults file you use XTerm with the first two letters capitalised. Which I always thought is a pretty hokey old interface, Jim Gettys and Rob Scheiffler. I think it's something to do with being a class name or an instance name, but I can't remember without going and looking it up 😁
 
A better explanation of X11 resources is given here https://archive.org/details/xwindowsystem03quermiss/xwindowsystem03quermiss_200KB/page/180/mode/2up
- starting on page 181. There may be a more up to date version of the book but it covers the basic concepts. While the system enables a very high degree of visual attribute customisation without having to recompile any code, that same high level of flexibility can make the system complex and confusing to understand, especially when multiple levels of libraries, toolkits and widget sets are involved, as in motif.
 
Back
Top