home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 11 / IOPROG_11.ISO / docs / cyrill~1 < prev    next >
Encoding:
Text File  |  1997-08-17  |  61.6 KB  |  1,476 lines

  1.   The Linux Cyrillic HOWTO
  2.   Alexander L. Belikoff, (abel@bfr.co.il)
  3.   v3.0, 13 August 1997
  4.  
  5.   This document describes how to set up your Linux box to typeset, view
  6.   and print the documents in the Russian language.
  7.  
  8.   1.  General notes
  9.  
  10.   1.1.  Introduction
  11.  
  12.   This document covers the things you need to successfully typeset,
  13.   view, and print documents in Russian under Linux. Although this
  14.   document assumes your using Linux as an operating system, most of
  15.   information presented is equally applicable to many other Unix
  16.   flavors. I shall try to keep the distinction as visible as possible.
  17.  
  18.   There are a number of popular Linux distributions. As an example
  19.   system I describe the RedHat 3.0.3 Linux (Picasso) and the RedHat 4.1
  20.   Linux (Vanderbildt) - the one I am personally using. Nevertheless, I
  21.   shall try to highlight the differences, if they exist, in the
  22.   Slackware Linux setup.
  23.  
  24.   Since such setup directly modifies and extends the Operating System,
  25.   you should understand, what you are doing. Even though I tried to keep
  26.   things as easy as possible, having some experience with a given piece
  27.   of software is an advantage. I am not going to describe what the X
  28.   Window System is or how to typeset the documents with TeX and LaTeX,
  29.   or how to install printer in Linux. Those issues are covered in other
  30.   documents.
  31.  
  32.   For the same reason, in most cases I describe a system-wide setup, by
  33.   default requiring root privileges. Still, if there is a possibility
  34.   for user-level setup, I'll try to mention it.
  35.  
  36.   NOTE: The X Window System, TeX and other Linux components are complex
  37.   systems with a sofisticated configuration. If you do something wrong,
  38.   you can not only fail with Russian setup, but to break the component
  39.   as well, if not the entire system. This is not to scare you off, but
  40.   merely to make you understand the seriousness of the process and be
  41.   careful. Preliminary backup of the config files is highly recommended.
  42.   Having a guru around is also advantageous.
  43.  
  44.   1.2.  Availability and feedback
  45.  
  46.   This document is available at sunsite.unc.edu or tsx-11.mit.edu as a
  47.   part of the Linux Document Project. Also, it may be available at
  48.   various FTP sites containing Linux. Moreover, it may be included as a
  49.   part of Linux distribution.
  50.  
  51.   You may also get it directly from the author at ftp.netvision.net.il.
  52.  
  53.   If you have any suggestions or corrections regarding this document,
  54.   please, don't hesitate to contact me as belikoff@netvision.net.il. Any
  55.   new and useful information about Cyrillic support in various Unices is
  56.   highly appreciated. Remember, it will help the others.
  57.  
  58.   1.3.  Acknowledgments and copyrights
  59.  
  60.   Many people helped me (and not only me) with valuable information and
  61.   suggestions. Even more people contributed software to the public
  62.   community. I am sorry if I forgot to mention somebody.
  63.  
  64.   So, here they go:
  65.  
  66.   ╖  Bas V. de Bakker
  67.  
  68.   ╖  David Daves
  69.  
  70.   ╖  Serge Vakulenko
  71.  
  72.   ╖  Sergei O. Naoumov
  73.  
  74.   ╖  Winfried Truemper
  75.  
  76.   ╖  Ilya K. Orehov
  77.  
  78.   ╖  Michael Van Canneyt
  79.  
  80.   This document is Copyright (C) 1995,1997 by Alexander L. Belikoff. It
  81.   may be used and distributed under the usual Linux HOWTO terms
  82.   described below.
  83.  
  84.   The following is a Linux HOWTO copyright notice:
  85.  
  86.        Unless otherwise stated, Linux HOWTO documents are copy¡
  87.        righted by their respective authors. Linux HOWTO documents
  88.        may be reproduced and distributed in whole or in part, in
  89.        any medium physical or electronic, as long as this copyright
  90.        notice is retained on all copies. Commercial redistribution
  91.        is allowed and encouraged; however, the author would like to
  92.        be notified of any such distributions.
  93.  
  94.        All translations, derivative works, or aggregate works
  95.        incorporating any Linux HOWTO documents must be covered
  96.        under this copyright notice.  That is, you may not produce a
  97.        derivative work from a HOWTO and impose additional restric¡
  98.        tions on its distribution. Exceptions to these rules may be
  99.        granted under certain conditions; please contact the Linux
  100.        HOWTO coordinator at the address given below.
  101.  
  102.        In short, we wish to promote dissemination of this informa¡
  103.        tion through as many channels as possible. However, we do
  104.        wish to retain copyright on the HOWTO documents, and would
  105.        like to be notified of any plans to redistribute the HOWTOs.
  106.  
  107.   If you have questions, please contact Greg Hankins, the Linux HOWTO
  108.   coordinator, at gregh@sunsite.unc.edu. You may finger this address for
  109.   phone number and additional contact information.
  110.  
  111.   Unix is a technology trademark of the X/Open Ltd.; MS-DOS, Windows,
  112.   Windows 95, and Windows NT are trademarks of the Microsoft Corp.; The
  113.   X Window System is a trademark of The X Consortium Inc. Other
  114.   trademarks belong to the appropriate holders.
  115.  
  116.   2.  Characters and codesets
  117.  
  118.   In order to understand and print characters of various languages, the
  119.   system and software should be able to distinguish them from other
  120.   characters. That is, each unique character must have a unique
  121.   representation inside the operating system, or the particular software
  122.   package. Such collection of all unique characters, that the system is
  123.   able to represent at once, is called a codeset.
  124.  
  125.   At the time of the most operating system's creation, nobody cared
  126.   about software being multilingual. Therefore, the most popular codeset
  127.   was (and actually is) an ASCII (American Standard Code for Information
  128.   Interchange).
  129.  
  130.   The standard ASCII (aka 7-bit ASCII) comprises 128 unique codes. Some
  131.   of them ASCII defines as real printable characters, and some are so-
  132.   called control characters, which had special meanings in the old
  133.   communication protocols. Each element of the set is identified by an
  134.   integer character code (0-127). The subset of printable characters
  135.   represents those found on the typewriter's keyboard with some minor
  136.   additions. Each character occupies 7 least significant bits of a byte,
  137.   whereas the most significant one was used for control purposes (say,
  138.   transmission control in old communication packages).
  139.  
  140.   The 7-bit ASCII concept was extended by 8-bit ASCII (aka extended
  141.   ASCII). In this codeset, the characters' codes' range is 0-255. The
  142.   lower half (0-127) is pure ASCII, whereas the upper one contains 127
  143.   more characters. Since this codeset is backward compatible with the
  144.   ASCII (character still occupies 8 bit, the codes correspond the old
  145.   ASCII), this codeset gained wide popularity.
  146.  
  147.   The 8-bit ASCII doesn't define the contents of the upper half of the
  148.   codeset. Therefore the ISO organization took the responsibility of
  149.   defining a family of standards known as ISO 8859-X family. It is a
  150.   collection of 8-bit codesets, where the lower half of each codeset
  151.   (characters with codes 0-127) matches the ASCII and the upper parts
  152.   define characters for various languages. For example, the following
  153.   codesets are defined:
  154.  
  155.   ╖  8859-1 - Europe, Latin America (also known as Latin 1)
  156.  
  157.   ╖  8859-2 - Eastern Europe
  158.  
  159.   ╖  8859-5 - Cyrillic
  160.  
  161.   ╖  8859-8 - Hebrew
  162.  
  163.   In Latin 1, the upper half of the table defines various characters
  164.   which are not part of the English alphabet, but are present in various
  165.   european languages (german umlauts, french accentes etc).
  166.  
  167.   Another popular extended ASCII implementation is so-called IBM
  168.   codepage (named after some computer company, that developed this
  169.   codeset for it's infamous personal computers). This one contains
  170.   pseudo-graphic characters in the upper half.
  171.  
  172.   Software, that doesn't make any assumptions about the 8-th bit of the
  173.   ASCII data is called 8-bit clean. Some older programs, designed with
  174.   7-bit ASCII in mind are not 8-bit clean and may work incorrectly with
  175.   your extended ASCII data. Most of packages, however, are able to deal
  176.   with the extended ASCII by default, or require some very basic setup.
  177.   NOTE: before posting the question "I did all setup right, but I cannot
  178.   enter/view Cyrillic characters!", please consult the section ``'' for
  179.   the notes on the program, you are using.
  180.   For information about making your software 8-bit clean, see section
  181.   ``''.
  182.  
  183.   Since on most systems character occupies 8 bits, there is no way to
  184.   extend ASCII more and more. The way to implement new symbols in ASCII-
  185.   based codesets is creation of other extended ASCII implementations.
  186.   This is the way, the Cyrillic ASCII set is implemented.
  187.  
  188.   We already mentioned ISO 8859-5 standard as the one defining the
  189.   Cyrillic codeset. But as it often happens to the standards, this one
  190.   was developed without taking into account the real practices in the
  191.   former USSR. Therefore, one thing that standard really achieved was
  192.   another degree of confusion. I wouldn't say that ISO 8859-5 is widely
  193.   used anywhere.
  194.  
  195.   Other standards for Cyrillic include the so-called Alt codeset and
  196.   Microsoft CP1251 codepage. The former one was developed by (who?) for
  197.   MS-DOS quite a while ago. Back then, there was not very buzz yet about
  198.   internetworking, so the intention was to make it as compatible as
  199.   possible with the IBM standard. Therefore the Alt codeset is
  200.   effectively the same IBM codepage, where all specific European
  201.   characters in the upper half were replaced with the Cyrillic ones,
  202.   leaving the pseudographic ones. Therefore, it didn't screw the text
  203.   windowing facilities and provided Cyrillic characters as well.  The
  204.   Alt standard is still alive and extremely popular in MS-DOS.
  205.  
  206.   Microsoft CP1251 codepage is just an attempt of Microsoft to come up
  207.   with the new standard for Cyrillic codeset in Windows. As far as I
  208.   know, it is not compatible with anything else (not very surprizing,
  209.   huh?)
  210.  
  211.   And finally there is KOI-8. This one is also quite old, but it was
  212.   designed wisely and nowadays the design points of it look really
  213.   useful.
  214.  
  215.   Again, it is compatible with ASCII, and the Cyrillic characters are
  216.   located in the upper half. But the main design point of KOI-8 is that
  217.   the Cyrillic characters' positions must correspond to the English
  218.   characters with the same phonetics. Namely, if we set the eighth bit
  219.   of the English character 'a', we'll get the Cyrillic 'a'.  This means
  220.   that, given the Cyrillic text written in KOI-8, we can strip the
  221.   eighth bit of each character and we still get a readable text,
  222.   although written with English characters! This is very important now,
  223.   since there are many mailers on the Internet, that just strip the
  224.   eighth bit silently, being sure that every single soul on the face of
  225.   the Earth speaks English.
  226.  
  227.   Not surprisingly, KOI-8 quickly became a de-facto standard for
  228.   Cyrillic on the Internet. Andrew A. Chernov did a tremendous amount of
  229.   work to make a standard in this area. He is an author of RFC 1489
  230.   ("Registration of a Cyrillic Character Set").
  231.  
  232.   These two standards differ only in positions of the cyrillic
  233.   characters in the table (that is in cyrillic character codes).
  234.  
  235.   The principal difference is that the Alt codeset is used by MS-DOS
  236.   users only, whereas KOI-8 is used in Unix, as well as in MS-DOS
  237.   (though in the latter KOI-8 is much less popular). Since we are doing
  238.   the right thing (namely working in the Unix operating system), we
  239.   shall focuse mostly on KOI-8.
  240.  
  241.   As for the ISO standard, it is more popular in Europe and the US as a
  242.   standard for Cyrillic. The leader in Russia is definitely KOI-8.
  243.  
  244.   There are other standards, which are different from ASCII and much
  245.   more flexible. Unicode is most known. However, they are not
  246.   implemented as good as the basic ones in Unix in general and  Linux in
  247.   particular. Therefore, I am not describing them here.
  248.  
  249.   3.  Text mode setup
  250.  
  251.   Generally, the text mode setup is the easiest way to show and input
  252.   Cyrillic characters. There is one significant complication, however:
  253.   the text mode fonts and keyboard layout manipulations depend on
  254.   terminal driver implementation. Therefore, there is no portable way to
  255.   achieve the goal across different systems.
  256.  
  257.   Right now, I describe the way to deal with the Linux console driver.
  258.   Thus, if you have another system, don't expect it to work for you.
  259.   Instead, consult your terminal driver manual. Nevertheless, send me
  260.   any information you find, so I'll be able to include it in further
  261.   versions of this document.
  262.  
  263.   3.1.  Linux Console
  264.  
  265.   The Linux console driver is quite a flexible piece of software. It is
  266.   capable of changing fonts as well as keyboard layouts. To achieve it,
  267.   you'll need the kbd package. Both RedHat and Slackware install kbd as
  268.   part of a system.
  269.  
  270.   The kbd package contains keyboard control utilities as well as a big
  271.   collection of fonts and keyboard layouts.
  272.  
  273.   Cyrillic setup with kbd usually involves two things:
  274.  
  275.   1. Screen font setup. This is performed by the setfont program. The
  276.      fonts files are located in /usr/lib/kbd/consolefonts.
  277.  
  278.      NOTE: Never run the setfont program under X because it will hang
  279.      your system. This is because it works with low-level video card
  280.      calls which X doesn't like.
  281.  
  282.   2. Load the appropriate keyboard layout with the loadkeys program.
  283.  
  284.   NOTE: In RedHat 3.0.3, /usr/bin/loadkeys has too restrictive access
  285.   permissions, namely 700 (rwx------). There are no reasons for that,
  286.   since everyone may compile his own copy and execute it (the
  287.   appropriate system calls are not root-only). Thus, just ask your
  288.   sysadmin to set more reasonable permissions for it (for example, 755).
  289.  
  290.   The following is an excerpt from my cyrload script, which sets up the
  291.   Cyrillic mode for Linux console:
  292.  
  293.   if [ notset.$DISPLAY != notset. ]; then
  294.       echo "`basename $0`:  cannot run under X"
  295.       exit
  296.   fi
  297.  
  298.   loadkeys /usr/lib/kbd/keytables/ru.map
  299.   setfont /usr/lib/kbd/consolefonts/Cyr_a8x16
  300.   mapscrn /usr/lib/kbd/consoletrans/koi2alt
  301.   echo -ne "\033(K"              # the magic sequence
  302.   echo "Use the right Ctrl key to switch the mode..."
  303.  
  304.   Let me explain it a bit. You load the appropriate keyboard mapping.
  305.   Then you load a font corresponding to the Alt codeset. Then, in order
  306.   to be able to display text in KOI8-R correctly, you load a screen
  307.   translation table. What it does is a translation of some characters
  308.   from the upper half of the codeset to the Alt encoding. The word
  309.   'some' is crucial here - not all characters get translated, therefore
  310.   some of them, like IBM pseudographic characters get unmodified to the
  311.   screen and display correctly, since they are compatible with the Alt
  312.   codeset, as opposed to KOI8-R. To ensure this, run mc and pretend you
  313.   are back to MS-DOS 3.3...
  314.  
  315.   Finally, the magic sequence is important but I have no idea what on
  316.   the Earth it does. I stole/borrowed/learned it from German HOWTO back
  317.   in 1994, when it was like the only national language oriented HOWTO.
  318.   If you have any idea about this magic sequence, please tell me.
  319.  
  320.   Finally, for those purists, who don't wont to give the Alt codeset a
  321.   chance, I'm attaching yet another version of the script above, using
  322.   native KOI8-R fonts.
  323.  
  324.   if [ notset.$DISPLAY != notset. ]; then
  325.       echo "`basename $0`:  cannot run under X"
  326.       exit
  327.   fi
  328.  
  329.   loadkeys /usr/lib/kbd/keytables/ru.map
  330.   setfont /usr/lib/kbd/consolefonts/koi-8x16
  331.   echo "Use the right Ctrl key to switch the mode..."
  332.  
  333.   However, don't expect nice borders in your text mode-based windowing
  334.   applications.
  335.  
  336.   Now you probably want to test it. Do the appropriate bash or tcsh
  337.   setup, rerun it, then press the right Control key and make sure you
  338.   are getting the cyrillic characters right. The 'q' key must produce
  339.   russian "short i" character, 'w' generates "ts", etc.
  340.  
  341.   If you've screwed something up, the very best thing to do is to reset
  342.   to the original (that is, US) settings. Execute the following
  343.   commands:
  344.  
  345.   loadkeys /usr/lib/kbd/keytables/defkeymap.map
  346.   setfont /usr/lib/kbd/consolefonts/default8x16
  347.  
  348.   NOTE: unfortunately enough, the console driver is not able to preserve
  349.   it's state (at least easily enough), while running the X Window
  350.   System. Therefore, after you leave the X (or switch from it to a
  351.   console), you have to reload the console russian font.
  352.  
  353.   3.2.  FreeBSD Console
  354.  
  355.   I am not using FreeBSD so I couldn't test the following information.
  356.   All data in this section should be treated as just pointers to begin
  357.   with. The FreeBSD project homepage may have some information on the
  358.   subject. Another good source is the relcom.fido.ru.unix newsgroup.
  359.   Also, check the resources listed in section ``''.
  360.  
  361.   Anyway, this is what Ilya K. Orehov suggests to do in order to make
  362.   FreeBSD console speak Russian:
  363.  
  364.   1. In /etc/sysconfig add:
  365.  
  366.      keymap=ru.koi8-r
  367.      keyrate=fast
  368.      # NOTE: '^[' below is a single control character
  369.      keychange="61 ^[[K"
  370.      cursor=destructive
  371.      scrnmap=koi8-r2cp866
  372.      font8x16=cp866b-8x16
  373.      font8x14=cp866-8x14
  374.      font8x8=cp866-8x8
  375.  
  376.   2. In /etc/csh.login:
  377.  
  378.      setenv ENABLE_STARTUP_LOCALE
  379.      setenv LANG ru_SU.KOI8-R
  380.      setenv LESSCHARSET latin1
  381.  
  382.   3. Make analogous changes in /etc/profile
  383.  
  384.   4.  The X Window System
  385.  
  386.   Like the console mode, the X environment also requires some setup.
  387.   This involves setting up the input mode and the X fonts. Both are
  388.   being discussed below.
  389.  
  390.   4.1.  The X fonts.
  391.  
  392.   First of all, you have to obtain the fonts having the Cyrillic glyphs
  393.   at the appropriate positions.
  394.  
  395.   If you are using the most recent X (or XFree86) distribution, chances
  396.   are, that you already have such fonts. In the late 1995, the X Window
  397.   System incorporated a set of Cyrillic fonts, created by Cronyx. Ask
  398.   your system administrator, or, if you are the one, check your system,
  399.   namely:
  400.  
  401.   1. Run 'xlsfonts | grep koi8'. If there are fonts listed, your X
  402.      server is already aware about the fonts.
  403.  
  404.   2. Otherwise, run
  405.  
  406.      find -name crox\*.pcf\*
  407.  
  408.   to find the location of the Cyrillic fonts in the system. You'll have
  409.   to enable those fonts to the X server, as I explain below.
  410.  
  411.   If you haven't found such fonts installed, you'll have to do it
  412.   yourself.
  413.  
  414.   There is some ambiguity with the fonts. XFree86 docs claim that the
  415.   russian fonts collection included in the distribution is developed by
  416.   Cronyx. Nevertheless, you may find another set of Cronyx Cyrillic
  417.   fonts on the net (eg. on ftp.kiae.su), known as the xrus package
  418.   (don't confuse it with the xrus program, which is used to setup a
  419.   Cyrillic keyboard layout. Hopefully, tha letter one was renamed to
  420.   xruskb recently). Xrus has fewer fonts than the collection in Xfree86
  421.   (38 vs 68), but the latter one didn't go along with my ``Netscape''
  422.   setup - it gave me some really huge font in the menubar. The xrus
  423.   package doesn't have this problem.
  424.  
  425.   I would suggest you to download and try both of them. Pick up the one
  426.   which you'll like more. Also, I'm going to creat RPM packages soon for
  427.   both collections and download them both to ftp.redhat.com and to my
  428.   FTP site.
  429.  
  430.   There are also older stuff, for example the vakufonts package, created
  431.   by Serge Vakulenko, which was the base for the one in the X
  432.   distribution. There are also a number of others. The important point
  433.   is that the fonts' names in the old collection were not strictly
  434.   conforming to the standard. The latter is fine in general, but
  435.   sometimes it may cause various weird errors. For example, I had a bad
  436.   experience with Maple V for Linux, which crashed mysteriously with the
  437.   vakufonts package, but ran smoothly with the "standard" ones.
  438.  
  439.   So, let's start with the fonts:
  440.  
  441.   1. Download the appropriate fonts collection. The package for XFree86
  442.      may be found at any FTP site, containing the X distribution, for
  443.      example, directly from the XFree86 FTP site. The xrus package may
  444.      be found on ftp.kiae.su
  445.  
  446.   2. Now when you have the fonts, you create some directory for them. It
  447.      is generally a bad idea to put new fonts to the already existing
  448.      font directory. So, place them, to, say,
  449.      /usr/lib/X11/fonts/cyrillic for a system-wide setup, or just create
  450.      a private directory for personal use.
  451.  
  452.   3. If the new fonts are in BDF format (*.bdf files), you have to
  453.      compile them. For each font do:
  454.  
  455.      bdftopcf -o <font>.pcf <font>.bdf
  456.  
  457.   If your server supports compressed fonts, do it, using the compress
  458.   program:
  459.  
  460.   compress *.pcf
  461.  
  462.   Also, if you do want to put the new fonts to an already existing font
  463.   directory. you have to concatenate the old and the new files named
  464.   fonts.alias in the case both of them exist.
  465.  
  466.   4. Each font directory in the X must contain a list of fonts in it.
  467.      This list is stored in the file fonts.dir. You don't have to create
  468.      this list manually. Instead, do:
  469.  
  470.      cd <new font directory>
  471.      mkfontdir .
  472.  
  473.   5. Now you have to make this font directory known to the X server.
  474.      Here, you have a number of options:
  475.  
  476.   ╖  System-wide setup for XFree86. If you are running this version of
  477.      X, then append the new directory to the list of directories in the
  478.      file XF86Config. To find the location of this file, see output of
  479.      startx. Also, see XF86Config(4/5) for details.
  480.  
  481.   ╖  System-wide setup through xinit. Add the new directory to the xinit
  482.      startup file. See xinit(1x) and the next option for details.
  483.  
  484.   ╖  Personal setup. You have a special start-up file for the X -
  485.      ~/.xinitrc (or ~/.Xclients, or ~/.xsession for the RedHat users).
  486.      Add the following commands to it:
  487.  
  488.      xset +fp <new font directory>
  489.      xset fp rehash
  490.  
  491.   6. Now restart your X. If you have done everything right, the tests in
  492.      the beginning of the section will be successful. Also, play with
  493.      xfontsel(1x) to make sure you are able to select the cyrillic
  494.      fonts.
  495.  
  496.   In order to make the X clients use the Cyrillic fonts, you have to set
  497.   up the appropriate X resources. For example, I make the russian font
  498.   the default one in my ~/.Xdefaults:
  499.  
  500.   *font:         6x13
  501.  
  502.   Since my cyrillic fonts are first in the font path (see output of
  503.  
  504.   This just a simple case. If you want to set the appropriate part of
  505.   the X client to a cyrillic font, you have to figure out the name of
  506.   the resource (eg. using editres(1x)) and to specify it either in the
  507.   resource database, or in the command line. Here go some examples:
  508.  
  509.   $ xterm -font '-cronyx-*-bold-*-*-*-19-*-*-*-*-*-*-*'
  510.  
  511.   $ xfontsel -xrm '*quitButton.font: -*-times-*-*-*-*-13-*-*-*-*-*-koi8-*'
  512.  
  513.   xfontsel.
  514.  
  515.   4.2.  The input translation
  516.  
  517.   In the newest X releases (X11R61 and higher) there are two "standard"
  518.   input methods: the original one, working through the xmodmap utility,
  519.   and the new one called Xkb (X KeyBoard). The very first thing you have
  520.   to do is to disable the Xkb method! Don't get charmed by it's ability
  521.   to set up a "russian keyboard". It looks like this method is using the
  522.   Cyrillic keysyms defined in keysymdef.h. This file defines keysyms for
  523.   many languages. The only problem is that those definitions have
  524.   nothing to do with the extended ASCII codeset - the one most programs
  525.   are only able to operate with! I hardly know any programs being able
  526.   to grok the keysymdef.h keysyms, different from 8-bit ASCII. However
  527.   our goal is to get the KOI8-R support to work.
  528.  
  529.   To disable the Xkb support, browse through the Keyboard section of
  530.   your XF86Config file and comment all lines starting with Xkb (case
  531.   doesn't matter). Instead, put the following line:
  532.  
  533.   XkbDisable
  534.  
  535.   The xmodmap program.allows customization of codes emitted by various
  536.   characters and their combinations. It sets the things up based on the
  537.   file containing the translation table.
  538.  
  539.   If you don't want to deal with all these tricks and you prefer having
  540.   a solution right away, either download an appropriate xmodmap table,
  541.   available at many sites dealing with the Cyrillic, for example,
  542.   ftp.kiae.su or ftp.funet.fi. Also, I made the table, described below,
  543.   available at my FTP site.
  544.  
  545.   More convenient alternative is to install the xruskb package, which
  546.   allows you to configure most of the input translation parameters
  547.   without having to know about xmodmap.
  548.  
  549.   The following is a simplified description of input customization. If
  550.   you want to do more sophisticated tricks, refer to the xmodmap(1) or,
  551.   even better, wait for the next major X release, which will hopefully
  552.   address the current input problems.
  553.  
  554.   In our case, the translation table should define two things:
  555.  
  556.   ╖  the character codes emitted by the alphanumeric characters, and
  557.  
  558.   ╖  the mode switching rules
  559.  
  560.   4.2.1.  The table of characters
  561.  
  562.   This is basically a sequence of directives which assign the certain
  563.   keysyms to a specified keycodes. The general syntax is the following:
  564.  
  565.        keycode code = sym1 sym2 sym3 sym4
  566.  
  567.   where code is the numerical code of the given key on the keyboard
  568.   (refer to the standard table for your system. In my case it is stored
  569.   in the file /usr/lib/X11/etc/xmodmap.std). The syms define the keysyms
  570.   emitted by that key in different conditions. Sym1 is the keysym
  571.   emitted by the key in a regular state, sym2 corresponds the key in
  572.   shifted state (usually when Shift is held down). Sym3 and sym4 define
  573.   the keysyms emitted when the Mode_switch is active for the normal and
  574.   shifted states respectively (group 2, according to the X Protocol
  575.   Specification). In our case, the active Mode_switch corresponds to the
  576.   Cyrillic input mode.
  577.  
  578.   These should be either hexadecimal codes or the symbolic constants
  579.   from /usr/include/X11/keysymdef.h (without leading "XK_").
  580.  
  581.   Thus, if we wanted the key corresponding to the Latin 'a' generate the
  582.   Russian 'a' in the alternative mode, we would write the following:
  583.  
  584.   keycode 38  =  a  A  0xC1 0xE1
  585.  
  586.   The reader might be curious why I don't use the Cyrillic_a and
  587.   Cyrillic_A constants respectively. The answer is that it didn't work
  588.   for me. I am not very familiar with the guts of the X Window System
  589.   specification, but I've got the following explanation. The symbolic
  590.   constants above have the values 0x6C1 and 0x6E1 respectively. This
  591.   means that in really multi-lingual environment they could be
  592.   successfully used without overlapping with any other character set.
  593.   However the KOI-8 standard is not well suited for such environment.
  594.   Thus, since we want to retain compatible with the past, we will
  595.   violate the rules of multi-lingual support in the X Window System.
  596.  
  597.   The following is a table for the most popular russian JCUKEN keyboard
  598.   layout (these tables are derived from the ones in the vakufonts
  599.   package):
  600.  
  601.   keysym  4             = 4               dollar          4       quotedbl
  602.   keysym  5             = 5               percent         5       colon
  603.   keysym  6             = 6               asciicircum     6       comma
  604.   keysym  7             = 7               ampersand       7       period
  605.   keysym  q             = q               Q               0xCA    0xEA
  606.   keysym  w             = w               W               0xC3    0xE3
  607.   keysym  e             = e               E               0xD5    0xF5
  608.   keysym  r             = r               R               0xCB    0xEB
  609.   keysym  t             = t               T               0xC5    0xE5
  610.   keysym  y             = y               Y               0xCE    0xEE
  611.   keysym  u             = u               U               0xC7    0xE7
  612.   keysym  i             = i               I               0xDB    0xFB
  613.   keysym  o             = o               O               0xDD    0xFD
  614.   keysym  p             = p               P               0xDA    0xFA
  615.   keysym  bracketleft   = bracketleft     braceleft       0xC8    0xE8
  616.   keysym  bracketright  = bracketright    braceright      0xDF    0xFF
  617.   keysym  a             = a               A               0xC6    0xE6
  618.   keysym  s             = s               S               0xD9    0xF9
  619.   keysym  d             = d               D               0xD7    0xF7
  620.   keysym  f             = f               F               0xC1    0xE1
  621.   keysym  g             = g               G               0xD0    0xF0
  622.   keysym  h             = h               H               0xD2    0xF2
  623.   keysym  j             = j               J               0xCF    0xEF
  624.   keysym  k             = k               K               0xCC    0xEC
  625.   keysym  l             = l               L               0xC4    0xE4
  626.   keysym  semicolon     = semicolon       colon           0xD6    0xF6
  627.   keysym  apostrophe    = apostrophe      quotedbl        0xDC    0xFC
  628.   keysym  grave         = grave           asciitilde      0xA3    0xB3
  629.   keysym  z             = z               Z               0xD1    0xF1
  630.   keysym  x             = x               X               0xDE    0xFE
  631.   keysym  c             = c               C               0xD3    0xF3
  632.   keysym  v             = v               V               0xCD    0xED
  633.   keysym  b             = b               B               0xC9    0xE9
  634.   keysym  n             = n               N               0xD4    0xF4
  635.   keysym  m             = m               M               0xD8    0xF8
  636.   keysym  comma         = comma           less            0xC2    0xE2
  637.   keysym  period        = period          greater         0xC0    0xE0
  638.  
  639.   Also, for those using the russian YAWERTY layout, I include the
  640.   following table:
  641.  
  642.   keysym  q             = q               Q               0xD1    0xF1
  643.   keysym  w             = w               W               0xD7    0xF7
  644.   keysym  e             = e               E               0xC5    0xE5
  645.   keysym  r             = r               R               0xD2    0xF2
  646.   keysym  t             = t               T               0xD4    0xF4
  647.   keysym  y             = y               Y               0xD9    0xF9
  648.   keysym  u             = u               U               0xD5    0xF5
  649.   keysym  i             = i               I               0xC9    0xE9
  650.   keysym  o             = o               O               0xCF    0xEF
  651.   keysym  p             = p               P               0xD0    0xF0
  652.   keysym  bracketleft   = bracketleft     braceleft       0xDB    0xFB
  653.   keysym  bracketright  = bracketright    braceright      0xDD    0xFD
  654.   keysym  a             = a               A               0xC1    0xE1
  655.   keysym  s             = s               S               0xD3    0xF3
  656.   keysym  d             = d               D               0xC4    0xE4
  657.   keysym  f             = f               F               0xC6    0xE6
  658.   keysym  g             = g               G               0xC7    0xE7
  659.   keysym  h             = h               H               0xC8    0xE8
  660.   keysym  j             = j               J               0xCA    0xEA
  661.   keysym  k             = k               K               0xCB    0xEB
  662.   keysym  l             = l               L               0xCC    0xEC
  663.   keysym  z             = z               Z               0xDA    0xFA
  664.   keysym  x             = x               X               0xD8    0xF8
  665.   keysym  c             = c               C               0xC3    0xE3
  666.   keysym  v             = v               V               0xD6    0xF6
  667.   keysym  b             = b               B               0xC2    0xE2
  668.   keysym  n             = n               N               0xCE    0xEE
  669.   keysym  m             = m               M               0xCD    0xED
  670.   keysym  backslash     = backslash       bar             0xDC    0xFC
  671.   keysym  grave         = grave           asciitilde      0xC0    0xE0
  672.   keysym  equal         = equal           plus            0xDE    0xFE
  673.   keysym  3             = 3               numbersign      3       0xDF
  674.   keysym  4             = 4               dollar          4       0xFF
  675.  
  676.   4.2.2.  The mode switching rules
  677.  
  678.   This is the trickiest part of the X Cyrillic setup. You should define
  679.   the conditions in which the current mode is switched between the
  680.   regular and the Cyrillic one. Thanks to the wise X input translation
  681.   design, it is non-portable, inflexible, incomplete, and, generally
  682.   speaking, it sucks. No surprise, people switch to MS Windows.
  683.  
  684.   Currently, there is a lot of activity in development of XFree86 in
  685.   general and X input model in particular. The result is, you
  686.   configuration must work with one XFree version and not work with a
  687.   different one. Even worse, sometimes things differ accross different
  688.   servers in the same distribution.
  689.  
  690.   First of all, I'll describe my setup, which works for me now. I am
  691.   running XFree86 3.3 SVGA server. In my XF86Config file (in the RedHat
  692.   distribution it is located in /etc/X11) I have the following
  693.   directives in the "Keyboard" section:
  694.  
  695.      LeftAlt         Meta
  696.      RightAlt        ModeShift
  697.      ScrollLock      ModeLock
  698.      RightCtl        Control
  699.  
  700.   NOTE: The way to set up the mode switching rules via XF86Config file
  701.   is XFree86-specific. It won't work for other X versions.
  702.  
  703.   Now, I load the table described in the last section and stored in some
  704.   file using the xmodmap(1X) utility:
  705.  
  706.   xmodmap  <table_file>
  707.  
  708.   Now I am able to shift to the Cyrillic input mode using right Alt key
  709.   and to switch to Cyrillic and back using ScrollLock. You'll be
  710.   surprised to learn that neither CapsLock nor Control keys work in the
  711.   Cyrillic input mode. Well, say it again: the X input model sucks!
  712.  
  713.   The rest of this section is a concise description of generic X input
  714.   translation configuration. It used to work for older XFree86 releases
  715.   but exposes various problems now. I left it here, so that the most
  716.   curious of you would be able to try some of this stuff and make use of
  717.   it.
  718.  
  719.   What you should do is:
  720.  
  721.   ╖  Assign the Mode_switch keysym to some key, and
  722.  
  723.   ╖  Add Mode_switch to some spare modifier map
  724.  
  725.   Now the key to which the ModeShift is assigned will act as a mode
  726.   switch. This means that while it is held down, the keyboard is in
  727.   alternative mode.
  728.  
  729.   Moreover, if you add a lockable key to that modifier's map, this key
  730.   will lock the alternative mode.
  731.  
  732.   Note: There are some problems however. Serge Vakulenko
  733.   (vak@cronyx.com) pointed out that the different X Server
  734.   implementations may have different rules of assignments the mode
  735.   switches (like, for example, some servers restrict the set of the keys
  736.   which may work in toggle mode to, say, CapsLock, NumLock, and
  737.   ScrollLock). Hopefully, this is a subject to change in the next
  738.   release of the X Window System. For more details, see the X Protocol
  739.   specification.
  740.  
  741.   Unfortunately, I didn't manage to make the CapsLock key have the same
  742.   functionality in the alternative mode, namely, to lock the upper case.
  743.   It seems to me, it is impossible to do it, because of the idiotic X
  744.   input translation design. If I am wrong, please correct me.
  745.  
  746.   Let's see an example. Suppose, one wants to use the right Alt as a
  747.   mode switch and the ScrollLock as as a mode lock. First of all, one
  748.   should check the default modifiers' map. This is accomplished by
  749.   running the xmodmap without arguments:
  750.  
  751.   $ xmodmap
  752.  
  753.   xmodmap:  up to 2 keys per modifier, (keycodes in parentheses):
  754.  
  755.   shift       Shift_L (0x32),  Shift_R (0x3e)
  756.   lock        Caps_Lock (0x42)
  757.   control     Control_L (0x25)
  758.   mod1        Alt_L (0x40),  Alt_R (0x71)
  759.   mod2        Num_Lock (0x4d)
  760.   mod3
  761.   mod4
  762.   mod5
  763.  
  764.   According to the above, the plan of attack is the following:
  765.  
  766.   1. remove the Alt_R key from the mod1 map
  767.  
  768.   2. assign the Mode_switch keysym to the Alt_R key
  769.  
  770.   3. assign the Scroll_Lock keysym to the keycode 78 (the code of the
  771.      actual ScrollLock)
  772.  
  773.   4. add the Mode_switch to the spare (mod3) map, and
  774.  
  775.   5. add the Scroll_Lock keysym to the mod3 map
  776.  
  777.   Thus, here is the solution:
  778.  
  779.   remove mod1 = Alt_R
  780.   keysym Alt_R = Mode_switch
  781.   keycode 78 = Scroll_Lock
  782.   add mod3 = Mode_switch
  783.   add mod3 = Scroll_Lock
  784.  
  785.   If you use the latter solution, you may combine both the table and the
  786.   mode directives in your ~/.Xmodmap file.
  787.  
  788.   Such files are generally supplied with the various X Cyrillic stuff
  789.   packages. The good example is the tables in the old package by Serge
  790.   Vakulenko described above.
  791.  
  792.   Once you have such file containing the table, you should run the
  793.   command:
  794.  
  795.        xmodmap filename
  796.  
  797.   system-wide file is /usr/lib/X11/xinit/xinitrc; the personal one is
  798.   either ~/.xinitrc, or ~/.Xclients, or ~/.xsession, depending on what
  799.   you have.
  800.  
  801.   NOTE: If xmodmap complains on your table, try to load the default
  802.   table first. The default one is usually located in
  803.   /usr/lib/X11/etc/xmodmap.std.
  804.  
  805.   5.  Cyrillic support in TeX and LaTeX
  806.  
  807.   In this section I'll describe several ways to make TeX and LaTeX
  808.   typeset Cyrillic texts. There are several ways, which differ in setup
  809.   sophistication and usage convenience. For example, one possibility is
  810.   to start without any preliminary setup and use the Washington AMSTeX
  811.   Cyrillic fonts. On the other hand, you may install a LaTeX package,
  812.   providing a very high degree of Cyrillic setup. I have an experience
  813.   with two such packages. One is the cmcyralt package by Vadim V.
  814.   Zhytnikov (vvzhy@phy.ncu.edu.tw) and Alexander Harin
  815.   (harin@lourie.und.ac.za), and the other one is the LH package by the
  816.   CyrTUG group with styles and hyphenation for LaTeX2e by Sergei O.
  817.   Naoumov (serge@astro.unc.edu). I'll describe both.
  818.  
  819.   Note, that there are two versions of LaTeX available - 2.09 is the old
  820.   one, while 2e is a new pre-3.0 release. If you are using LaTeX 2.09,
  821.   then switch quickly to the 2e. The latter retains compatibility with
  822.   the old one, but has much more features. Hopefully, version 3 will be
  823.   released soon. I describe a LaTeX 2e setup.
  824.  
  825.   Also, both of these packages require the Cyrillic text to be typeset
  826.   using the Alt codeset, not KOI-8! This is caused by historical
  827.   reasons, since the creators of these packages used to work with EmTeX
  828.   - the MS-DOG version of TeX (they didn't know about Linux yet :-).
  829.   Switching to the KOI-8 requires some effort and is being expected to
  830.   be done soon. So far, use some utility to convert your russian text
  831.   from KOI-8 to Alt. See section ``''.
  832.  
  833.   5.1.  Using the Washington Cyrillic
  834.  
  835.   This package was created for the American Mathematic Society to
  836.   provide documents with Russian references. Therefore, the authors were
  837.   not very careful and the fonts look quite clumsy. This package is
  838.   usually referred to as a "really bad cyrillic package for TeX".
  839.  
  840.   Nevertheless, we'll discuss it, because it is very easy to use and
  841.   doesn't require any setup - this collection is supplied with most of
  842.   TeX distributions.
  843.  
  844.   Of course, you won't be able to use such luxury as automatic
  845.   hyphenation, but anyway...
  846.  
  847.   1. Prepend your document with the following directives:
  848.  
  849.   \input cyracc.def
  850.   \font\tencyr=wncyr10
  851.   \def\cyr{\tencyr\cyracc}
  852.  
  853.   2. Now to type a cyrillic letter, you enter
  854.  
  855.   \cyr
  856.  
  857.   and use a corresponding latin letter or a TeX command. Thus, the lower
  858.   case of the Russian alphabet is expressed by the following codes:
  859.  
  860.   a b v g d e \"e zh z i {\u i} k l m n o p r s t u f kh c ch sh shch
  861.   {\cprime} y {\cdprime} \`e yu ya
  862.  
  863.   It is extremely inconvenient to convert your Russian texts to such
  864.   encoding, but you can automate the process. The translit program
  865.   (section ``'') supports a TeX output option.
  866.  
  867.   5.2.  KOI-8 package for teTeX
  868.  
  869.   There is some new teTeX-rus package. It is reported to support KOI-8
  870.   character set and have all basic stuff required for TeX and LaTeX. I
  871.   personally haven't tried it yes, although I heard about it's
  872.   successfull usage.
  873.  
  874.   NOTE: This package requires you to reconfigure and rebuild some parts
  875.   of your teTeX package (for example the precompiled LaTeX macros).
  876.   Unless you know what you are doing, you shouldn't try it without
  877.   necessary care. Otherwise, you may be better off by borrowing the
  878.   precompiled parts fron somebody on the net
  879.  
  880.   5.3.  Using the cmcyralt package for LaTeX
  881.  
  882.   The cmcyralt package can be found on any CTAN (Comprehensive TeX
  883.   Archive Network) site like ftp.dante.de. You should obtain two pieces:
  884.   the fonts collection from fonts/cmcyralt and the styles and
  885.   hyphenation rules from macros/latex/contrib/others/cmcyralt.
  886.  
  887.   Note: Make sure you have the Sauter package installed, since cmcyralt
  888.   requires some fonts from it. You can get this package from CTAN site
  889.   as well.
  890.  
  891.   Now you should do the following:
  892.  
  893.   1. Put the new fonts to the TeX fonts tree. On my system (Slackware
  894.      2.2) I created a cmcyralt directory in the
  895.      /usr/lib/texmf/fonts/cm/. Create the src, tfm, and vf
  896.      subdirectories in it. Put there .mf, .tfm, and vf files
  897.      respectively.
  898.  
  899.   2. Put the font driver files (*.fd) from the styles archive to the
  900.      appropriate place (in my case it was /usr/lib/texmf/tex/latex/fd).
  901.  
  902.   3. Put the style files (*.sty) to the appropriate LaTeX styles
  903.      directory (in my case /usr/lib/texmf/tex/latex/sty).
  904.  
  905.   Now the hyphenation setup. This requires to remake the LaTeX base
  906.   file.
  907.  
  908.   1. The file hyphen.cfg contains the directives for both English and
  909.      Russian hyphenation. Extract the one for Russian and place it to
  910.      the LaTeX hyphenation config file lthyphen.ltx. In my case, that
  911.      file was in /usr/lib/texmf/tex/latex/latex-base.
  912.  
  913.   2. Put the rhyphen.tex to the same directory. It is needed for making
  914.      the new base file. Later, you can remove it.
  915.  
  916.   3. Do 'make' in that directory. Don't for get to make a link from
  917.      Makefile to Makefile.unx. During the make process check the output.
  918.      There should be a message:
  919.  
  920.      Loading hyphenation patterns for Russian.
  921.  
  922.   If everything goes OK, you will get the new latex.fmt in that direc¡
  923.   tory. Put it to the appropriate place, where the previous one was
  924.   (like /usr/lib/texmf/ini/). Don't forget to save the previous one!.
  925.  
  926.   This is it. The installation is complete. Try processing the examples
  927.   found in the styles archive. If you are to create the PostScript files
  928.   without any problems, then everything is OK. Now, to use Cyrillic in
  929.   LaTeX, prepend your document with the following directive:
  930.  
  931.   \usepackage{cmcyralt}
  932.  
  933.   For more details, see the README file in the cmcyralt styles archive.
  934.  
  935.   Note: if you do have problems with the examples, provided you have
  936.   installed the things right, then probably your TeX system hasn't been
  937.   installed correctly. For example, during my first try, every attempt
  938.   to create the .pk files for the russian fonts failed (MakeTeXPK
  939.   stage). A substantial investigation discovered some implicit conflict
  940.   between the localfont and ljfour METAFONT configurations. It used to
  941.   work before, but kept crashing after the cmcyralt installation.
  942.   Contact your local TeX guru - TeX is very (sometimes too much)
  943.   complicated to reconfigure it without any prior knowledge.
  944.  
  945.   5.4.  Using the CyrTUG package
  946.  
  947.   You can obtain the CyrTUG package from the SunSite archive. Get the
  948.   files CyrTUGfonts.tar.gz, CyrTUGmacro.tar.gz, and hyphen.tar.Z.
  949.  
  950.   The process of installation doesn't differ from too much the previous
  951.   one.
  952.  
  953.   6.  Cyrillic in PostScript
  954.  
  955.   Experts say PostScript is easy. I cannot judge - I've got too many
  956.   things to learn to spare some time to learn PostScript. So I'll try to
  957.   use my sad experience with it. I'll appreciate any feedback from you
  958.   guys who know more on the subject than I do (approx. 99% of the Earth
  959.   population).
  960.  
  961.   Basically, in order to print a Cyrillic text using PostScript, you
  962.   have to make sure about the following things:
  963.  
  964.   ╖  Cyrillic font is loaded or included in the document.
  965.  
  966.   ╖  Cyrillic text is included in the document.
  967.  
  968.   ╖  Cyrillic text uses the appropriate character codes which correspond
  969.      to the font's requirements.
  970.  
  971.   ╖  An appropriate font is selected in order to print Cyrillic text.
  972.  
  973.   There is no solution general enough to be recommended as an ultimate
  974.   treatment. I'll try to outline various ways to cope with different
  975.   problems related to the subject.
  976.  
  977.   One way to address Cyrillic setup problems generally enough is to use
  978.   Ghostscript. Ghostscript (or just gs in the newspeak) is a free (well
  979.   quasi-free) PostScript interpreter. It has many advantages; among
  980.   them:
  981.  
  982.   ╖  Ability to run on many platforms (various Unices, Windows etc)
  983.  
  984.   ╖  Support for a wide number of non-PostScript printers
  985.  
  986.   ╖  Good degree of configurability
  987.  
  988.   What is important in our particular case, is that once Ghostscript is
  989.   set up, we can do all printing through it, thus eliminating extra
  990.   setup for other PostScript devices (for example HP LaserJet IV)
  991.  
  992.   6.1.  Adding Cyrillic fonts to Ghostscript
  993.  
  994.   This is important, since you probably don't want to put a
  995.   responsibility to other programs to insert Cyrillic fonts in the
  996.   PostScript output. Instead, you add them to gs and just make the
  997.   programs generate Cyrillic output compatible with the fonts.
  998.  
  999.   To add a new font (in pfa or pfb form) in gs, you have to:
  1000.  
  1001.   1. Put it in the gs fonts directory (ie.  /usr/lib/ghostscript/fonts
  1002.  
  1003.   2. Add the appropriate names and aliases for the font in the Fontmap
  1004.      file in the gs directory.
  1005.  
  1006.   Recently a decent set of Cyrillic fonts for GhostScript appeared.  It
  1007.   is located in ftp.kapella.gpi.ru. This one even has a necessary part
  1008.   to add to the Fontmap file. You have to download the contents of the
  1009.   /pub/cyrillic/psfonts directory. The README file describes the
  1010.   necessary details.
  1011.  
  1012.   7.  Print setup
  1013.  
  1014.   Printing is always tricky. There are different printers from different
  1015.   vendors with different facilities. Even for a native printing there is
  1016.   no uniform solution (this applies not only to UNIX, but to other
  1017.   operating systems as well.
  1018.  
  1019.   Printers have different control languages and often they have very
  1020.   different views on foreign language support.  The good news is that on
  1021.   control language seems to be recognized as a de-facto standard for
  1022.   print job description - it is a PostScript language developed by Adobe
  1023.   Corporation.
  1024.  
  1025.   Another problem is a variety of requirements to the print services.
  1026.   For example, sometimes you want just to print a piece if C program,
  1027.   containing comments in Russian, so you don't need any pretty-printing
  1028.   - just a raw ASCII output in a single font. Another time, when you
  1029.   design a postcard for your girlfriend, you'll probably need to typeset
  1030.   some document with different fonts etc. This will definitely require
  1031.   more effort to setup Cyrillic support.
  1032.  
  1033.   To accomplish the former task you just have to make your printer
  1034.   understand one Cyrillic font and (maybe) install some filter program
  1035.   to generate data in appropriate format. To accomplish the latter one,
  1036.   you have to teach your printer different fonts and have a special
  1037.   software.
  1038.  
  1039.   There is also something in the middle, when you get a program which
  1040.   knows how to generate both the fonts and the appropriate printer
  1041.   input, so you can say do some aource code pretty-printing without
  1042.   sophisticated word processing systems.
  1043.  
  1044.   All these options will be more or less covered below.
  1045.  
  1046.   7.1.  Pre-loading Cyrillic fonts into a non-PostScript printer
  1047.  
  1048.   If you have a good old dot matrix printer and all you need is to print
  1049.   a raw KOI-8 text, try the following:
  1050.  
  1051.   1. Find a proper KOI-8 font for your printer. Check out the MS-DOSish
  1052.      stuff on the Internet (for example the SimTel archive
  1053.      <ftp://ftp.simtel.net>).
  1054.  
  1055.   2. Learn from the manual, how to load such font into your printer and,
  1056.      probably, write a simple program doing that.
  1057.  
  1058.   3. Run this program from the appropriate rc file at a boot time.
  1059.  
  1060.   Thus, having Cyrillic characters in the upper part of the printer's
  1061.   character set will allow you to print you texts in Russian without any
  1062.   hussle.
  1063.  
  1064.   Alternatively to the KOI-8 fonts you may try to use the Alt font.
  1065.   There are two reasons for that:
  1066.  
  1067.   ╖  It may be probably much easier to find an Alt font, since those
  1068.      were very widespread in the MS-DOS culture.
  1069.  
  1070.   ╖  Having a proper Alt font will allow you to print pseudo-graphic
  1071.      characters as well.
  1072.  
  1073.   However in this case, you'll have to convert your texts from KOI-8 to
  1074.   Alt before sending them to a printer. This is quite easy, since there
  1075.   are a lot of programs doing that (see ``translit'' for example), so
  1076.   you just have to call such program properly in the if field in
  1077.   /etc/printcap file. For example, with the translit program you may
  1078.   specify:
  1079.  
  1080.   if=/usr/bin/translit -t koi8-alt.rus
  1081.  
  1082.   See printcap(5) for details.
  1083.  
  1084.   7.2.  Printing with different fonts
  1085.  
  1086.   One great way to cope with different printers and fonts is to use
  1087.   ``TeX''. TeX drivers handle all details, so once you make TeX
  1088.   understand Cyrillic fonts, you are done.
  1089.  
  1090.   Another possibility is to use PostScript. I decided to devote an
  1091.   entire ``chapter'' to the subject, since it is not simple.
  1092.  
  1093.   Finally, there are other word processors, which have printer drivers.
  1094.   I never tried anything apart from TeX, so I cannot suggest anything.
  1095.  
  1096.   7.3.  Converting text to TeX
  1097.  
  1098.   If all you need is just to print an ASCII text without any additional
  1099.   word processing, you may try to use some programs, which would convert
  1100.   your Cyrillic text to a ready-to-process TeX file. One of the best
  1101.   programs for such purposes is ``translit''. In this case, you don't
  1102.   even have to bother about installing the Cyrillic fonts for TeX, since
  1103.   translit uses a Washington Cyrillic package, which is included in most
  1104.   TeX distributions (or am I wrong?)
  1105.  
  1106.   7.4.  Text to PostScript converters
  1107.  
  1108.   Sometimes you have just a plain ASCII KOI-8 text and you want to print
  1109.   it just to get it on the paper. One of the easiest ways to achieve
  1110.   that is to use special programs converting text to PostScript.
  1111.  
  1112.   There are a number of programs doing such conversion. I personally
  1113.   prefer a2ps. Originally developed as a simple text-to-PostScript
  1114.   converter it became a big and highly configurable program with many
  1115.   options and allows you to manage various page layouts, syntax
  1116.   highlighting etc. Another tool (now available as a part of the GNU
  1117.   project) is enscript.
  1118.  
  1119.   The main problem with such programs is that they know nothing about
  1120.   Cyrillic fonts. Right now I am investigating a possibility of
  1121.   including Cyrillic fonts in them in order to understand Cyrillic. Stay
  1122.   in touch.
  1123.  
  1124.   Nevertheless all the blah-blah above would be pointless without any
  1125.   real advice. So, there we go.
  1126.  
  1127.   As usual, GNU is the winner. The GNU enscript program is designed for
  1128.   converting text to PostScript and has perfect non-ASCII codeset
  1129.   support. It doesn't have Cyrillic PostScript fonts, but it is very
  1130.   easy to get them, as will be explained below (thanks to Michael Van
  1131.   Canneyt):
  1132.  
  1133.   1. Install the newest enscript. As of now, the most recent release is
  1134.      1.5. You may either get the one from the GNU FTP archive, or take
  1135.      an RPM package from the Redhat site.
  1136.  
  1137.   2. Now, if you are a lucky RedHat Linux user, download and install
  1138.      Cyrillic Textbook font
  1139.      <ftp://ftp.redhat.com/pub/contrib/i386/enscript-fonts-
  1140.      koi8-1.0-1.i386.rpm>.
  1141.  
  1142.   3. If you don't use RPM, download a file textbook.tar.gz from the
  1143.      Cyrillic Software collection on sunsite.unc.edu
  1144.      <ftp://sunsite.unc.edu/pub/academic/russian-studies/Software/>.
  1145.      Extract it to a directory, where enscript fonts are located
  1146.      (usually /usr/share/enscript). Now change to that directory and run
  1147.      the following command:
  1148.  
  1149.          mkafmmap *.afm
  1150.  
  1151.   4. The setup is finished. Try to print some text in KOI8-R Cyrillic
  1152.      with the following command:
  1153.  
  1154.          enscript --font=Textbook8 --encoding=koi8 some.file
  1155.  
  1156.   If you don't want a really quick and dirty solution and you don't care
  1157.   about the output quality and all you need is just Cyrillic on the
  1158.   paper, try the rtxt2ps package. It is a very simple no-frills text-to-
  1159.   PostScript conversion program. The output quality is not very good
  1160.   (or, to be honest, just bad) but it does it's job.
  1161.  
  1162.   Another resort is a hacked version of a2ps. This one is quite old, so
  1163.   don't expect all new version's bells and whistles in it. But it prints
  1164.   Cyrillic text and the quality is sufficiently better than that of
  1165.   rtxt2ps.  However, I experienced various kinds of problems with it -
  1166.   like I couldn't print more than two pages (???).
  1167.  
  1168.   8.  Miscellaneous utilities setup
  1169.  
  1170.   Generally, to set the certain utility up to handle the Cyrillic
  1171.   requires just to allow the 8 bit input. In some cases it is required
  1172.   to tell the application to show the extended ASCII characters in their
  1173.   "native" form.
  1174.  
  1175.   8.1.  bash
  1176.  
  1177.   Three variables should be set on order to make bash understand the
  1178.   8-bit characters. The best place is ~/.inputrc file. The following
  1179.   should be set:
  1180.  
  1181.   set meta-flag on
  1182.   set convert-meta off
  1183.   set output-meta on
  1184.  
  1185.   8.2.  csh/tcsh
  1186.  
  1187.   The following should be set in .cshrc:
  1188.  
  1189.   setenv LC_CTYPE iso_8859_5
  1190.   stty pass8
  1191.  
  1192.   If you don't have the POSIX stty (impossible for Linux), then replace
  1193.   the last call to the following:
  1194.  
  1195.   stty -istrip cs8
  1196.  
  1197.   8.3.  emacs
  1198.  
  1199.   The minimal cyrillic support in emacs is done by adding the following
  1200.   calls to one's .emacs (provided that the Cyrillic character set
  1201.   support is installed for console or X respectively):
  1202.  
  1203.   (standard-display-european t)
  1204.  
  1205.   (set-input-mode (car (current-input-mode))
  1206.      (nth 1 (current-input-mode))
  1207.      0)
  1208.  
  1209.   This allows the user to view and input documents in Russian.
  1210.  
  1211.   However, such mode is not of a big convenience because emacs doesn't
  1212.   recognize the usual keyboard commands while set in Cyrillic input
  1213.   mode. There are a number of packages which use the different approach.
  1214.   They don't rely on the input mode stuff established by the environment
  1215.   (either X or console. Instead, they allow the user to switch the input
  1216.   mode by the special emacs command and emacs itself is responsible for
  1217.   re-mapping the character set. The author took a chance to look at
  1218.   three of them. The russian.el package by Valery Alexeev
  1219.   (ava@math.jhu.edu) allows the user to switch between cyrillic and
  1220.   regular input mode and to translate the contents of a buffer from one
  1221.   Cyrillic coding standard to another (which is especially useful while
  1222.   reading the texts imported from MS-DOG).
  1223.  
  1224.   The only inconvenience is that emacs is still treating the russian
  1225.   characters as special ones, so it doesn't recognize russian words'
  1226.   bounds and case changes. To fix it, you have to modify the syntax and
  1227.   case tables of emacs:
  1228.  
  1229.   ;; there is a garbage in the variables below, since SGML doesn't like
  1230.   ;; cyrillic characters. You have to put the uppercase and lowercase
  1231.   ;; parts of the Russian alphabet respectively (see the actual files)
  1232.  
  1233.   (setq *russian-abc-ucase* "*** SGML SUCKS ***")
  1234.   (setq *russian-abc-lcase* "*** SGML SUCKS ***")
  1235.  
  1236.   (let ((i 0)
  1237.         (len (length *russian-abc-ucase*)))
  1238.  
  1239.        (while (< i len)
  1240.          (modify-syntax-entry (elt *russian-abc-ucase* i) "w  ")
  1241.          (modify-syntax-entry (elt *russian-abc-lcase* i) "w  ")
  1242.          (set-case-syntax-pair (elt *russian-abc-ucase* i)
  1243.                                (elt *russian-abc-lcase* i)
  1244.                                (standard-case-table))
  1245.          (setq i (+ i 1))))
  1246.  
  1247.   For this purpose I created a rusup.el file which does this, as well as
  1248.   a couple handy functions. You have to load it in your ~/.emacs.
  1249.  
  1250.   Another alternative is the package remap which tries to make such
  1251.   support more generic. This package is written by Per Abrahamsen
  1252.   (abraham@iesd.auc.dk) and is accessible at ftp.iesd.auc.dk.
  1253.  
  1254.   As for the author's opinion, I would suggest to start using the
  1255.   russian.el package because it is very easy to setup and use.
  1256.  
  1257.   8.4.  ispell
  1258.  
  1259.   There is an rspell add-on created by Neal Dalton (nrd@cray.com) for
  1260.   the GNU ispell package, but I experienced some problems making it work
  1261.   right away. Try it - maybe you will be luckier.
  1262.  
  1263.   9.  joe
  1264.  
  1265.   Try the -asis option.
  1266.  
  1267.   9.1.  ksh
  1268.  
  1269.   As for the public domain ksh implementation - pdksh 5.1.3, you can
  1270.   input 8 bit characters only in vi input mode. Use:
  1271.  
  1272.   set -o vi
  1273.  
  1274.   9.2.  less
  1275.  
  1276.   So far, less doesn't support the KOI-8 character set, but the
  1277.   following environment variable will do the job:
  1278.  
  1279.   LESSCHARSET=latin1
  1280.  
  1281.   9.3.  lynx
  1282.  
  1283.   As of version 2.6, you may select the appropriate value for the
  1284.   display Character set opetion.
  1285.  
  1286.   9.4.  mc (The Midnight Commander)
  1287.  
  1288.   To display Cyrillic text correctly, select the full 8 bits item in the
  1289.   Options/Display menu.
  1290.  
  1291.   If your problem is the ugly windows' borders, consult the ``''
  1292.   section.
  1293.  
  1294.   As an off-topic, if you want to make mc use color in an Xterm window,
  1295.   set the variable COLORTERM:
  1296.  
  1297.   COLORTERM= ; export COLORTERM
  1298.  
  1299.   9.5.  Netscape navigator
  1300.  
  1301.   Make sure you are using Netscape version higher than 3. If your
  1302.   Netscape is older, download a new one from www.netscape.com.
  1303.  
  1304.   9.5.1.  Basic setup
  1305.  
  1306.   To be able to see Cyrillic text in most parts of the HTML document, do
  1307.   the following:
  1308.  
  1309.   ╖  In menu Options/Document Encoding select Cyrillic(KOI-8).
  1310.  
  1311.   ╖  In menu Options/General Preferences/Fonts select Cyrillic (KOI-8)
  1312.      encoding, Times(Cronyx) as a proportional font and Courier(Cronyx)
  1313.      as a fixed one.
  1314.  
  1315.   ╖  save options.
  1316.  
  1317.   NOTE: This setup will work with most parts of the document. However,
  1318.   you won't be able to display Cyrillic text in the window header, menus
  1319.   and some controls. To fix these problems, do an
  1320.  
  1321.   9.5.2.  Advanced setup
  1322.  
  1323.   Andrew A. Chernov is the one, who knows more than others about KOI-8
  1324.   in general and netscape in particular. Visit his excellent KOI-8 page
  1325.   and download a patch for Netscape resource file, making Netscape speak
  1326.   Russian as much as it is able to.
  1327.  
  1328.   9.6.  pine
  1329.  
  1330.   Set the following directive in ~/.pinerc for personal configuration,
  1331.   or in /usr/lib/pine.conf for a global one:
  1332.  
  1333.   character-set=ISO-8859-5
  1334.  
  1335.   9.7.  rlogin
  1336.  
  1337.   Make sure that the shell on the destination site is properly set up.
  1338.   Then, if your rlogin doesn't work by default, use 'rlogin -8'.
  1339.  
  1340.   9.8.  sendmail (aka "The Doom of a Sysadmin")
  1341.  
  1342.   As of version 8, sendmail handles 8-bit data correctly by default. If
  1343.   it doesn't do it for you, check the EightBitMode option and option 7
  1344.   given to mailers in your /etc/sendmail.cf. See "Sendmail. Operation
  1345.   and Installation Guide" for details.
  1346.  
  1347.   9.9.  zsh
  1348.  
  1349.   Use the same way as with csh (see section ``csh''). The startup files
  1350.   in this case are .zshrc or /etc/zshrc.
  1351.  
  1352.   10.  Useful Tools
  1353.  
  1354.   10.1.  Conversion Utilities
  1355.  
  1356.   There are a number of programs able to convert from KOI-8 to Alt and
  1357.   back. Look at SovInformBureau or ftp.funet.fi for a list of handy
  1358.   little utilities. You can even use the special mode for emacs (see
  1359.   section ``Emacs'').
  1360.  
  1361.   However, I would especially recommend a translit package. It supports
  1362.   many popular codesets and is even able to produce a *TeX files (see
  1363.   section ``'') from text in Russian. Also, RedHat users will enjoy an
  1364.   RPM package for translit.
  1365.  
  1366.   10.2.  Programmer's tools
  1367.  
  1368.   So far, I explained the ways to make the programs accept and display
  1369.   the Cyrillic codeset. However the full localization of the system
  1370.   comprises much more. All discussed above is not enough. The system
  1371.   should be friendly for a user who doesn't necessarily speak English.
  1372.   In my own opinion, it is not a big deal to become familiar with
  1373.   English at the level of the programs' messages. However, it is not
  1374.   quite fair to require it.
  1375.  
  1376.   Thus, the next level of localization requires the programs to be
  1377.   customizable to the requirements of different languages and data
  1378.   representation habits.
  1379.  
  1380.   Before, that was done by developing some abstraction of the messages
  1381.   to output from the program's code. Now, such mechanism is (more or
  1382.   less) standardized. And, of course, there are free implementations of
  1383.   it!
  1384.  
  1385.   The good news is that GNU finally adopted the way of making the
  1386.   internationalized applications. Ulrich Drepper (drepper@ipd.info.uni-
  1387.   karlsruhe.de) developed a package gettext. This package is available
  1388.   at all GNU sites like prep.ai.mit.edu. It allows you to develop
  1389.   programs in the way that you can easily make them support more
  1390.   languages. I don't intend to describe the programming techniques,
  1391.   especially because the gettext package is delivered with excellent
  1392.   manual.
  1393.  
  1394.   So, if you are developing programs which output messages (have you
  1395.   ever developed any program which didn't?), then don't be lazy to put a
  1396.   little (yes, really little) effort to make your program locale-aware.
  1397.  
  1398.   Request for collaboration: If you want to learn the gettext package
  1399.   and to contribute to the GNU project simultaneously; or even if you
  1400.   just want to contribute, then you can do it! GNU goes international,
  1401.   so all the utilities are being made locale-aware. The problem is to
  1402.   translate the messages from English to Russian (and other languages if
  1403.   you'd like). Basically, what one has to do is to get the special .po
  1404.   file consisting of the English messages for a certain utility and to
  1405.   append each message with it's equivalent in Russian. Ultimately, this
  1406.   will make the system speak Russian if the user wants it! For more
  1407.   details and further directions contact Ulrich Drepper
  1408.   (drepper@ipd.info.uni-karlsruhe.de).
  1409.  
  1410.   11.  Summary of the various useful resources
  1411.  
  1412.   a2ps homepage <http://www-inf.enst.fr/~demaille/a2ps.html>
  1413.  
  1414.   A. Chernov's KOI-8 page <http://www.nagual.ru/~ache/koi8.html>
  1415.  
  1416.   General Linux Information <http://sunsite.unc.edu/mdw/linux.html>
  1417.  
  1418.   My collection of stuff related to the Cyrillic setup
  1419.   <ftp://netvision.net.il/pub/home/b/belikoff/cyrillic/>
  1420.  
  1421.   Collection of Cyrillic stuff on ftp.kiae.su
  1422.   <ftp://ftp.kiae.su/cyrillic/>
  1423.  
  1424.   Collection of Cyrillic stuff on ftp.relcom.ru
  1425.   <ftp://ftp.relcom.ru/cyrillic/>
  1426.  
  1427.   Collection of cyrilization software
  1428.   <ftp://ftp.funet.fi/pub/culture/russian/comp/>
  1429.  
  1430.   Cronyx <http://www.cronyx.ru> - the creators of Cyrillic fonts for the
  1431.   X Window System.
  1432.  
  1433.   Cyrillic fonts for Ghostscript
  1434.   <ftp://ftp.kapella.gpi.ru/pub/cyrillic/psfonts>Cyrillic fonts for X
  1435.   <ftp://ftp.kiae.su/cyrillic/x11/fonts/xrus-2.1.1-src.tgz>
  1436.  
  1437.   Ghostscript <http://www.cs.wisc.edu/~ghost/index.html>
  1438.  
  1439.   GNU nenscript <ftp://prep.ai.mit.edu/pub/gnu>
  1440.  
  1441.   Information on Cyrillic Software
  1442.   <http://sunsite.oit.unc.edu/sergei/Software/Software.html>
  1443.  
  1444.   relcom.fido.ru.unix <news:relcom.fido.ru.unix> newsgoup.
  1445.  
  1446.   RFC 1489 <file://ds.internic.net/rfc/rfc1489.txt>
  1447.  
  1448.   rspell for GNU ispell <ftp://sunsite.unc.edu/pub/academic/russian-
  1449.   studies/Software/rspell.tar.gz>
  1450.  
  1451.   SovInformBureau <http://www.siber.com/sib/russify/>
  1452.  
  1453.   teTeX russification package <ftp://xray.sai.msu.su/pub/outgoing/teTeX-
  1454.   rus/>
  1455.  
  1456.   The kbd package for Linux
  1457.   <ftp://sunsite.unc.edu/pub/Linux/system/Keyboards/>
  1458.  
  1459.   The remap package for Emacs <ftp://ftp.iesd.auc.dk/>
  1460.  
  1461.   The rtxt2ps and hacked a2ps packages
  1462.   <http://www.siber.com/sib/russify/converters/>
  1463.  
  1464.   The translit package
  1465.   <ftp://ftp.osc.edu/pub/russian/translit/translit.tar.Z>
  1466.  
  1467.   The xruskb package <ftp://ftp.relcom.ru/x11/cyrillic/>
  1468.  
  1469.   Useful Cyrillic packages <ftp://sunsite.unc.edu/pub/academic/russian-
  1470.   studies/Software>
  1471.  
  1472.   X fonts collections <ftp://ftp.switch.ch/mirror/linux/X11/fonts/>
  1473.  
  1474.   XFree86 FTP site <http://www.xfree86.org>
  1475.  
  1476.