2

My Linux kernel, by default, uses the big 16x32 Terminus font that is built into the kernel (with CONFIG_FONT_TER16X32) for the framebuffer console.

I just installed the "kbd" package and ran setfont with no arguments, and it switched to some other font that looks tiny on my screen. setfont seems to only support loading a font from a file, and not one of the kernel's built-in fonts. Also, the 16x32 Terminus font is not included in the kbd package.

So, how can I switch my console back to the default built-in font that I see while the system is booting up? Running setfont with no arguments does not do this. I am looking for a non-distro-specific solution.

1 Answer 1

3

I can’t find a ready-made tool which can do this, but the following C program will reset /dev/tty (if it’s a Linux VT) to the default font:

#include <fcntl.h>
#include <linux/kd.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>

int main(int argc, char **argv) {
  struct console_font_op cfo = { .op = KD_FONT_OP_SET_DEFAULT };
  int fd;
  
  fd = open("/dev/tty", O_RDONLY);
  if (fd < 0) perror("Opening /dev/tty");
  else if (ioctl(fd, KDFONTOP, &cfo)) perror("Setting the default font");
}

Save that to defaultfont.c, build it with make defaultfont (no Makefile needed), and run ./defaultfont.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .