Charset / font in the Linux console

5,400

That terminal is called the Linux console, or sometimes a “vt” (short for virtual terminal). The terminology can be confusing, especially since it's used inconsistently and sometimes incorrectly. You can find more information on terminology by reading What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?.

The Linux console supports user-configured fonts, so the answer to your question is “whatever the user set up”. The utility to change the font is consolechars, part of the Linux console tools. Only 8-bit fonts are supported by the hardware, though you can partly work around this by supporting unicode-encoded output but only having 256 glyphs (other characters are ignored). Read the lct documentation (online as of this writing, it should be included in your distribution's package) for more information.

If you use the Linux framebuffer, you can have proper unicode support, either directly or through fbterm.

The half-block characters are included in IBM code page 437, which is supported in ROM most PC video adapters. Depending on what characters you need, this may be enough.

Note that very few people use the Linux console these days. Some people cannot use it for various reasons (not running Linux, running on a remote X terminal, having a video adapter where text mode is buggy, …). I don't recommend spending much energy on supporting it.

Share:
5,400

Related videos on Youtube

Josh Farneman
Author by

Josh Farneman

Updated on September 17, 2022

Comments

  • Josh Farneman
    Josh Farneman over 1 year

    I want to write a game which runs in a terminal. I do some terminal coloring and wanted to use some unicode characters for nice ascii art "graphics". But a lot of unicode characters aren't supported in the linux terminal (the non-X terminal, I don't know how you call it... VT100? I mean the terminal which uses the text mode for output, no graphic mode, so the same font as in bios is used to display the text.)

    For example, I wanted to draw half character "pixels" using the "half block" characters U+2580 (▀) and U+2584 (▄) but these are not supported in the terminal. (These are only examples - I want to use a lot more special characters...)

    Which characters does this font support? Is there any document or table listing these characters? Is this device-dependent or is there any "standard"?

  • Josh Farneman
    Josh Farneman about 13 years
    Yeah, I already feared that I dont get proper unicode support in the terminal... But thanks for the IBM code page link, I searched for this but didn't know what to search for. I think these characters are enough. I do not want to support only the linux terminal but I want to support it too. Can you tell me how I can use the IBM 437 chars using unicode? The unicode characters I mentioned don't get "converted" automatically. (They are properly displayed in a graphical console (I use gnome-terminal with unicode).) Is there any way of supporting both console types?
  • Josh Farneman
    Josh Farneman about 13 years
    To be more specific, I code in C++ and have access to termios and stuff... Maybe I can set the encoding of the underlying console manually?
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' about 13 years
    @leemes: termios provides a portable interface to text terminals. You'll have to go beyond that interface to set up the Linux console for unicode (more precisely, your program would output unicode and the console driver would translate your output to the encoding of a cp437 font). I don't know the exact commands involved, but I think the consolechars man page and the lct documentation has the information you need.