How do I permanently change the console TTY font type so it holds after reboot?

28,529

Solution 1

See https://askubuntu.com/questions/630118/ and https://askubuntu.com/questions/328463/.

This problem seems to be caused by a mismatch in the naming of fonts that console-setup expects vs what are in /usr/share/consolefonts/, and thus copied to /etc/console-setup/ when you pick a font to use (using dpkg-reconfigure console-setup).

If you go to a console and do an strace /lib/udev/console-setup-tty fbcon, you can see that it is trying to open fonts like this:

/etc/console-setup/Lat15-TerminusBold11x22.psf

But if you look in /etc/console-setup/, there are only a handful of fonts in there (the ones you picked), and they look more like this:

/etc/console-setup/Lat15-TerminusBold22x11.psf.gz

One has height x width, and the other has width x height.

The problem can be fixed in a few ways.

(1) /lib/udev/console-setup-tty could be fixed - This is the more permanent, upstream solution.

(2) You could manually change /etc/default/console-setup, reversing the height and width in FONTSIZE. This will need to be done each time you change the fonts using dpkg-reconfigure console-setup. But when the machine reboots, that preference is kept.

(3) You could install the fonts that console-setup-tty expects. This is what I call the "overkill" option. I did it like this:

In /etc/rc.local:

# install console fonts and then set up console
/etc/console-setup/fonts.sh install
/lib/udev/console-setup-tty fbcon

Create a script called /etc/console-setup/fonts.sh:

#!/bin/bash

action=$1

srcdir="/usr/share/consolefonts"
parent="/etc/console-setup"
subdir="fonts"

case "$1" in
    install)
        # console fonts are not named properly in Ubuntu 15.04, compensate
        [[ -d $parent/$subdir ]] || mkdir $parent/$subdir
        for x in $( cd $srcdir ; ls -1 ) ; do
           # rearrange the two numbers from HHxWW to WWxHH
           y=$(echo "$x" | sed -e 's/^\([^-]*\)-\([^0-9]*\)\([0-9]*\)x\([0-9]*\).psf.gz/\1-\2\4x\3.psf.gz/g')
           # whether the pattern above matches or not, we'll be uncompressing here
           z=${y/.psf.gz/.psf}
           [[ ! -f $parent/$subdir/$z ]] && zcat $srcdir/$x > $parent/$subdir/$z
           [[ ! -L $parent/$z ]] && ln -sv $subdir/$z $parent/$z
        done
        ;;
    uninstall)
        rm -rf $parent/$subdir
        # only remove broken links (links to the fonts we removed above)
        rm $(find -L $parent -type l)
        ;;
    *)
        echo "$(basename $0) install|uninstall"
        ;;
esac

exit 0

For a quick pragmatic solution, I'd do #2, with a comment in the file that it may be need to be re-done if you choose a different font (assuming the comment does not also get overwritten).

But #3 works well with minimal fuss or mess.

Solution 2

I've recently encountered this problem on my Ubuntu 15.04 64 bit box. The setupcon command set the fonts to what I had set with dpkg-reconfigure console-setup.

I added setupcon to my rc.local, but that left a gap where the font was still wrong (because rc.local is executed after the console is setup), so that wasn't good enough for me.

So, I decided to go deeper. I edited my /lib/systemd/system/console-setup.service file and appended ExecStart=/bin/setupcon to the end of the file. That will call setupcon when the console is setup, correcting the fonts on boot without a time gap.

Solution 3

The simplest solution I found was to edit /etc/default/console-setup to set

FONT="Lat7-Terminus32x16.psf.gz"

and comment out everything else except the ACTIVE_CONSOLES line.

You can apply this immediately with setupcon, and it will be applied after rebooting as well.

Specifying the font name rather than the individual components works around the naming mismatch described by Alan Porter.

Share:
28,529

Related videos on Youtube

Andy Fusniak
Author by

Andy Fusniak

Updated on September 18, 2022

Comments

  • Andy Fusniak
    Andy Fusniak over 1 year

    I'm running Ubuntu 15.04 64-bit Desktop Edition (A Debian based Linux).

    I used sudo dpkg-reconfigure console-setup from the command line to change the default console font type to Terminus. Immediately afterwards the console fonts changed to the sharper looking font face.

    However, after a reboot Ctrl+Alt+F1 takes me to a console window that has the original chunkier looking style font face, not my selected choice.

    The /etc/default/console-setup file appears to have been changed to my choices.

    # CONFIGURATION FILE FOR SETUPCON
    
    # Consult the console-setup(5) manual page.
    
    ACTIVE_CONSOLES="/dev/tty[1-6]"
    
    CHARMAP="UTF-8"
    
    CODESET="guess"
    FONTFACE="Terminus"
    FONTSIZE="8x16"
    
    VIDEOMODE=
    
    # The following is an example how to use a braille font
    # FONT='lat9w-08.psf.gz brl-8x8.psf'
    

    How do I permanently change the console font to use my preferred font?

    • toxefa
      toxefa about 9 years
      This answer on askuntu may help you: askubuntu.com/a/396254/399775
    • Andy Fusniak
      Andy Fusniak about 9 years
      So it appears that it's a known bug. Unfortunately in the askubuntu question the answer suggested is to create an upstart script. Ubuntu 15.04 and Debian have now adopted systemd and no longer use upstart.
  • DaVince
    DaVince about 4 years
    I can confirm five years later that this has been fixed in (1). :)