Japanese in Linux: a few remarks (Slackware 10) →[important note]

  1. Introduction
  2. Reading and writing in Japanese
  3. Notes

Introduction

A previous version of this text I wrote when I was working with Slackware 9.1. Presently I’ve moved to Slackware 10 (that edition of Slackware has much better support for Unicode locales). I don’t know to which extent my experiences with Slackware are usefull for other distributions. It is probably also relevant to take note that for years I only used the window manager Fluxbox png (I’ve moved to Openbox png for better Unicode support).

The text below is quite long for two reasons: (1) it deals with a Slackware system, and that distro does not provide any packages for reading or writing Japanese or Chinese, which forces you to install and configure a lot of things yourself (2) I try to control more aspects of the interface than most people care for. If you don’t use Slackware but one of the bigger and more popular distros, installing and configuring things for Japanese might be easier and a distro specific manual might be more practical. Or perhaps reading only the section about the basic approach to activating Japanese below might suffice.

As stated, Slackware itself does not come with special packages for dealing with Japanese. A few necessities can be downloaded from the SourceForge.jp: Project File List png. They can be installed (as root, do su) with the Slackware command installpkg [packagename]. Canna needs a bit manual editing of /etc/rc.d/rc.6 for stopping cannaserver when shutting down (the code is printed to the screen after installing the package for Canna).

From these packages I’ve only installed Canna (kanjiserver), kinput2 (XIM capable inputsystem), the font archive, and the terminal rxvt suitable for a Japanese locale.

Update: I’ve also installed scim png (‘Smart Common Input Method platform’) and scim-anthy, scim-tables, scim-pinyin (formerly scim-chinese). For Japanese you need at least scim and scim-anthy. Jinsong Yang made Slackware 10.2 packages for scim (LinuxPackages: scim and scim-pinyin png (1-5-2006). It seems that after installing, you still need to execute gtk-query-immodules-2.0 > /etc/gtk-2.0/gtk.immodules. It may or may not be necessary to restart your system, and it may or may not be necessary to use something like scim -d to activate scim in X (the latter seems to depend on whether the application you want to use is a gtk program or not - to use scim with rxvt-unicode I do need to execute scim -d first; see scim --help). For Japanese you need scim-anthy in addition to scim. In my upgraded Slackware 10.2 system compiling anthy and scim-anthy gave no problems. See some examples below for ways to make a scim enabled environment or start a single program with scim.

Reading and writing in Japanese

Required programs

I only discuss the programs and options that I use myself. The programs canna (kana-kanji conversion server) en kinput2 (input server) should be installed and active (for Slackware 9.1 and 10 the packages from the Slackware Add-on package Project png or the SourceForge.jp: Project File List png are fine). Canna runs default after startup - assuming the initscript is in place. (In Slackware the regular package installs the script rc.canna in /etc/rc.d/ and makes it executable; if it is lacking, install it manually or start canna manually with /usr/local/sbin/cannaserver).

Since kinput2 works in the X Window System only, it has to be started after that. If you start X directly with startx from the console, putting the line /usr/X11R6/bin/kinput2 -canna -xim & in the dotfile .xinitrc before the exec line that starts the windowmanager works in Slackware (.xsession may or may not work as well).

If you use KDE and KDM to start X and to log in, it seems that you can use the ~/.kde/Autostart folder to start it automatically with a small bash script (which should be executable: do chmod 755 [filename]). It’s content looks like:

#!/usr/bin/bash
kinput2 -canna -xim &

If you do not use KDE but some other windowmanager, but still use a display manager like KDM or GDM to log in, it seems the new xinitscript .xprofile should be used (.xsession is by default disabled in Slackware 9.1, see - if you use Slackware - /etc/X11/xdm/Xsession). Simply put kinput2 -canna -xim & in .xprofile. (You can start it by hand with the same line as well of course.) Finding an initialisation script that actually works for you depends on your distribution and on the way you start X.

Basic approach to activating Japanese

The common way to deal with multiple languages and potentially multiple ways to input text in Linux is to give different values to the LANG and XMODIFIERS environment variables. The value of LANG can be any of the output of locale -a (some distributions do not install all the different locales by default; if locales like ja_JP.utf8—the name may vary slightly according to your system—lack, you have to install further locales first). XMODIFIERS identifies your input method (the way you can type Japanese or other non-latin languages). If you want all your programs to do Japanese tricks at once, a lot of systems allow for that using the dotfile .profile (this standard method still works in Slackware; other distributions may have modified this method).

# lines in the file .profile in your home directory
LANG="ja_JP.utf8" export LANG
XMODIFIERS="@im=kinput2"  export XMODIFIERS

  If Japansese is not your first language, in addition to setting LANG, you may want to set LC_MESSAGES to the language you prefer for menus and messages. But you can also start only specific programs in a different language mode. You can use many different languages alongside each other (I don't think there is a limit to the number of different languages and input methods you may want to use at the same time—which is really nice). If you use LC_MESSAGES as well and scim instead of kinput2, you can take a hint from the following:

# lines in the file .profile in your home directory
LANG="ja_JP.utf8" export LANG
LC_MESSAGES="en_US" export LC_MESSAGES
GTK_IM_MODULE="scim" export GTK_IM_MODULE
XMODIFIERS="@im=scim" export XMODIFIERS

Starting a single program in a language mode that differs from the default systemwide setting can normally be done from a terminal, a script, or a menu. For euc encoded Japanese the line: XMODIFIERS="@im=kinput2" LANG="ja_JP.eucjp" program_name suffices. Or, if you want English messages and unicode, XMODIFIERS="@im=kinput2" LC_MESSAGES="en_US.utf8" LANG="ja_JP.utf8" program_name or GTK_IM_MODULE="scim" XMODIFIERS="@im=scim" LC_MESSAGES="en_US" LANG="ja_JP.utf8" program_name (again, the exact names of locales might differ depending on your distro; check the output of locale -a). In a menu these lines are fine as they are. Typing them in a terminal might be cumbersome, so making an alias in .bashrc like alias myfirefox='XMODIFIERS="@im=kinput2" LANG="ja_JP.eucjp" firefox' or making your own scripts might be an idea. Warning: take note that setting LANG and LC_MESSAGES works correctly only when LC_ALL is empty (if you suspect trouble, check it with echo $LC_ALL).

Note: the program name is of course the name of the executable binary. For some recent programs that name may not be entirely obvious. For example, OpenOffice uses soffice. Also, when the executable is not in your PATH you have to either name the full path (for example /usr/local/OpenOffice.org1.1.4/program/soffice) or add the directory it is in to your PATH (example for .profile would be adding the line PATH="$PATH:/new/directory" export PATH to that dotfile). Or you could make an alias in .bashrc (example: alias office='/path/to/soffice') and use that name. Or make a symbolic link to a directory that is already in your path (check your path with echo $PATH and make a link like ln -s /usr/local/OpenOffice.org1.1.4/program/soffice /usr/local/bin - where the latter should be in your PATH). But for linking super user mode (type su) might be requierd to write to system directories.

Depending on your distribution and on the packages you choose to install, setting LANG and XMODIFIERS may very well suffice to get everything working. If you think you’re lucky, check your environment variables in a terminal with echo $LANG; echo $XMODIFIERS. If they are all right (and, as said, if $LC_ALL is empty), you can start a program that can do Japanese simply from that terminal (just type its name). Inputting text with kinput starts default with shift-space or ctrl-o. Or, starting scim is usually with ctrl-space. There are however potential problems that might spoil the fun:

  1. Your system may lack the necessary fonts for the locale you have chosen.
  2. Not all programs respond well to a Japanese language mode or allow XIM or kinput2 input.
  3. Certain programs (maybe even your window manager) may need additional configuration.

Below I will describe in more detail problems that I personally know of which may arise when trying to use a Japanese locale. Don’t look here for the configuration of either the Gnome or KDE desktop envirionments, since I don’t use those (I only use a lightweight windowmanager and programs that can run by themselves).

Add and configure your fonts

Add true type fonts

Slackware 10.0 installs without Japanese true type fonts (either jis or unicode). A way to remedy this quickly is to install the quite plentiful unicode font Bitstream Cyberbit (Cyberbit.ttf) if that’s still available (March 2006 still in ftp.netscape.com/pub/communicator/extras/fonts/windows png). Put the font in a proper directory - /usr/X11R6/lib/fonts/TTF/ is the system directory in Slackware, ~/.fonts/ should work as well (check /etc/fonts/fonts.conf to be sure), and do fc-cache in the directory where you put the font. With that, the Cyberbit font will be available, and programs like firefox, thunderbird and GTK2 gvim will use it without further ado. If you only need Japanese (excluding Chinese, Korean, etc.) the freely available font kochi-mincho png will work as well.

Even though I can understand the current preference for true type fonts, it seems to me that a lot of the Asian fonts that are available dont’t perform well enough on GNU/Linux yet. Japanese characters are mostly very complex, with lots of small details that get blurred easily. Certainly the Bitstream Cyberbit font does not display sharp at normal text size on my system. And I really dislike using fonts that don’t display well at a normal text size. There may not be a single reason why certain fonts look bad. Maybe some true types (e.g. Microsoft fonts) depend too much on features that are not (by default) available in GNU/Linux. It has been suggested to me that recompiling freetype with certain options might deal with that, but lots of fonts may actually look worse after that (see note 1). Some fonts are just low quality. For a while I thought there were no Asian true type fonts that could do well on my system at all, but a free Chinese font by Arphic Technology png turned out to be razersharp without any adjustment what so ever. Unfortunately, untill now I haven’t found a Japanese true type font that is quite as sharp yet. For this reason, I often prefer to use a bitmap font to read and write Japanese (see next section).

Bitmap or true type fonts in Mozilla

Update: below I’ve made a lot of the use of bitmap fonts, because when used at their natural resolution, a well made bitmap font can be very clear and sharp. However, while this is pure goodness on my crt monitor, on my tft lcd monitor there seems to be a catch: on a white or equally bright background, some of my favorite bitmap fonts look too fragile (strangely, light colored glyphs against a dark background are still fine). However, currently, for both Japanese and Chinese I still prefer bitmap fonts (both in my editor (gvim) and in Firefox) because they are just so much easier to read. For other languages I have turned to TTFs in Firefox, but not in gvim, where I still use bitmap fonts for Western languages as well.

When you download Mozilla from mozilla.org png it is probably still configured to look for the standard X Window System bitmap fonts. Quite a few people hate that and change that to make it use true type fonts through fontconfig by changing Mozilla’s configuration files. And Slackware preconfigures its versions of Mozilla to do the same. But as I said earlier, Slackware doesn't even ship with Japanese true type fonts, so when you fire up Mozilla in a fresh install of Slackware, a site like www.asahi.com png shows a lot of gibberish instead of Japanese, for which reason installing true type fonts (as indicated above) is a advisable first step. By the way, the binaries for Firefox from mozilla.org png already use default fontconfig and the true type fonts available through that program.

After a fresh install of Slackware I download the latest Mozilla from mozilla.org png and put that in my home directory, as a quick way to have both a version of Mozilla that does true type tricks and one that uses bitmap fonts (as said, currently the binaries from mozilla.org png itself still come configured to use bitmaps, but that policy may change of course, in which case you would need to modify userfiles deep inside of mozilla’s file tree, or use fontconfig as outlined below).

After installing mozilla to a convenient place, simply make a new exec line in your menu or an alias in the dotfile .bashrc to start it. A feature of the standard version of mozilla that is quite nice, is that it doesn’t actually needs unicode fonts, because it simple uses language specific fonts (like the Japanese jis fonts) and fills up the gaps from other fonts. The trick is to select in extra fontsedit-preferences-appearance-fonts for each language the best font. For Japanese (if you installed the extra fonts for X) shinonome-mincho-jisx0208.1990 or better it’s broader alias alias-mincho-jisx0208.1983-0 from Mozilla’s fontlist gives a crisp, nice shaped mincho bitmap font, both in jis encoded pages and unicode. If you start mozilla in the locoale for euc-jis the "Fonts for unicode" can be left unspecified (the primary font will be the Japanse jis font in Unicode mode as well). If you use another locale you need to select in "Fonts for unicode" your favorite Japanese font as well. In both cases Mozilla then tries the Japanese jis font first, converting jis to unicode, and adds characters from other charactersets from other fonts. Therefore, no additional fonts requiered.

Bitmap fonts through fontconfig

Other programs (for example the GTK2 version of gvim, firefox, thunderbird, etc.) can use bitmap fonts when those fonts are added to fontconfig. Actually that is quite easy if you know which fonts you want (do check however /etc/fonts/fonts.conf for a directory that you can use e.g. ~/.fonts/). If you don’t know about your bitmap fonts you could add several of the large directories to fontconfig, but that makes a real mess of your fontlist and makes it difficult to find a specific bitmap font via fontconfig (execute fc-list | sort in a terminal for a list) because the way fontconfig selects fonts is radically different from the old X Window System way.

I was particularly interested in unicode bitmap fonts to use in my editor gvim. Unicode fonts end in iso10646-1 in the old X Window System name system (do xlsfonts | grep iso10646-1 for a list). I copied the so called ‘fixed fonts’ 9x15.pcf.gz (X font name -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1 and 9x15-KOI8-R.pcf.gz (-misc-fixed-medium-r-normal--15-140-75-75-c-90-koi8-r from the /usr/X11R6/lib/fonts/misc directory to my home directory ~/.fonts and executed fc-cache in ~/.fonts to make them available to fontconfig (do fc-list to check for the new entry Fixed:style=Regular). These ‘fixed’ fonts give a rather complete range of characters from the unicode set. If you don’t add other ‘fixed’ fonts to fontconfig, this will be the font that can be selected from the font selection menus that use fontconfig (e.g. the one in GTK2 gvim). Fontconfig uses default family names to list fonts, which may hide some specific fonts from your menu if you add several fonts with the same family name to fontconfig.

Mincho unicode bitmap fonts

Although the ‘fixed’ font is currently relatively complete the Asian gliphs in it unfortunatly have two problems: (1) the Japanese gliphs are not mincho, i.e. have straight undecorated lines (it seems programmers often think that undecorated fonts should be the default fonts for Japanese, while in fact these fonts are more like italic Western fonts) (2) also, the Japanese gliphs in it are rather crude.

Recently I found at www.study-area.org the Chinese unicode bitmap font Firefly New Sung png, which is not bad at all. For Chinese at least... it seems a few Japanese gliphs are missing... (note 2).

Earlier I have converted the Shinonome Mincho jis encoded font to unicode. Initially did not know how to make a full unicode font out of it, but it could be used for programs that allow separate font definitions. But now I've started to include latin gliphs as well. I changed the name of the font from Shinonome Mincho to Modified Mincho. Note the dated version names of the archive. See the README for details on the provided gliphs. ModifiedMincho-16.bdf is inside a zipped tar archive, do: tar zxvf. Since the Modified Mincho font with the normal latin gliphs added is still a bit experimental for me, I’ll leave the Shinonome Mincho without latin gliphs (only usefull for apps that do font merging) here as well.

To install this font (or the Chinese bitmap font above) and copy or move it to a directory that is listed in /etc/fonts/fonts.conf, e.g. cp ModifiedMincho-16.bdf ~/.fonts and change to that directory and update fontconfig: cd ~/.fonts; fc-cache. When you do fc-list | sort, the line Modified Mincho:style=Regular should be present. Below I’ll show a few examples of using fonts like these with e.g. gvim and rxvt-unicode.

The default font for GTK2

If you make use of GTK2 applications regularly, depending on the fonts you’ve got on your system, you may notice that Japanese or Chinese that appears on the GTK2 widgets and menus looks blurred. If you know to have installed fonts that can look better, you can try to override GTK2’s font selection through the dotfile .gtkrc-2.0 (in your home directory). Multiple fonts can be suggested, which has the advantage that you can start with a Western TTF that contains only Western gliphs, and continue with Asian or other fonts for non-western gliphs. It seems you have to restart X to see the change. The contents of the dotfile should look something like the following (see fc-list | sort for a list of installed fonts to choose from):

gtk-font-name="Bitstream Vera Sans,Firefly New Sung 10"

The 10 at the end is the preferred font-size for all the fonts.

Set variables and fonts for specific programs

Example configuring Firefox

To be able to both read and write Japanese or Chinese with Firefox, you probably want to start it up with a Japanese or Chinese locale (see above about LANG and LC_MESSAGES). To be able to use the Japanese input method kinput2 you need definitely to use a Japanese locale, like ja_JP.eucjp or ja_JP.utf8. Instead of kinput2 you can use scim png which has support for multiple languages. For example in a menu you may want to use something like:

XMODIFIERS="@im=kinput2" LANG="ja_JP.utf8"  /usr/local/bin/firefox150/firefox
or
GTK_IM_MODULE="scim" XMODIFIERS="@im=scim" LC_MESSAGES="en_US" LANG="ja_JP.utf8"  bin/firefox150/firefox
Or in .bashrc:
alias fire='GTK_IM_MODULE="scim" XMODIFIERS="@im=scim" LC_MESSAGES="en_US" LANG="ja_JP.utf8"  bin/firefox150/firefox'

As indicated above for Slackware you should yourself have installed at least one Asian font for your language in either /usr/X11R6/lib/fonts/TTF/ or .fonts/ in your home directory. Firefox will use it without further configuration.

If you have multiple Asian fonts you can of course change some font settings in Firefox prefereces menu. However, Firefox its font selection menu does not seem to allow multiple fonts to be defined. Also, the selection of fonts is not entirely predictable, perhaps because of the way Firefox tries to deal with the information on the webpages it wants to display (encoding, lang-attribute etc.) And webpages in utf-8 encoding that do not have a lang tag may be problematic for proper font selection as well. To try to force Firefox to use your best Asian font, you may want to edit the file userContent.css (in ~/.mozilla/firefox/..../chrome/). For my own system I added the code below to Firefox’s userContent.css. It is only an example of course. You need to restart Firefox to see the effect.

/* Example of the config file  ~/.mozilla/firefox/[...]/chrome/userContent.css
 * Example for the preferential selection of fonts for webpages in Firefox. You need 
 * to use the fonts that are on your own system (these are fonts that happen to be on my system).
 * In Linux you can type fc-list | sort in a term to see a list of fonts for xft/fontconfig
 */

body { 
    font-family: "Bitstream Charter","Charis SIL","Shinonome Mincho","Firefly New Sung" !important;
}

/* setting font-family for body does not give full controll; other tags that need to be set
 * individually that I know of are textarea, input and pre 
 * It seems that setting pre also sets the font that Firefox uses for directory listings.
 * This does not work straightforwardly in Google (nor Yahoo I suspect) somehow due to 
 * the really complex code of their resultpages. However, most of the time it helps to
 * use Google's advanced search option and choose search in language x; it then adds a 
 * lang= tag for that language to the resultpage, and than the :lang() selector (see below)
 * should work.
 */
textarea { 
    font-family: "Bitstream Charter","Charis SIL","Shinonome Mincho","Firefly New Sung" !important;
}    
input {
    font-family: "Bitstream Charter","Charis SIL","Shinonome Mincho","Firefly New Sung" !important;
}   
pre {
    font-family: "Bitstream Vera Sans Mono","Shinonome Mincho","Firefly New Sung" !important;
    font-size: 85%; /* size is another option,  Bitstream Vera Sans Mono happens to be big */
} 

/* if the author of a webpage has been so kind to define the main language of the page,
 * you can use the :lang pseudo-class to choose a language specific font, even if the page
 * is encoded in the language neutral encoding utf-8
 */
body:lang(zh) { 
        font-family: "Firefly New Sung" !important;
}

/* I have had some problems with sites that mess up the line-height for Asian fonts. You may want
 * to try to set the line-height, but this is not full-proof and may cause problems in other pages
 */

body { line-height: 1.3em ! important; }
h1 { line-height: 1.5em ! important; } 
h2 { line-height: 1.4em ! important; } 
h3 { line-height: 1.4em ! important; } 

For the body, this code tries to select first a Western font, after that a font that I like less but has macrons in it, than a Japanese font and finally a Chinese font. Most of the times this works for me.

Apart from the selection of fonts for the display of webpages, Firefox seems to use its own selection mechanism for the fonts of its menus and widgets. At least on my system it ignores my selection of the default font for gtk2 (see above) and selects a blurred Asian font instead. This can be changed by editing the file userChrome.css (also in ~/.mozilla/firefox/..../chrome/), as in the example below.

window {
    font-size: 12px !important;
    font-family: "Bitstream Vera Sans","Firefly New Sung" !important;
}
menu, menulist, menuitem {
    font-size: 14px !important;
    font-family: "Bitstream Vera Sans","MgOpen Cosmetica","Firefly New Sung","Modified Mincho" !important;
}

Example configuring GTK2 gvim

The default version of gvim in Slackware is currently the GTK2 version. This version seems to be the most stable one for use with Unicode. Unlike the GTK1 version, the GTK2 version allows the selection of wide fonts from the fontselection menu. However, gvim seems unable to set letter spacing correctly when loading certain fonts directly (fonts like Kochi Mincho or MS Mincho load correctly, others, like Bitstream Cyberbit do not). Often this problem can be avoided by first setting a (non wide) guifont that loads correctly, and only than add a wide font with guifontwide. I do this from the .gvimrc. It is also the convenient way to get gvim to start up with your favorite font and fontsize (note 3).

If you only want to set the normal width Latin font, the command set guifont in your .gvimrc will do the job.

" line in ~/.gvimrc
set guifont=Courier\ 16

Spaces in the names and before the desired fontsize need to be escaped with a backslash. If you load a text with Asian gliphs without preselecting a wide font, the system will try to choose a suitable one to match the normal width font. Alternatively, you could preselect a wide font for the Asian characters as well. When using bitmap fonts, the wide font should be twice the width of the Latin font. I am uncertain whether this is a requierment for true types as well (according to fontconfig all my true type fonts are width 100). More examples:

" lines in ~/.gvimrc
if $LANG == "ja_JP.utf8"
   set linespace=3
   set guifont=Courier\ 16
   set guifontwide=Bitstream\ Cyberbit\ 16
endif

When you make the commands conditional on the locale you are working in, you can maintain different preferences for different languages. Also, if you know you are going to work in Japanese, increasing the space between the lines with set linespace often improves readability (but this command can just as well be executed from gvim itself). The command set ambiwidth is also optinal, and seems necessary to display the Japanese zero as double width character. However ambiwidth effects other characters as well (even quotes and some combined Latin characters), see :h ambiwidth in gvim’s help files for more information. The line to execute gvim for this Japanese unicode locale would be something like:

XMODIFIERS="@im=kinput2" LC_MESSAGES="en_US.utf8" LANG="ja_JP.utf8" gvim

But as I explained above, I am unhappy with the quality of the display of Japanese characters with true type fonts. But as soon as you have added bitmap fonts to fontconfig, you can use those as well, and the syntax is the same. However, according to the help file of gvim the wide font should be double the width of the Latin font.

" lines in ~/.gvimrc
if $LANG == "ja_JP.utf8"
   set linespace=3
   set guifont=LucidaTypewriter\ 16
   set guifontwide=Shinonome\ Mincho\ 16
endif

The names for the fonts are those used by fontconfig. You can either use the command fc-list in a terminal, or peek in a fontselection menu that uses fontconfig (like firefox does, or the GTK2 version of gvim) to get to know the names. For the Latin font I copied all the files lutRS14*.pcf.gz to ~/.fonts (and did fc-cache there to add them to fontconfig). Shinonome Mincho is the font I discussed above.

Finding bitmap fonts that are nice to add to fontconfig can be hard. Which files belong to which X Window font names can be seen from the files fonts.dir inside the font directories (the fonts.dir files are updated when you do mkdfontdir inside the directory). There I could see that lutRS14.pcf.gz had:
-b&h-lucidatypewriter-medium-r-normal-sans-14-140-75-75-m-90-iso10646-1,
while the file Shinonome16minu.bdf that I made had:
-shinonomeu-mincho-medium-r-normal--16-150-75-75-c-160-iso10646-1.
The width (90 versus 160) wasn’t entirely the double, and the height (14/140 versus 16/150 didn’t match completely either, but gvim did not complain.

A screenshot of gvim configured as above.

Example configuring Athena gvim for euc jis

Before I switched to unicode I used the Athena version of gvim to write Japanese in euc jis. I failed to make the Athena version work with unicode, but I used it with euc jis all the time for at least seven years. It seemed to have the most stable connection to kinput2 (at least in Slackware 7 and 9.1). I kept a gtk1 version of gvim for other languages.

Compiling a different version of gvim is really easy. The source code can be obtained free of charge from vim.org png. Go to the download section and fetch the unix version with ‘runtime and source files together’, e.g. vim-6.3.tar.bz2. Save it to a place in your home directory where it can be kept savely, open an xterm and cd to the directory you picked. Unpackage it with something like bunzip2 vim-6.3.tar.bz2; tar xvf vim-6.3.tar and cd to the new vim63 directory with source code. Open the file src/Makefile with a editor if you want to change the default install path /usr/local/ to something else to uncomment the line #prefix = $(HOME) (i.e. remove the #), remove the variable $(HOME) with the path you prefer, and save the changed file. Then, still in the root of the source code tree, do:

./configure --with-features=big --enable-gui=athena

And if that goes well,
make
and if you changed the path to a place in your home directory:
make install
or outside your home directory:
su
make install

In my menu I simply used the whole path as exec line like:

XMODIFIERS="@im=kinput2" LC_MESSAGES="nl_NL" LANG="ja_JP.eucjp" /home/myhome/bin/gvim

To use it from the commandline I made an alias in .bashrc like:

alias avim='XMODIFIERS="@im=kinput2" LC_MESSAGES="nl_NL" LANG="ja_JP.eucjp" /home/myhome/bin/gvim'

The configuration of the fonts can be done from .gvimrc:

if $LANG == "ja_JP.eucjp"
       set guifontset=-*-mincho-medium-r-*-*-*-160-*-*-*-*-*-*
       set linespace=4
endif

The set guifontset command depends of course on the fonts on your system. See :h guifontset in gvim for authoritative information. After installing the add-on font package png the example above is bound to work. For trying other lines you should realise that through the use of the asterixes the one line should catch both a proper Latin font and a wide font double the width of the Latin font. Checking that can be done from the commandline with xlsfonts -fn [font_line] | grep iso8859-1 for the Latin font and xlsfonts -fn [font_line] | grep jis for the jis font. On my system the output of those commands is as follows:

myprompt:~$ xlsfonts -fn -*-mincho-medium-r-*-*-*-160-*-*-*-*-*-* | grep iso8859-1
-alias-mincho-medium-r-normal--16-160-75-75-c-80-iso8859-1
myprompt:~$ xlsfonts -fn -*-mincho-medium-r-*-*-*-160-*-*-*-*-*-* | grep jis      
-alias-mincho-medium-r-normal--16-160-75-75-c-160-jisx0208.1983-0
-alias-mincho-medium-r-normal--16-160-75-75-c-160-jisx0213.2000-1
-alias-mincho-medium-r-normal--16-160-75-75-c-160-jisx0213.2000-2
-alias-mincho-medium-r-normal--16-160-75-75-c-80-jisx0201.1976-0
-kappa-mincho-medium-r-normal--17-160-75-75-c-0-jisx0208.1990-0
-misc-mincho-medium-r-normal--17-160-75-75-c-0-jisx0208.1983-0
-misc-mincho-medium-r-normal--17-160-75-75-c-0-jisx0208.1990-0
-naga10-mincho-medium-r-normal--17-160-75-75-c-0-jisx0208.1983-0
-shinonome-mincho-medium-r-normal--17-160-75-75-c-0-jisx0208.1990-0

The Athena version of gvim responds to the file .Xdefaults (at least in Slackware). The syntax for gvim is irregular (see h: Xdefaults in vim). It can be used to set preferences for window size and color, so that you don’t have to set them from the commandline or from within gvim itself. Example:

Vim.foreground:         Black
Vim.background:         Wheat
Vim.geometry:           84x28

A screenshot of Athena configured as above.

In a fresh install of Slackware the line set guifontset=-*-*-medium-r-normal--16-*-*-*-c-*-*-* might work, but the selected fonts may not be that great to look at. The names of the locale for euc jis may differ slightly depending on the version of Slackware. Check with locale -a in a terminal to be sure.

Example configuring rxvt

The original rxvt works with a lot of languages, but apparently not with unicode. I still use rxvt occasionally for jis encoded Japanese (together with an athena version of gvim configured to use jis fonts as well). In .Xdefaults I defined for rxvt a normal width and a wide font, using fonts from the add-on font package png mentioned above.

rxvt*background:    wheat
rxvt*foreground:    black
rxvt*font:          -*-mincho-medium-r-*-*-*-160-*-*-*-*-iso8859-1
rxvt*mfont:         -*-mincho-medium-r-*-*-*-160-*-*-*-*-jisx0208.1983-*

Example configuring rxvt-unicode

A unicode capable version of the rxvt terminal is rxvt-unicode, available at software.schmorp.de png. Its binary name is simply rxvt, but instead of removing the old rxvt from my system, I compiled rxvt-unicode with a different name (I choose urxvt), with the following ./configure line executed in the root of the unpackaged source code:

./configure --enable-everything --program-prefix=u

By the way, if at all possible, I do not install programs that need to be compiled with make; make install. Instead, after first executing make, I use the program checkinstall png to create a Slackware package, and install that. Using the Slackware package format allows one to keep track of installed programs more easily, and facilitates uninstalling (only few Makefiles come with an uninstall line).

I start rxvt-unicode (urxvt on my system) only from my Fluxbox menu. An example of an exec line would be:

XMODIFIERS="=kinput2" LC_MESSAGES="en_GB" LANG="ja_JP.utf8" /usr/local/bin/urxvt -fn -adobe-courier-medium-r-normal--14-140-75-75-m-90-iso10646-1, -misc-fixed-medium-r-normal-ja-18-120-100-100-c-180-iso10646-1 -lsp 4  -bg black -fg grey75 -cr white -T " rxvt-unicode" -vb -imfont -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1 --scrollstyle plain -sr -sl 1000
My own exec line is currently:
XMODIFIERS="=kinput2" LC_MESSAGES="en_GB" LANG="ja_JP.utf8" /usr/local/bin/urxvt -fn -adobe-courier-medium-r-normal--14-140-75-75-m-90-iso10646-1, -shinonomeu-mincho-medium-r-normal--16-150-75-75-c-160-iso10646-1, -*-*-*-*-*-*-16-*-*-*-*-*-*-*,-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1  -lsp 4  -bg black -fg grey75 -cr white -T " rxvt-unicode" -vb -imfont  -shinonomeu-mincho-medium-r-normal--16-150-75-75-c-160-iso10646-1,  -*-*-*-*-*-*-16-*-*-*-*-*-*-*,-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1  --scrollstyle plain -sr -sl 1000

All the options are documented in the man file of rxvt-unicode (in my case man urxvt). The program is quite flexible in loading different fonts for different subsets of characters, hence the posibility to define multiple fonts after -fn. Configured as above the first instance starts a bit slower that a regular xterm. Also, I missed the key combination ctrl L to clear the screen (but typing clear does work). A minor error occurs when a program that runs inside rxvt-unicode wants to know the contents of the TERM enviroment variable and complaints that rxvt-unicode is not in its list of known terminal types. This behavior seems obsolete. The error can be suppressed by adding the option -tn xterm to rxvt-unicode’s startup line. An important reason for me to use rxvt-unicode is that it allows me to change the lineheight (which I cannot in xterm) which is important for displaying easily readable Japanese or Chinese. Also, the minimalistic scroll-bar (option --scrollstyle plain, a mere line) is quite nice.

Screenshot examples of rxvt-unicode as configured above.

Few notes on OpenOffice

When started with XMODIFIERS="@im=kinput2" LANG="ja_JP.utf8" soffice the ‘word processor’ of OpenOffice version 1.1.4 connects to kinput2, and when you select a font that contains Japanese gliphs it can use those as well. In tools/options there seem to be quite a few options that concern using Asian fonts. I hardly ever use OpenOffice, but while performing a short test the basic support for Japanese seemed all right: input, display and printing. I did manage to break the connection with kinput2 when I tried a different default Japanse font in tools/options/Basic Fonts (Asian) though. But undoing that restored the functionality. A point to take note of is that this version of OpenOffice uses its own fontsystem. It seems that manually adding or symlinking fonts to [install prefix]/share/fonts and restarting suffices to add fonts. An alternative option is to use the configuration screen that is started with the command [install prefix]/spadmin (either way, apparently only true type fonts work). While OpenOffice works with kinput2 (and therefore allows keyboard input of Japanese), scim (probably confined to GTK2 applications) does not seem to work with it (which makes direct input of e.g. Chinese difficult). But I was quite impressed with OpenOffice ability to print any Asian font I added to it.


____________

Notes

* Slackware 12.1 has (for the first time) complete support for Japanese out of the box: scim, anthy, Japanese TTF, the whole deal. Check that you are using an utf8 locale (echo $LANG) otherwise set one; GTK2 applications should be scim enabled by default, if not use scim -d . Have fun!

1. See for example x-fonts png and fabulous_fonts_in_linux/ png and jmccoy.sdf-us ... fonts.php#ft png. Take also note that (according to Carlos Corbacho (‘Re: freetype question’ Sun, 08 May 2005 <news:alt.os.linux.slackware>) enabling the bytecode interpreter of freetype2 (an advise that often is given in howto’s that aim at improving the display of fonts in X) works only with fonts that are built like the ones that ship with Microsoft software (XFree86 Font De-uglification HOWTO png more recently Optimal Use of Fonts on Linux png). Therefore, if you use other fonts (as well) you probably don’t want that.
2. Since most applications that use xft/fontconfig do ‘font merging’ (take gliphs from another font if need be) initially I did not notice that the current version of Firefly New Sung is missing specific Japanese gliphs. E.g. ー (hex 30fc), and apparently all simplified characters that are unique to the Japanese part of unicode. Ouch!
3. I had hoped that this problem would be fixed in gvim 7 (even voted for that) but no such luck. See h: guifont... GTK 2: all fonts are accepted, but mono-spaced fonts look best.’ Oh well, as long a I can still find mono-spaced bitmap fonts for the languages I use I don't really mind (but finding those fonts can be hard, its mostly TTF currently).
4. A few of the things missing: -> writing Japanese and Chinese using LaTeX (Pai H. Chou’s How to make LaTeX (teTeX) handle unicode and CJK in MacOSX png helped me on my way, but I can’t retell how I made it really work...

Last updated: spring 2006
kornelis@xs4all.nl