Printing is always tricky. There are different printers from different vendors with different facilities. Even for a native printing there is no uniform solution (this applies not only to UNIX, but to other operating systems as well.
Printers have different control languages and often they have very different views on foreign language support. The good news is that on control language seems to be recognized as a de-facto standard for print job description - it is a PostScript language developed by Adobe Corporation.
Another problem is a variety of requirements to the print services. For example, sometimes you want just to print a piece if C program, containing comments in Russian, so you don't need any pretty-printing - just a raw ASCII output in a single font. Another time, when you design a postcard for your girlfriend, you'll probably need to typeset some document with different fonts etc. This will definitely require more effort to setup Cyrillic support.
To accomplish the former task you just have to make your printer understand one Cyrillic font and (maybe) install some filter program to generate data in appropriate format. To accomplish the latter one, you have to teach your printer different fonts and have a special software.
There is also something in the middle, when you get a program which knows how to generate both the fonts and the appropriate printer input, so you can say do some aource code pretty-printing without sophisticated word processing systems.
All these options will be more or less covered below.
If you have a good old dot matrix printer and all you need is to print a raw KOI-8 text, try the following:
rc
file at a boot
time.
Thus, having Cyrillic characters in the upper part of the printer's character set will allow you to print you texts in Russian without any hussle.
Alternatively to the KOI-8 fonts you may try to use the Alt font. There are two reasons for that:
However in this case, you'll have to convert your texts from
KOI-8 to Alt before sending them to a printer. This is quite
easy, since there are a lot of programs doing that (see
translit for example), so you just have to
call such program properly in the if
field in
/etc/printcap
file. For example, with the translit
program you may specify:
if=/usr/bin/translit -t koi8-alt.rus
See printcap(5) for details.
One great way to cope with different printers and fonts is to use TeX. TeX drivers handle all details, so once you make TeX understand Cyrillic fonts, you are done.
Another possibility is to use PostScript. I decided to devote an entire chapter to the subject, since it is not simple.
Finally, there are other word processors, which have printer drivers. I never tried anything apart from TeX, so I cannot suggest anything.
If all you need is just to print an ASCII text without any additional word processing, you may try to use some programs, which would convert your Cyrillic text to a ready-to-process TeX file. One of the best programs for such purposes is translit. In this case, you don't even have to bother about installing the Cyrillic fonts for TeX, since translit uses a Washington Cyrillic package, which is included in most TeX distributions (or am I wrong?)
Sometimes you have just a plain ASCII KOI-8 text and you want to print it just to get it on the paper. One of the easiest ways to achieve that is to use special programs converting text to PostScript.
There are a number of programs doing such conversion. I personally prefer a2ps. Originally developed as a simple text-to-PostScript converter it became a big and highly configurable program with many options and allows you to manage various page layouts, syntax highlighting etc. Another tool (now available as a part of the GNU project) is enscript.
The main problem with such programs is that they know nothing about Cyrillic fonts. Right now I am investigating a possibility of including Cyrillic fonts in them in order to understand Cyrillic. Stay in touch.
Nevertheless all the blah-blah above would be pointless without any real advice. So, there we go.
As usual, GNU is the winner. The GNU enscript program is designed for converting text to PostScript and has perfect non-ASCII codeset support. It doesn't have Cyrillic PostScript fonts, but it is very easy to get them, as will be explained below (thanks to Michael Van Canneyt):
textbook.tar.gz
from
the Cyrillic Software collection on
sunsite.unc.edu. Extract it to a directory, where
enscript fonts are located (usually
/usr/share/enscript
). Now change to that directory and run
the following command:
mkafmmap *.afm
enscript --font=Textbook8 --encoding=koi8 some.file
If you don't want a really quick and dirty solution and you don't care about the output quality and all you need is just Cyrillic on the paper, try the rtxt2ps package. It is a very simple no-frills text-to-PostScript conversion program. The output quality is not very good (or, to be honest, just bad) but it does it's job.
Another resort is a hacked version of a2ps. This one is quite old, so don't expect all new version's bells and whistles in it. But it prints Cyrillic text and the quality is sufficiently better than that of rtxt2ps. However, I experienced various kinds of problems with it - like I couldn't print more than two pages (???).