💾 Archived View for pwshnotes.flounder.online › gemlog › 2024-07-16-console-font.gmi captured on 2024-08-24 at 23:59:13. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-08-18)

-=-=-=-=-=-=-

Change Virtual Console Font Size

openSUSE Tumbleweed follows a rolling release update cycle. And, when there are major updates to KDE, I like to switch to the virtual console (Ctrl+Alt+F1) to run zypper so that the update doesn't fail. Sometimes KDE will reset (and kill the update process) if one of its critical files is updated. So, using the virtual console avoids that potential issue.

The problem I'm having is that the virtual console is impossible to read. The font size is too small. Or, the display resolution is too high. And, I need some way to make the console more readable.

setfont

The easiest and fastest way to fix the issue is to issue the setfont command from within a virtual console. Use the -d option to double the default font size:

setfont -d 

vconsole.conf

If you want to permanently change the font size, you'll have to modify the relevant systemd configuration file. The relevant file is vconsole.conf:

/etc/vconsole.conf

Before you do that, you'll probably want to list the potential fonts. In PowerShell, you can list the contents of the consolefonts directory and look for Lat15 fonts which correspond to English:

Get-ChildItem -Path /usr/share/kbd/consolefonts -Filter Lat15*

   Directory: /usr/share/kbd/consolefonts

UnixMode   User Group   LastWriteTime Size Name
--------   ---- -----   ------------- ---- ----
-rw-r--r-- root root  10/1/2023 06:32 2438 Lat15-Fixed13.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2573 Lat15-Fixed14.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2540 Lat15-Fixed15.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2543 Lat15-Fixed16.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2579 Lat15-Fixed18.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2374 Lat15-Terminus12x6.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2439 Lat15-Terminus14.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2465 Lat15-Terminus16.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2936 Lat15-Terminus18x10.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2962 Lat15-Terminus20x10.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 3185 Lat15-Terminus22x11.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 3212 Lat15-Terminus24x12.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 3498 Lat15-Terminus28x14.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 3827 Lat15-Terminus32x16.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2441 Lat15-TerminusBold14.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2477 Lat15-TerminusBold16.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2986 Lat15-TerminusBold18x10.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 3014 Lat15-TerminusBold20x10.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 3228 Lat15-TerminusBold22x11.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 3265 Lat15-TerminusBold24x12.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 3676 Lat15-TerminusBold28x14.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 3791 Lat15-TerminusBold32x16.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2450 Lat15-TerminusBoldVGA14.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2477 Lat15-TerminusBoldVGA16.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2477 Lat15-VGA14.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2543 Lat15-VGA16.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 3220 Lat15-VGA28x16.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 3312 Lat15-VGA32x16.psf.gz
-rw-r--r-- root root  10/1/2023 06:32 2243 Lat15-VGA8.psf.gz

Linux fonts are stored as bitmaps. So, each font file contains one font with a fixed height and width. The file names typically reflect the font size.

TerminusBold32x16 has one of the largest font sizes available from the console fonts.

If we specify the full font name in vconsole.conf then the virtual consoles should use that font file and therefore font size.

To modify vconsole.conf, you'll need super user access. I'll use sudo and vim to edit the file:

sudo vim /etc/vconsole.conf

The default configuration looks like this:

KEYMAP=us
FONT=eurlatgr.psfu
FONT_MAP=
FONT_UNIMAP=
XKBLAYOUT=us
XKBMODEL=pc105+inet
XKBOPTIONS=terminate:ctrl_alt_bksp

We'll just change the FONT= variable to use the font with a larger size.

KEYMAP=us
FONT=Lat15-TerminusBold32x16
FONT_MAP=
FONT_UNIMAP=
XKBLAYOUT=us
XKBMODEL=pc105+inet
XKBOPTIONS=terminate:ctrl_alt_bksp

This change will take effect after you reboot.

Or, you can apply the changes immediately by restarting the appropriate systemd service:

sudo systemctl restart systemd-vconsole-setup

console-setup

You can also use the third-party console-setup utility.

From the README:

This package provides the console with the same keyboard configuration
scheme that X Window System has. In result, there is no need to
duplicate or change the console keyboard files just to make simple
customizations such as the use of dead keys, the key functioning as
AltGr or Compose key, the key(s) to switch between Latin and non-Latin
layouts, etc. Besides the keyboard, the package configures also the
font on the console. It includes a rich collection of fonts and
supports several languages that would be otherwise unsupported on the
console (such as Armenian, Georgian, Lao and Thai).

Install the console-setup package. It seems to be available for Debian, Ubuntu, and openSUSE. Below, I use zypper on openSUSE Tumbleweed:

sudo zypper install console-setup

The configuration file is simply called "console-setup".

sudo vim /etc/default/console-setup

The default settings are:

# CONFIGURATION FILE FOR SETUPCON

# Consult the console-setup(5) manual page.

ACTIVE_CONSOLES=guess

CHARMAP=guess

CODESET=guess
FONTFACE=TerminusBold
FONTSIZE=16

VIDEOMODE=

# The following is an example how to use a braille font
# FONT='lat9w-08.psf.gz brl-8x8.psf'

You can change the FONTSIZE value to one of the accepted values mentioned in the manual page (eg man console-setup(5)).

For example:

FONTSIZE=16x32

Then, save the changes to the console-setup file.

After switching to a virtual console (eg Ctrl+Alt+F1) and logging in, you can apply the console-setup configuration with the setupcon command. The -f option limits the changes to just the console font.

setupcon -f

Unlike using the vconsole.conf file, console-setup does not have a way to permanently change the font. You will have to run the setupcon command each time you log into a virtual console.

video=

Another option is to use the video kernel parameter.

This solves the problem in a different way. Instead, of increasing the font size, the video option allows you to reduce the screen resolution in the virtual consoles. This has the effect of enlarging the text.

Normally, you would have to modify your boot loader configuration and apply the changes. Since I'm using Tumbleweed, I'll take advantage of the YaST Boot Loader applet. You will be prompted to enter your password--just like when using sudo.

By default, my Parameter field looked like this:

splash=silent quiet security=apparmor

Then I added the video= kernel parameter:

splash=silent quiet security=apparmor video=1024x768

Some other common values are:

When I reboot, the virtual consoles will use this resolution.

The only problem I found with this approach is that using a lower resolution means that your video card will have to switch modes when switching to the virtual console. So, once you press Ctrl+Alt+F1, instead of switching immediately, the system will take a moment to switch video modes. And, you'll have the same problem when switching back to the desktop.

Otherwise, Wayland did not have a problem with the video= parameter being present. And my login screen and desktop were fine with the video kernel parameter applied.

Shell Profile

For commands like setfont and setupcon, you might take advantage of your shell profile to automatically run these commands. Your shell profile is a script that runs when you log in.

In PowerShell, we typically refer to the profile using the PowerShell automatic variable $profile which resolves to your profile file path.

Make sure that $profile exists or create it:

if (!(Test-Path -Path $PROFILE)) 
{
   New-Item -ItemType File -Path $PROFILE -Force
}

Then edit $profile:

vim $profile

I'll add a line to my file and instruct PowerShell to run either setfont or setupcon:

setfont -d

And, since it only makes sense to run this command while logging into a virtual console, we can check the XDG_SESSION_TYPE environment variable for the value 'tty' before running the command.

if ('tty' -eq $Env:XDG_SESSION_TYPE)
{  setfont -d  }

By convention in PowerShell, we place the variable on the right side of the comparison operator to force a scalar comparison. This will output $True or $False and allow the if statement to work properly.

Also, PowerShell uses the Env:\ ($Env:) provider to access environment variables. For Windows users, this can be understood as a type of 'letter drive' that allows you to access environment variables.

By default, Linux uses the Bash shell. So, these changes to my PowerShell profile will only take effect if I change my login shell or if I launch pwsh after logging in. That's fine for me.

I'm less familiar with Bash profiles. Though, if you want to use Bash then I'm sure you can find an appropriate example online: including how to check the value of an environment variable. Your Bash profile probably already has default stuff in it from your Linux distribution. So, add your changes to the bottom of the file.

References

Main Methods

setfont | Arch Manual Pages

vconsole.conf | Arch Manual Pages

console-setup | Debian Manpages

Video Kernel Parameter | Linux Kernel Documentation

Q&A

How to change resolution of virtual terminal? | Linux Systems

Virtual Console Font Size | Unix & Linux Stack Exchange

Mentions Kernel Mode Setting | Unix & Linux Stack Exchange

Can I change the font of the text-mode console? | Unix & Linux Stack Exchange

PowerShell

about_Profiles | Microsoft Learn

about_Environment_Variables | Microsoft Learn

about_Comparison_Operators | Microsoft Learn

about_If | Microsoft Learn

about_Providers | Microsoft Learn

Background

Where is .bash_profile? | NewbeDev

Explanation of Linux Shell Profiles | Greg's Wiki

Virtual Console | ArchWiki

Kernel Mode Setting | ArchWiki

Direct Rendering Manager | Wikipedia

sudo dpkg-reconfigure console-setup | TechInfected

console-setup Source | Debian GitLab

PC Screen Font | Wikipedia

ISO/IEC 8859-1 | Wikipedia

Created: Tuesday, July 16, 2024

Updated: Tuesday, July 16, 2024