0

OS: Ubuntu 18.04. I think it is distribution-independent. The Arch Linux uses the same principle, but do it by another way.

I set the tty's font by editing the /etc/default/console-setup file:

CODESET="guess"
FONTFACE="TerminusBold"
FONTSIZE="22x11"

The font's file is located in the /usr/share/consolefonts/. It has psf format.

From Wikipedia:

PC Screen Font (PSF) is a bitmap font format currently employed by the Linux kernel for console fonts. Documentation of the PSF file format can be found within the source code of the Linux Kernel.

Questions:

  1. Does kernel load this file into the kernel space?
  2. If not, then how the tty (which resides in the kernel) renders characters from the .psf file, which resides in the /usr/share/consolefonts/?
  3. I were thinking, that the kernel is a solid piece of code, which doesn't use any user files (except kernel modules), for reliability and security reasons. Am I wrong? Or console fonts are exception?
  4. How can I check, which .psf file was loaded specifically? Because the /usr/share/consolefonts/ folder has many TerminusBold22x11.psf.gz files, with different codesets. I want to know which particular file was used. I check dmesg and syslog, but didn't find such information there.
  • 2
    The place to look is console_ioctl. – Thomas Dickey Oct 6 '18 at 18:20
  • @ThomasDickey Did you mean, use console_ioctl for checking, which .psf file was loaded specifically? Does this method require writing a C program? – MiniMax Oct 6 '18 at 19:47
  • 2
    If you read the whole manual page, it answers your questions by pointing out some misconceptions. – Thomas Dickey Oct 6 '18 at 19:54
  • fonts are loaded into user memory somehow and then copied (might be an different-from-userspace internal format) into kernel. No file have to be involved. This answers 124, then 3, kernel can load module from fd or memory, providing more flexibility. – 炸鱼薯条德里克 Oct 7 '18 at 0:25
0

I found answer to the 4-th question for Ubuntu 18.04:

sudo strace -s99 setupcon 2>&1 | grep '.psf' 

Output

read(3, "/etc/console-setup/cached_Uni2-TerminusBold22x11.psf.gz\n", 128)

Explanation:

By using the setupcon program the systemd does console setup on the OS booting. It can be viewed in this file: /lib/systemd/system/console-setup.service. So, by repeating setupcon manually, we have possibility to strace its system calls and find the used font file.

setupcon is a program for fast and easy setup of the font and the keyboard on the console. Most of the time you invoke setupcon without arguments. The keyboard configuration is specified in ~/.keyboard or /etc/default/keyboard. The font configuration is specified in ~/.console-setup or /etc/default/console-setup.

  • 1
    The other three parts, as noted, can be answered by reading the manual page and realizing that the kernel provides the way for an application to load the font, but doesn't reach out and read the files itself. – Thomas Dickey Oct 6 '18 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.