5. Configure X Windows for Arabic

XFree86 is an X Window implementation that is freely available and is one of the most popular. XFree86 is written under the assumption that only Latin-based languages will use it. This means that adapting the application to the new world of internationalization is additionally cumbersome and complex. It would be nice if we could scrap it all together and start from scratch, but we will work with what we have for now ;)

5.1. Install Fonts

http://old.arabeyes.org/project.php?proj=khotot

Unfortunately, XFree86 does not come with full Arabic fonts. In fact, the XFree86 repository does include a complete Arabic font but it is truncated during the installation for memory optimization reasons. This is only true to bitmap fonts. XFree86 does not have any complete Arabic TrueType fonts.

To find out what fonts you have installed in your system, do:

$ xlsfonts | more
    

5.1.1. Install Bitmap Fonts

You can download the complete font here: http://prdownloads.sourceforge.net/arabeyes/ae_fonts_mono.tar.bz2?download

To install it, simply copy it over to one of your fonts directories (e.g. /usr/X11R6/lib/X11/fonts/misc/):

# cd /usr/X11R6/lib/X11/fonts/misc
# mkfontdir && xset fp+ `pwd` && xset fp rehash
      

This should make the font available to you. To test if your XFree86 system can see the font, you can do:

$ xlsfonts | grep arabeyes
-misc-fixed-medium-r-normal--20-200-75-75-c-100-arabeyes-1
      

5.1.2. Install TrueType Fonts

In order for you to be able to use TTF (TrueType Fonts) you must have an X Font Server that supports TrueType fonts. As of XFree86 4.x, it can natively support TrueType fonts. There are two more popular servers: xfs and xfstt. The main difference between the two is that xfs also supports Type 1 fonts (which are Adobe's PostScript fonts).

You can get TTF's from the Fonts section here: http://old.arabeyes.org/resources.php

5.1.2.1. xfs
  1. To check if you are running xfs do:

     
    $ ps -waux | grep xfs
                 

    If it is not running, make sure you start it before restarting XFree86.

    $ xfs -droppriv -daemon
                 
  2. You need to add the following line to your /etc/X11/XF86Config-4 file (where you see 'FontPath' entries in the file):

    FontPath  "unix/:7100"
                 
  3. Create the font directory by executing the following commands while inside the directory:

    $ ttmkfdir -o fonts.scale ; mkfontdir 
                 
  4. Check to see if your xfs /etc/X11/fs/config file knows about your new truetype fonts directory. They should be listed under the 'catalogue' line, with the font directories are separated by commas.

5.1.2.2. xfstt

The location where xfstt keeps truetype fonts apparently varies from one distribution to another. For example, it is found in /usr/share/fonts/truetype/ in Debian. You must put your TTF's in that directory in order for it to know about your fonts.

You can update the list of loaded fonts by doing:

$ xfstt --sync
$ xfstt &
         

In order for XFree86 to know about xfstt you need to add the following line:

FontPath  "unix/:7101"[4]
         

5.1.3. Install Type 1 Fonts

Type 1 fonts are what ghostscript uses. This is especially important because some big applications (like StarOffice until recently) only supported Type 1 fonts and not TrueType fonts. It is also useful if you use TeX for your typesetting.

Installing Type 1 fonts is straight-forward. While in the directory containing your fonts:

# type1inst
# cat Fontmap >> /PATH/TO/YOUR/SYSTEM-WIDE/Fontmap
      

The path to your system-wide Fontmap file also varies. For instance, it is /usr/share/gs/6.53/Fontmap.GS in my Debian distribution.

You can also convert TrueType fonts to Type 1 fonts (which is what you will probably need to do).

$ ttf2pt1 -b fontname.ttf fontname
      

You can get ttf2pt1 here: http://quadrant.netspace.net.au/ttf2pt1/

5.1.4. Configure Anti-aliasing

Anti-aliasing is what makes your fonts look so beautiful. It is almost as if someone took an eraser and smudged the letters with it so the angles are so smooth. This is all achieved via the Xft library, which is designed to interface the FreeType rasterizer with the X Rendering Extension. It is often called 'gdkxft' or similar. Check with your distribution.

To configure Xft to work for you, either check the system-wide configuration (/etc/X11/XftConfig) to find out where your personalized configuration (~/.xftconfig) should be. Put the following in it:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>/usr/X11R6/lib/X11/fonts/truetype</dir>
</fontconfig>
      

The majority of applications currently don't come with Xft enabled, even if the source code links to it the binary distributions are often left without Xft support. A good example of this is Mozilla. As of version 1.2 you would have to compile the source yourself with '--enable-xft' option.

5.2. Setup X Terminals

5.2.1. Setup mlterm

http://mlterm.sourceforge.net/

Mlterm was the first X terminal to support Arabic and bidi in a satisfactory fashion. Most binary distributions have utf-8 and bidi support. If yours doesn't, you can download and compile mlterm like this:

$ ./configure --enable-fribidi && make && make install
      

Create a directory named ~/.mlterm in your home-directory with two files: font and main. font should have:

ISO10646_UCS2_1 = 20,-arabeyes-fixed-medium-r-normal--20-200-75-75-c-100-misc-1;
      

and main should have the following:

ENCODING = utf8
fontsize = 20
      

Now once you start mlterm, you should be able to read Arabic under any text-based application that supports UTF-8. Also, note that less may not work unless you set the LESSCHARSET environment to 'UTF-8'.

5.2.2. Setup iterm

To be completed.

5.3. Configure Keymaps

There are two key programs you will need to know about:

  1. xmodmap: modifies keymaps and pointer button mappings in X. This is the old deprecated way.

  2. setxkbmap: sets the keyboard using the X Keyboard Extension. This is how the new way of setting the keyboard is done (as of XFree86 4.x)

As of XFree86 4.2.0 there is already a symbol map for the Arabic keyboard, which should be found in $X11DIR/lib/X11/xkb/symbols/ar. If this file is missing or you have an older version of XFree86 (especially 3.3.6) you can use this keymap: http://old.arabeyes.org/download/download/3rd/arabic.xkb in conjunction with the xmodmap utility (read the manpages for more inforamtion).

However, if you do have XFree86 4.2 or higher, you can simply switch your keyboard by doing:

$ setxkbmap -symbols "us(pc101)+ar+group(ctrl_shift_toggle)"
    

Now you can simply switch between the Arabic keyboard layout and the English one by pressing the Ctrl and Shift buttons. Or you can simply add this to your /etc/X11/XF86Config-4 file like so:

Section "InputDevice"
        Identifier  "Keyboard0"
        Driver      "keyboard"
        Option      "XkbRules" "xfree86"
        Option      "XkbModel"  "pc101"
        Option      "XkbLayout" "ar"
        Option      "XkbOptions"        "grp:ctrl_shift_toggle"
EndSection
    


[4] Please note that the default port number will also vary from one distribution to another.