The Indic Fonts HOWTO Maninder Bali Dan Scott Conversion from HTML to DocBook v4.1.2 (XML) Revision History Revision 0.1 2002/01/07 mb First rendition released by Maninder Bali. Abstract This is a detailed guide on how to install and use Indic scripts (devanagri etc.) using UTF-8 encoding under GNU/Linux. This HOWTO is a work in progress. More sections regarding fonts and other related things shall be added to this HOWTO in due course of time. Special thanks to Dan Scott for conversion from HTML to DocBook v4.1.2(XML). Any feedback, sugestions, pointers, gifts, cds, BMWs will be gladly accepted. All flames will be redirected to /mnt/ praises_for_thee/ for future reference. Be afraid. ------------------------------------------------------------------------------- Table of Contents 1._Introduction 2._Installing_the_IndiX_system 2.1._Installing_IndiX 2.2._Running_Simpm 3._Devanagri_Input_and_Output_setup 3.1._Linux_console 3.2._X_Window_System 4._Locale_Setup 4.1._Files_and_the_kernel 4.2._Locale_environment_variables 5._Applications_with_Devanagri 5.1._Browsers 5.2._Editors 5.3._Mailers 6._References_and_sites 7._Frequently_Asked_Questions_(FAQ) 8._Acknowledgements_and_Copyright A._GNU_Free_Documentation_License 1._0._PREAMBLE 2._1._APPLICABILITY_AND_DEFINITIONS 3._2._VERBATIM_COPYING 4._3._COPYING_IN_QUANTITY 5._4._MODIFICATIONS 6._5._COMBINING_DOCUMENTS 7._6._COLLECTIONS_OF_DOCUMENTS 8._7._AGGREGATION_WITH_INDEPENDENT_WORKS 9._8._TRANSLATION 10._9._TERMINATION 11._10._FUTURE_REVISIONS_OF_THIS_LICENSE 12._Addendum 1. Introduction This HOWTO has been written to help you setup your Linux box to use UTF- 8 encoding for using various Indic scripts. You will have to install the IndiX system developed by NCST, Mumbai on your machine in order for you to use various Indic scripts. I have tested the IndiX system on Exodus GNU/Linux, RedHat Linux, and Mandrake Linux. Anyone who has tested this system on a machine running Debian, please let me know and I will include that in this HOWTO. I want to thank Mr. Keyur Shroff from NCST, Mumbai for allowing me to modify and redistribute his Devanagri-HOWTO. Please note that Exodus GNU/Linux, developed by the good guys at Centurion Linux, India will ship with the IndiX system installed, thanks to the Transfer of Technology deal signed by NCST, Mumbai and Centurion Linux Pvt. Ltd. Almost all of the leading GNU/Linux distributions available today have been localized in various international languages like French, German, Spanish, Chinese, Arabic, etc. This HOWTO aims at documenting the steps involved in enabling you to localize your GNU/Linux distribution to Indic scripts of your choice. To begin with, you must be aware of the complexity involved in localizing any of the Indian languages. Any Indian language text input differs from that of English. Perhaps the most significant difference is that in English, each keystroke maps directly onto a letter where each letter has a unique code. On the other hand, a 'syllable' - the Indian language equivalent unit of writing letter is composed of one or more characters entered through the keyboard. The syllable is composed of vowels, consonants, modifiers and other special graphics signs. These are encoded, just as roman letters are. The user types in a sequence of vowels, consonants, modifiers and the graphics signs. The machine then composes these syllables at run time based on language dependent rules. Every syllable is thus represented in the machine as a unique sequence of vowels, consonants and modifiers. In a text sequence, these characters are stored in logical (phonetic) order. Indic characters can combine or change shape depending on their context. A character's appearance is affected by its ordering with respect to other characters, the font used to render the character, and the application or system environment. These variables can cause the appearance of Devanagari characters to be different from their nominal glyphs (used in the code charts). Additionally, characters cause a change in the order of the displayed glyphs. This reordering is not commonly seen in non-Indic scripts and occurs independent of any bi-directional character reordering that might be required. Each syllable has a unique visual representation. However, there are too many syllables to design glyphs for each one individually. So a font normally contains certain component glyphs from which a syllable is composed at run time. The onscreen representation of a syllable is then a composition of glyphs from the Indian language font. There is no direct mapping of glyph codes to the consonant, vowel or modifier codes. However, for every syllable (a sequence of consonants, vowels and modifiers) there is a corresponding sequence of glyphs. This constitutes a many-to-many mapping from keystrokes to glyphs as opposed to a simplistic one-to-one mapping in roman scripts. Please read the Unicode-HOWTO and visit http://www.unicode.org/ for more information on the UTF-8 encoding. The Indix system developed by NCST, Mumbai enables most applications in X Windows (irrespective of the toolkit used), to render Indic characters according to the unicode standard specification. IndiX provides support for OpenType fonts and Unicode encoding at X Windows level. This enables most of the existing applications to handle Indic scripts without any modification or recompilation. Once you have installed the IndiX system, following all the steps mentioned in this HOWTO, you will be able to fly across seven seas and slap that annoying sailor who keeps goin' hic' hic'... Okay, on a more serious note, you will be able to enjoy your Linux experience in Devanagri and other Indic scripts of your choice. 2. Installing the IndiX system You can obtain the IndiX system from NCST, Mumbai site http:// rohini.ncst.ernet.in/indix/. The system is available in its source as well as binary form. This HOWTO covers the installation of the IndiX system using the binary files avaiable for download. At a later stage, I plan to cover the source installation of IndiX on your box, too. You need to download the following files in order to install IndiX sucessfully onto your machine: gtk.tar.gz indix.tar.gz 2.1. Installing IndiX NCST has written Simpm ( Simple Package Manager ) that takes care of the entire installation process on your system. Simpm carries out the following steps for a binary distribution of the IndiX system: 1. It reads the names of the files within the distribution by essentially running the command tar -tzpPf package.tgz > .package.list 2. It saves all these files and the file containing the list using the command tar -czpPf .old.package.tgz .package.list `cat .package.list` 3. Simpm then extracts the files from the package and installs them using tar -xzpPf package.tgz Should you wish to go back to the old system state for any reason, you can easily do so using tar -xzpPf .old.package.tgz 2.2. Running Simpm simpm with no arguments/parameters will display its usage. # simpm -i package.tgz [-d savdir/] does all the above steps, 1 through 3. The 'i' flag indicates install. Successful installation will create savdir/.old.package.tgz. If it finds an existing .old.package.tgz, simpm will not proceed as it means that the IndiX system has already been installed earlier. However, you can force an IndiX install by renaming it to a newpackage. Alternatively, you can uninstall the package and install it again. # simpm -u package.tgz [-d savdir/] uninstalls the package. Note, however, that this command will work only if it finds a readable .old.package.tgz. Having uninstalled the package, simpm will restore the original files that were overwritten by the package. The .old.package.tgz will be deleted after the uninstallation so that all instances of the previous installation are removed. Simpm maintains a log of all installs and uninstalls in the savdir/simpm.log file. To install the IndiX system, all you have to do is (pray and do your favourite tribal dance) type in the following commands: # simpm -i /path/to/gtk.tar.gz # simpm -i /path/to/indix.tar.gz and all the necessary files will be backed up, and the IndiX system installed on your machine. Hurrah. Congratulations, o' most precious one, on having installed IndiX system on your machine. The remainder of this HOWTO will focus on setting up your Linux environment to support Indic fonts and scripts in X. 3. Devanagri Input and Output setup 3.1. Linux console Devanagari characters do not display properly in a Linux console. However, NCST has developed ncst-term (a terminal emulator program in X Window System) which has support for converting keystrokes to UTF-8 before sending them to the application running in the ncst-term, and for displaying Unicode characters that the application outputs as UTF-8 byte sequence. 3.2. X Window System You need to make some changes in your XF86Config-4 file (usually resides in / etc/X11/ directory). A sample config file XF86Config-4.indix is installed along with IndiX system. This file can be found in /etc/X11/ directory. 3.2.1. Devanagri Font OpenType is the most suitable font format to render any Indic script properly. The IndiX system ships with one OpenType font called "raghu" for Hindi. Anyone can use and distribute this font free-of-cost. You can find this font in /usr/ X11R6/lib/X11/fonts/TrueType/ directory. Installing the Indic Fonts: In order to install the Indic fonts, you must log in as root. The X Font Server (xfs) is known to have some problems with the IndiX system, so remove it from the FontPath of the X Server. This can be achieved by modifying your XF86Config-4 file (usually in /etc/X11/) and commenting the line in the Files section and adding /usr/X11R6/lib/X11/fonts/TrueType/ to the current FontPath. After that, the FontPath should look something similar to this: FontPath "unix/:7100" FontPath "/usr/X11R6/lib/X11/fonts/misc" FontPath "/usr/X11R6/lib/X11/fonts/100dpi" FontPath "/usr/X11R6/lib/X11/fonts/75dpi" FontPath "/usr/X11R6/lib/X11/fonts/TrueType" FontPath "/usr/X11R6/lib/X11/fonts/Type1" Next, in order to make use of the OpenType font you have, load the "freetype" module at startup. You can achieve this by adding the following line in the Module section of XF86Config-4 file. Load "freetype" Make sure you specify the modules search path in the Files section, too. ModulePath "/usr/X11R6/lib/modules/fonts" ModulePath "/usr/X11R6/lib/modules/drivers" ModulePath "/usr/X11R6/lib/modules" ModulePath "/usr/X11R6/lib" ModulePath "/usr/lib" Any new Indic fonts you want to install should be placed in the /usr/X11R6/lib/ X11/fonts/TrueType/ directory. Now, change to this directory and run the following commands: $ mkfontdir $ xset fp rehash In case you want to place your new Indic fonts in some other directory, you must use xset to add the new FontPath. Please see the xset man-page for further assistance. You can check the new installed fonts by running the xlsfonts command. In case you don't see any Indic fonts using this command, you may need to restart X. 3.2.2. Devanagri Keyboard Layout The IndiX system comes with a keyboard map file for xmodmap. You can use the utility xmodmap to map a Devanagri keyboard. For most distributions, when you start X, the X-Server will look for a Xmodmap in /etc/X11/ directory. If that file does not exist, the server will look for a .Xmodmap in your $HOME. Just putting the .Xmodmap in your $HOME will be okay. When you start the X server, it will load this file. You can also load .Xmodmap from the command line: $ xmodmap ~/.Xmodmap Note If you are using XFree86 version 4.0 or later, you need to add the line XkbDisable in InputDevice section of XF86Config-4 file. You may config the keyboard section like the following sample. Section "InputDevice" Identifier "Keyboard0" Driver "keyboard" Option "XkbDisable" EndSection 4. Locale Setup 4.1. Files and the kernel You can now use any Unicode characters in file names. No kernel or file utilities need modifications. This is because file names in the kernel can be anything not containing a null byte, and '/' is used to delimit subdirectories. When encoded using UTF-8, non-ASCII characters will never be encoded using null bytes or slashes. All that happens is that file and directory names occupy more bytes than they contain characters. For example, a filename consisting of five greek characters will appear to the kernel as a 10-byte filename. The kernel does not know (and does not need to know) that these bytes are displayed as greek. This is the general theory, so long as your files reside on Linux. On filesystems which are used from other operating systems, you have mount options to control conversion of filenames to or from UTF-8: * The "vfat" filesystems has a mount option "utf8". See file /usr/src/linux/ Documentation/filesystems/vfat.txt. When you give an "iocharset" mount option different from the default (which is "iso8859-1"), the results with and without "utf8" are not consistent. Therefore, it is not I recommend to use the "iocharset" mount option. * The "msdos", "umsdos" filesystems have the same mount option, but appear to have no effect. * The "iso9660" filesystem has a mount option "utf8". See file /usr/src/linux/ Documentation/filesystems/isofs.txt. * Since Linux 2.2.x kernels, the "ntfs" filesystem has a mount option "utf8". See file /usr/src/linux/Documentation/filesystems/ntfs.txt. The other filesystems (nfs, smbfs, ncpfs, hpfs, etc.) don't convert filenames; therefore they support Unicode file names in UTF-8 encoding only if the other operating system supports them. Please note that to enable a mount option for all future remounts, you add it to the fourth column of the corresponding /etc/ fstab line. 4.2. Locale environment variables You should have the following environment variables set, containing locale names: LANGUAGE override for LC_MESSAGES LC_ALL override for all other LC_* variables LC_CTYPE, LC_MESSAGES, LC_COLLATE, LC_NUMERIC, LC_MONETARY, LC_TIME individual variables for: character types and encoding, natural language messages, sorting rules, number formatting, money amount formatting, date and time display. LANG default value for all LC_* variables. (See `man 7 locale' for a detailed description.) In order to tell your system and all applications that you are using UTF-8, you need to add a codeset suffix of UTF-8 to your locale names. For example, if you want to run an application in UTF-8 Hindi locale then with bash shell, you can specify which environment variable to be passed to the application. $ LANG=hi_IN.UTF-8 xman In order to set locale the Hindi locale globally for a particular user, you can append the following line in ~/.bashrc file. export LANG=hi_IN.UTF-8 After that you need not to set the LANG environment variable each time you run a specific application. 5. Applications with Devanagri 5.1. Browsers 5.1.1. Netscape Navigator Netscape 6.01 or later can display HTML documents in UTF-8 encoding. All a document needs is the following line between the
and tags: To setup Netscape so that it displays Hindi characters: Goto, Edit -> Preferences Select category, Appearance -> Fonts Select Language encoding "Unicode" Set Variable-width and Fixed-width fonts to "raghu" Check button "Always use my font settings, overriding web page font" Also, ensure that the character coding scheme is set to UTF-8 Goto, View -> Character Coding Select "Unicode (UTF-8)" from the list 5.1.2. Konqueror Konqueror has good support for Unicode. To setup konqueror so that it displays Hindi characters: Goto, Settings -> Configure Konqueror Select "Konqueror Bowser" from the left pan Goto "Appearance" tab on the right pan Select charset "iso106460-1" Set all fonts to "raghu" for this encoding and also set Default encoding to "utf8" 5.2. Editors 5.2.1. yudit yudit by Gáspár Sinai (http://czyborra.com/yudit/) is an excellent unicode text editor for the X Window System. It supports simultaneous processing of many languages, input methods, conversions for local character standards etc. It has facilities for entering text in all languages with only an English keyboard, using keyboard configuration maps. Customization is very easy. Typically you will first want to customize your font. From the font menu, choose "Unicode". Next, you should customize your input method. The input methods "Straight", "Unicode" and "SGML" are most remarkable. For details about the other built-in input methods, look in /usr/local/share/yudit/data/. To make a change the default for the next session, edit your $HOME/.yuditrc file. The general editor functionality is limited to editing, cut and paste and search and replace. There is no provision for an undo. yudit can display text using a TrueType font. But it doesn't seem to support combining characters. 5.2.2. Vim Vim (as of version 6.0) has good support for UTF-8. When started in an UTF- 8 locale, it assumes UTF-8 encoding for the console and the text files being edited. It supports double-wide (CJK) characters as well and combining characters and therefore fits perfectly into UTF-8 enabled ncst-term. 5.2.3. gedit gedit is an editor developed using GtkText widget. gedit-0.9.0 does not support FontSet. This means that you can't edit both English and Hindi text simultaneously. But if you choose a proper font then you will be able to use any one language at a time. 5.2.4. xedit With XFree86-4.0.1, xedit is capable of editing UTF-8 files if your locale is set appropriately. Add the line "Xedit*international: true" to your $HOME/.Xdefaults file. 5.3. Mailers Mail clients released after January 1, 1999, should be capable of sending and displaying UTF-8 encoded mails, otherwise they are considered deficient. But these mails have to carry the MIME labels: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simply piping an UTF-8 file into "mail" without caring about the MIME labels will not work. Mail client implementors should take a look at http:// www.imc.org/imc-intl/ and http://www.imc.org/mail-i18n.html. Now about some of the individual mail clients (or "mail user agents"): 5.3.1. kmail kmail (as of KDE 1.0) does not support UTF-8 mails at all. 5.3.2. Netscape Mail Netscape Mail can send and display mails in UTF-8 encoding, but it needs a little bit of manual user intervention. To send an UTF-8 encoded mail: 1. After opening the "Mail" window, but before starting to compose the message, select from the menu "View -> Character Coding -> Unicode (UTF- 8)". 2. Then compose the message and send it. When you receive an UTF-8 encoded mail, Netscape does not display it in UTF- 8 right away, and does not even give a visual clue that the mail was encoded in UTF-8. You have to manually select from the menu View -> Character Coding - > Unicode (UTF-8). For displaying UTF-8 mails, Netscape uses different fonts. You can adjust your font settings in the Edit -> Preferences -> Fonts dialog by selecting the "Unicode" font category. 5.3.3. exmh exmh 2.1.2 with Tk 8.4a1 can recognize and correctly display UTF-8 mails if you add the following lines to your $HOME/.Xdefaults file. ! ! Exmh ! exmh.mimeUCharsets: utf-8 exmh.mime_utf-8_registry: iso10646 exmh.mime_utf-8_encoding: 1 exmh.mime_utf-8_plain_families: fixed exmh.mime_utf-8_fixed_families: fixed exmh.mime_utf-8_proportional_families: fixed exmh.mime_utf-8_title_families: fixed 6. References and sites IndiX links * IndiX_Homepage * IndiX_Download Centurion Linux and Exodus GNU/Linux The good guys at Centurion Linux have finished work on Exodus GNU/Linux™, a 100% Free Software distribution featuring full Hindi language support for GNOME and KDE. The much awaited Exodus GNU/Linux™ (code named BitterCoffee) is expected to be released in the Indian market shortly. * Centurion_Linux_Homepage * The_Official_GNOME_i18n_Team_-_India_(hindi) Unicode * The_official_Unicode_website * UTF-8_and_Unicode_FAQ 7. Frequently Asked Questions (FAQ) 7.1. I_can't_start_the_X_windows_system._It_gives_an_error_"Could_not_open default_Indic_font_'xyz'". 7.2. Can_I_use_any_other_font_as_the_default_system_font_instead_of_the_raghu font_shipped_with_the_IndiX_system? 7.3. I_have_installed_IndiX_system_but_it_doesn't_show_Hindi_characters._Why? 7.4. Why_are_some_of_the_pixels_in_Hindi_characters_distorted? 7.5. All_Hindi_characters_are_displayed,_but_why_are_they_not_rendered properly? 7.6. Why_can't_I_download_ISO_images_of_Exodus_GNU/Linux™,_yet? 7.1. I can't start the X windows system. It gives an error "Could not open default Indic font 'xyz'". Please make sure that the font 'xyz' is correctly installed and is in the current FontPath. The Indic fonts usually reside in the /usr/X11R6/lib/X11/ fonts/TrueType/ directory. Your FontPath is defined in the /etc/X11/ XFree86Config-4 file. To learn more about howto specify your FontPath, read the section on X Window System (3.2) in this HOWTO. 7.2. Can I use any other font as the default system font instead of the raghu font shipped with the IndiX system? You can load an Indic script font by giving command line server option while starting X Window System. e.g. $ startx -- -devanagari "my_devanagari_font" or $ startx -- -tamil "my_tamil_font" Here, "my_devanagari_font" and "my_tamil_font" should be replaced by the font name that you want to load. You can either specify alias name or full XLFD name for the font. However alias name must be there in fonts.alias file and XLFD name in fonts.dir file. 7.3. I have installed IndiX system but it doesn't show Hindi characters. Why? This could possibly be due to the fact that your Hindi locale has not been setup correctly. To change/set the locale you should set LANG environment variable. Append the line export LANG=hi_IN.UTF-8 in your ~/.bashrc and ~/.bash_profile files. Restart your terminal emulator program and run the application. After this the application should display Hindi characters. 7.4. Why are some of the pixels in Hindi characters distorted? This is probably because the X Font Server (xfs) is running and is still in the current FontPath. You can either shutdown the X Font Server or remove it from the current FontPath. To shutdown xfs issue the following command after becoming root: # /etc/rc.d/init.d/xfs stop To remove xfs from the current FontPath, read the section Section 3.2,_“X Window_System” in this HOWTO. 7.5. All Hindi characters are displayed, but why are they not rendered properly? IndiX system uses an OpenType font to render Indic script characters, as it is the most suitable font format for Indic scripts. If you use some other kind of font, for example a TrueType font or a Bitmap font, then the font does not have enough information that is required to render Indic script text properly. So it is recommended to use only OpenType fonts for Indic scripts. Also, in case you are already using an OpenType font, please update your glibc. 7.6. Why can't I download ISO images of Exodus GNU/Linux™, yet? The good guys at Centurion Linux are looking for sponsors who can take care of their hosting needs. If you are interested in helping Centurion Linux out, please contact me on