Russian in X Window System


Talking to the X

If you are running some flavor of X Window System there is almost a 100% chance you'll be able to get Russian support correctly. The procedure of russification is almost the same for every kind of X, whether it is a pure MIT X or it Sun's OpenWindows or it is XFree86. In case of Sun's X server there are a few additional points that you have to keep in mind, though. Take into account also that when I am talking about Sun's OpenWindows I mean the one not older than 3.5 (comes with Solaris 2.5). The reason for that is that the days of the old OpenWindows 3.0 that came with SunOS are close to an end.
You will need a collection of Russian fonts and a keyboard layout. There are several families: Once you got the fonts, you have to let the server know where to look for them. If you are a system administrator or have a root access, you probably want to put them in some centralized place. The fonts are all (except Type 1 fonts) in sources (.bdf format). Cronyx's set has a very self-explanatory Makefile. Browse through it. The general idea is that you need to run bdftopcf on each bdf-file. You might want to compress the .pcf output, for X servers understand that. Sometimes, I use the following very simple script:
	#!/bin/sh
	for font in `ls *.bdf`
	do
		bdftopcf $font | compress > `basename $font .bdf`.pcf.Z
	done
	rm -f *.bdf
	mkfontdir .
mkfontdir command creates a file fonts.dir in the directory where the fonts are. Then you have to make sure X server knows where to find the fonts:
	% xset fp+ directory_with_fonts
Some X servers like to have a FULL path. For example:
	% xset fp+ /home/serge/fonts/cyrillic/100dpi
Make sure the command finished successfully. You may want to tell xset q to the server. You should see something like this:
	% xset q
	
	... ...

	Font Path:
        /usr/openwin/lib/X11/fonts/F3/,/usr/openwin/lib/X11/fonts/F3bitmaps/,
	/usr/openwin/lib/X11/fonts/Type1/,/usr/openwin/lib/X11/fonts/Speedo/,
	/usr/openwin/lib/X11/fonts/misc/,/usr/openwin/lib/X11/fonts/75dpi/,
	/usr/openwin/lib/X11/fonts/100dpi/,/usr/openwin/lib/X11/fonts/Xt+/,
	/usr/dt/config/xfonts/C,/home/serge/fonts/cyrillic/100dpi
Try to issue xlsfonts to see the newly installed fonts. You should see something like this:
	$ xlsfonts '*koi8*'
	
	....

	-cronyx-fixed-medium-r-normal--20-200-75-75-c-100-koi8-r
	-cronyx-fixed-medium-r-normal--24-170-100-100-c-120-koi8-r
	-cronyx-fixed-medium-r-semicondensed--0-0-75-75-c-0-koi8-r
	-cronyx-fixed-medium-r-semicondensed--13-120-75-75-c-60-koi8-r
	-cronyx-helvetica-bold-o-normal--0-0-100-100-p-0-koi8-r
	-cronyx-helvetica-bold-o-normal--0-0-75-75-p-0-koi8-r

	....
You can now use your fonts in any application through the usual X mechanism.
Some people, however, do want more: they want to install scalable fonts, so they can set any size. X servers support scalable fonts, specifically Type 1. True Type are also supported. Refer to the documentation on X-TrueType Server, xfstt server or, if you prefer, TrueType to Type 1 converter.
Support for Type 1 fonts is a little bit different on the Sun's X server because it uses rasterizer from Adobe, whereas the pure MIT X server uses the code donated by IBM.
First of all, Sun's server supports Type 1 fonts only in the .pfa format. It is not a problem at all because you can always get .pfa from .pfb with a zillion utilities floating on the net. You can fetch one of the packages called adobe2mf. The package has pfb2pfa utility in it. Compilation is trivial.
The next thing you need is to create a file fonts.scale. You can get my quick example, write your own or you can use type1inst Perl script. This file is based on the set mentioned above. As you can see, it has "-*-adobe-fontspecific" instead of "-*koi8-r" (as it should be). It is true ONLY for Sun's X server which I use in my everyday's work. Here is an explanation.
I had a very extensive conversation with people from Sun. They explained me this in the following way. The encoding mechanism that they use for the Type 1 font is a bit different from other X servers (because of the Adobe software they use to rasterize the fonts). All information about the encodings that the server uses are described in different files of $OPENWINHOME/lib/X11/fonts/encodings. Each .enc file there describes one particular encoding (iso8859-1.enc, iso8859-2.enc, symbol.enc, etc.), and the general information is written in encodings.dir. According to Sun, if you want to add a new encoding, you have to create a file, say koi8-r.enc, put it in this directory, edit encodings.dir and restart the server. The file has to be created in accordance to the Adobe Cyrillic specifications. Of course, you still have to run mkfontdir that will create a fonts.dir and add the directory to your font path with xset fp+.
There is also a little "Sun-only" thing you have to do. You have to create a PostScript resource file. In the same directory where you have the fonts and fonts.* files. Create it with makepsres (I suggest reading man pages on it first). The file can have any name but it must have an extention .upr. It works for me this way.
Richard Verhoeven (rcb5@win.tue.nl) tells me this, however:
	You mention to use the makepsres utility to create a PSres.upr
	file.  Although I read the manual page, I did not specify the
	directory argument.  If you don't specify the directory, it
	will create a PSres.upr file in de current directory for the current
	directory. However, the PSres.upr file will not contain the path
	that is used to resolve the files mentioned in the .upr file.
	According to the documention of the DPS system, that directory is
	optional. In practise, that directory is needed.  Without it, adding
	the directory with "xset fp+" results in undefined behaviour:
	sometimes it works, sometimes it doesn't.  With it, it works without
	problems, even with .pfb or without .afm.
Well, I tried to do thing by the book, adding a new encoding. It does not work! I have heard the rumors that it is one of the bugs in OW 3.5 that they know about. I did not check 2.6 myself yet, though.
So, because adding KOI-8 for the Type 1 fonts in the right way does not work on Sun's X server, I set it to -*-adobe-fontspecific which is some generic encoding you can use. It is a shame, actually, becuase such programs as Netscape would not work properly. So you still have to use bitmaps in these programs.
On other servers, for example on XFree86, you do not need any of this. Just create fonts.scale with "-*-koi8-r", run mkfontdir . and enjoy.

Dealing with X terminals

There is nothing really special in them. You do everything as you would do for any other fonts. If your organization runs a font server, just ask your system administrator to add the directory to the font server path. You can run your own font server. I should say, it is an EXTREMELY useful thing. I really recommend it to everyone. Read man pages on xfs or, if it is Sun's server, fs. I noticed that some sysadms on Suns do not bother installing font server because they do not know what it is. Too bad! If they are managing a large network, it would really help them.
You can read more on this in Alexander Belopolsky's little HOWTO.

Keyboards

Ugh... It is a funny subject, I should say. Why? Well, in X, there is an absolutely wonderful utility called xmodmap which you are supposed to use in order to remap the keyboard. But... On many X servers it has bugs. It needs a little file which contains a standard Russian keyboard mapped on the KOI-8 encoded fonts. You can try it on your server.
I suggest, however, using a different utility written by Alexander Lukianov (lav@yars.free.net). The program XRusKb is basically a hacked version of xmodmap with a nice graphical interface added to it. It can also compile with either Motif, Xaw or Xt. You get the full set of options when you compile it with Motif.

Locales

XFree86 already has KOI8-R set up, so don't need to worry about it. If it is something else, you might want to get the locale and install it wherever your X server wants to find them. Of course, you have to be a system administrator (or be able to sneak through with the root password).