Tuesday, April 1, 2014

Increase font size of virtual terminals

My earlier post shows how to change, on the fly, the font size of X terminal emulators. Besides terminal emulators, Linux provides six virtual terminals which you can bring up from X Window by pressing Control+Alt+F1 to Control+Alt+F6 keys respectively. This post explains how to adjust the font size of virtual terminals for Debian, Ubuntu, and their derivatives.

Replace console-tools with kbd

By default, Debian installs the console package console-tools instead of kbd. With console-tools, the console font is limited to 8 pixels wide. If your concern is eye fatigue, you do want a wider font. Installing the kbd package automatically removes console-tools.

$ sudo apt-get install kbd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  console-tools kbd-compat
The following NEW packages will be installed:
  kbd
0 upgraded, 1 newly installed, 2 to remove and 3 not upgraded.
...snipped...

View live

A bonus for installing kbd is the setfont utility that is included in the package. With setfont, you can temporarily change the font of a virtual terminal, and view it live to decide if you want to configure it permanently.

You can't arbitrarily pick a font for a virtual terminal. The available fonts are stored in the directory /usr/share/consolefonts.

The name of a font file - Uni2-Terminus28x14.psf.gz - tells you 3 key pieces of information:

  • Codeset.

    For English-speaking users, select the codeset Uni2 or Lat15.

  • Font face.

    Popular choices are Terminus and Fixed.

  • Font size.

    The font size is specified by 2 numbers in pixels represented as HEIGHT x WIDTH. If the width is 8 pixels, then only the height is specified. For comparison purposes, the default console font size is 16 (that is, 16 x 8).

To view a font live, press Control+Alt+F1 keys to bring up virtual terminal #1, and then execute the setfont command.

$ setfont /usr/share/consolefonts/Uni2-Terminus28x14.psf.gz

Configure permanently new font and font size

You can directly edit the console configuration file (/etc/default/console-setup). But, it is much easier to run the reconfigure program as below.

  1. Run dpkg-reconfigure.
    $ sudo dpkg-reconfigure console-setup
    [sudo] password for peter: 
    
  2. Select UTF-8.
  3. Select Combined - Latin; savic Cyrillic; Greek.

    This corresponds to the Uni2 codeset.

  4. Select Terminus.
  5. Select the desired font size.
  6. Run setupcon in virtual terminals.

    If you now switch to a virtual terminal, you will still see the old font size until you run the following command from the virtual terminal.

    $ setupcon
    

No comments: