KOI8-R for X Window System

Warning: this section does not cover general Unix things, look at Unix section instead.


  • Bitmap fonts:
    • Cronyx KOI8-R font set v2.3.1 for X11R6 (*.pcf.gz)
    • Cronyx KOI8-R font set v2.3.1 for X11R5 (*.pcf.Z)

    XFree86 v3.3 & v4 already includes an older version of these fonts, but here is the latest version. You can also download drop-in source replacement for obsoleted KOI8-R fonts sources distributed with XFree86 v4, put it into xc/fonts/bdf/cyrillic source directory before building.

    WARNING: These fonts do NOT strictly conforms to KOI8-R as per RFC 1489, you can rely on the letters area only. Feel free to fix these fonts and contribute them back to me, if you are interested you can download the sources of these fonts.

    The usual place for these fonts is the /usr/local/lib/X11/fonts/cyrillic/{100dpi,75dpi,misc} set of directories, but if you can't modify system directories, just put them in any directory. You need to check that these directories are first in your FontPath, look in XF86Config file (/etc/XF86Config for XFree86 v3 or /etc/X11/XF86Config for XFree86 >= v4) if you install the fonts in the system directory. Otherwise type

    xset +fp misc_dir,100dpi_dir,75dpi_dir

    to add them locally. Use

    xset q

    to check if they are first in the FontPath.

  • OpenType / TrueType fonts:
    • Free Microsoft core fonts for the web
      (Andale Mono, Arial Black, Arial, Comic MS, Georgia, Impact, Times New Roman, Trebuchet MS, Verdana, Webdings, Courier)

    Download msttcorefonts.tgz package and extract it into /usr/local/lib/X11/fonts/ (the directory must be in /usr/local/etc/fonts/fonts.conf). Add

     FontPath "/usr/local/lib/X11/fonts/msttcorefonts/" 
    to your /etc/X11/xorg.conf. fonts.dir is already in the package, I use
     ttmkfdir -p 
    to create it with encodings.dir and some encodings it understands. After all, run
     fc-cache -f -v 
    to get new directory cached.

  • Type1 fonts:
    • Type1 KOI8-R font set X11 (two Couriers, Times, Arial)

    WARNING: These fonts (excluding ERKurier) do NOT conform to KOI8-R strictly as per RFC 1489, you can rely on the letters area only.

    The usual place for these fonts is the /usr/local/lib/X11/fonts/Type1 directory, but if you can't modify system directories, just put them in any directory and set FontPath as described above. See README file inside the archive and koi8 postscript fonts page (in Russian) for more info.

  • Xorg somehow miss koi8-r.enc file in the /usr/local/lib/X11/fonts/encodings. You can download it and place there. Don't forget to rebuild directory index.

  • See also TrueType Fonts in Debian mini-HOWTO.


  • X11R5 NLS workaround .
    Unpack it into /usr/local/lib/X11/. If you can't modify system directories, put it in any directory and then set the XNLSPATH environment variable to point to this directory.
  • X11R6 Locale.
    Unpack it into /usr/local/lib/X11/locale. You don't need it for XFree86 3.3*, because it is already included in the standard distribution.

To activate locale support you need to set your LANG environment variable to ru_RU.KOI8-R


Only the latest X11R6 and XFree86 provide for proper KOI8-R keyboard input (in terms of X11 internationalization) using separate Cyrillic_* keysyms (different from ISO 8859-1 keysyms); let's call this the right method. Different keysyms are needed for multilanguage processing, i.e. your xterm or properly internationalized editor can view/input Russian, Latin1, Greek and Japanese text at once and store it in a file using X11 pre-defined escape sequences to switch between languages. Since there is no standard ISO 2022 escape sequence for KOI8-R, X11 assigns the following non-standard C string to access the upper half of KOI8-R: "\033%/1\200\210koi8-r\002", to access the lower half (which is identical to the lower half of ISO 8859-1) you can use the following standard ISO 2022 escape sequence: "\033(B". Internally, when Cyrillic_* keysym is pressed for the first time, the X11 escape sequence for KOI8-R is generated to allow proper fonts switching. The new method is not backward compatible with old applications, examine the detailed warning below.

Подробнее об X Keyboard Extension (XKB) см. странички И. Паскаля.
About X Keyboard Extension (XKB) details see I. Pascal's pages.

ATTENTION: XFree86 3.3.3 introduced an Xlib bug which replaces the KOI8-R keyboard table with an ISO 8859-5 table. Use this patch to fix the bug.

For other X11 versions, you can resort to the so-called Xmodmap hack method, with ISO 8859-1 keysyms cheating used to disguise KOI8-R keycodes for ISO 8859-1 keycodes. X11 developers are strongly against this method since it breaks their internationalization concept, so you should avoid using it when possible.

XFree86 >= v3 (the right method)
This XFree86 version is capable of working correctly with KOI8-R keys when Cyrillic_* keysyms are used (e.g. in XKB mode).

WARNING: Most of the old and obsolete applications will not work with the KOI8-R keyboard as they are. X11 developers are aware of this situation, but say that nothing fancy can be done other than modifying the old programs: a few lines of code have to be added, i.e. in order to work, an application's sources must be at least minimally localized according to the X11R6 main strategy:

  • If your application does not use Xt or any other Xt-based toolkit like Xaw* or Motif/lesstif and is based directly on Xlib, use

     #include <X11/Xlocale.h> 
    header and call
     setlocale(LC_CTYPE, ""); 
    early in the main() function of your application.

  • For Xt-based applications (most applications) it's best to call
     XtSetLanguageProc(NULL, NULL, NULL); 
    early in the main() function of your application.

  • For GTK applications call
    early in the main() function of your application.

Suggest these methods to any application author you have problems with.

To enable the Russian keyboard, add this lines to the "Keyboard" section of your XF86Config configuration file. In the following examples caps_toggle means CapsLock switcher.

For XFree86 v3, /etc/XF86Config:

 XkbLayout "ru" XkbOptions "grp:caps_toggle" 

For XFree86 >= v4 (but not recent one), /etc/X11/XF86Config:

 Option "XkbLayout" "ru" Option "XkbOptions" "grp:caps_toggle" 

For Xorg, /etc/X11/xorg.conf and new XFree86:

 Option "XkbLayout" "us,ru" Option "XkbOptions" "grp:toggle" 
  1. English layout now isn't enabled by default, like in older versions.
  2. caps_toggle not works because of xkeyboard-config bug (fixed in new builds), use another switcher like Right Alt = toggle.

Also make sure that XkbDisable is turned off (commented out) there.

If you want to edit the keyboard description additionally, you can find it in the text file which is usually called /usr/local/lib/X11/xkb/symbols/ru, the format is almost self-explanatory.

To activate Russian locale and keyboard support you need to set your LANG environment variable to ru_RU.KOI8-R

Older XFree86 releases, prior to 3.2 (a hack method)
Place the XFree86 3.1.2 keyboard mapping table in /usr/local/lib/X11/xinit/.Xmodmap, and you use CapsLock to switch to/from Russian (KOI8-R) keyboard (after X (re)started). I assume that the default xinitrc you use or your ~/.xinitrc picks .Xmodmap as well. If this doesn't work for you, type xmodmap /usr/local/lib/X11/xinit/.Xmodmap directly. If you can't modify system directories, just place the file into any directory and call xmodmap there.

X86 OpenWindows (a hack method)
Try this X86 OpenWindows keyboard mapping table.

Combined (both hack and right methods)
xxkb И. Паскаля - индикатор-переключатель раскладки клавиатуры, в т.ч. позволяет работать с двумя раскладками: для "правильных" и "неправильных" (устаревших) программ.

Others (a hack method)
Xruskb by A. Lukyanov is an Xmodmap-compatible keyboard switcher program.

WARNING: For pure Xmodmap hacking methods (without Xruskb) control keys don't work when the Russian mode is active, this is a known feature.

Applicable Software:

  • Browsers:
  • E-Mail:
    • Red! Thunderbird (this MUA/Newsreader supports KOI8-R)
    • Red! XF-Mail (an XForms library ased MUA, MIME/POP/SMTP/IMAP4/XFaces, supports KOI8-R)

Software Tuning: