<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
   <TITLE>Thai Input method with xmodmap</TITLE>
   <META NAME="Author" CONTENT="Poonlap Veerathanabutr">
   <META NAME="GENERATOR" CONTENT="Mozilla/3.0Gold (X11; I; SunOS 4.1.3-JL sun4m) [Netscape]">
   <META NAME="Classification" CONTENT="Computor Science">
   <META NAME="Description" CONTENT="Explain how to input / output Thai characters on X. Also give examples of using Thai with other applications, xedit, xmacs...Describe basic on font, xmodmap, xkeycaps, etc.">
   <META NAME="KeyWords" CONTENT="xkeycaps, xmodmap, UNIX, Thai, Thai language,zzzthai, Thai input">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000">

<H1><FONT COLOR="#008080">Thai Input method with Xmodmap </FONT><IMG SRC="xlogo.gif" HEIGHT=96 WIDTH=98></H1>

<H3><FONT COLOR="#008000">Introduction</FONT></H3>

<P>With X window system, we can use X client, the <B><TT>xmodmap</TT></B>
to input Thai characters to other applications.To output Thai characters,
it depends on applications you are running, and you must have Thai fonts
to display on screen.</P>

<P>
<HR WIDTH="100%"></P>

<H2 ALIGN=CENTER><FONT COLOR="#008000">Contents</FONT></H2>

<UL>
<P><B><A HREF="#1">1.Obtains Thai fonts first</A></B></P>

<UL>
<P><A HREF="#1.1">1.1.How to install new fonts for X</A></P>

<P><A HREF="#1.2">1.2.Now, what can I do with this Thai fonts?</A></P>

<P><A HREF="#1.3">1.3.Which font is the best?</A></P>
</UL>

<P><B><A HREF="#2">2.The main point, xmodmap</A></B></P>

<UL>
<P><A HREF="#2.1">2.1.Prepairation for Thai input with <B><TT>xmodmap</TT></B></A></P>

<P><A HREF="#2.2">2.2.Edit a simple Thai document with <B><TT>xedit</TT></B></A></P>

<P><A HREF="#2.3">2.3.I want to use <B><TT>emacs</TT></B>!</A></P>

<P><A HREF="#2.4">2.4.What can I do more?</A></P>
</UL>

<P><B><A HREF="#3">3.More about xmodmap (X's Keyboard layout)</A></B></P>

<UL>
<P><A HREF="#3.1">3.1.Edit <I><TT>.xmodmaprc</TT></I></A></P>

<P><A HREF="#3.2">3.2.A graphical front-end to <B><TT>xmodmap, xkeycaps</TT></B>
(cool)</A></P>

<P><A HREF="#3.3">3.3.Thai character set = Latin1 character set?</A></P>

<P><A HREF="#3.4">3.4. Modify xkeycaps' sources </A></P>

<P><A HREF="#3.5">3.5. keysymdef.h</A></P>

<P><A HREF="#3.6">3.6. Modify sources code more</A></P>

<P><A HREF="#3.7">3.7. Unicode</A></P>
</UL>

<P><B><A HREF="#4">4.References</A></B></P>
</UL>

<P>
<HR WIDTH="100%"></P>

<H2><A NAME="1"></A><FONT COLOR="#008000">1.Obtains Thai fonts first</FONT></H2>

<P>First of all you should obtain Thai fonts, available freely at many
ftp sites. Here there are,</P>

<UL>
<P><A HREF="ftp://ftp.fedu.uec.ac.jp/pub/thai/UEC/ZzzThai/Software/UNIX/Fonts">ftp://ftp.fedu.uec.ac.jp/pub/thai/UEC/ZzzThai/Software/UNIX/Fonts/</A></P>

<P><A HREF="ftp://thaigate.rd.nacsis.ac.jp/pub/thaisoft/titech-aima/">ftp://thaigate.rd.nacsis.ac.jp/pub/thaisoft/titech-aima/</A></P>
</UL>

<H3><A NAME="1.1"></A>1.1.How to install new fonts for X</H3>

<P>See <A HREF="http://www.fedu.uec.ac.jp/ZzzThai/unix/nets-mail/nets-mail-s1.html">http://www.fedu.uec.ac.jp/ZzzThai/unix/nets-mail/nets-mail-s1.html</A>
for examples step by step. </P>

<P>Extract font if it came in form <I><TT>font_x.tar.</TT></I>Choose the
directory that the new fonts should be. You can choose any directory or
new directory as you want. If you use Linux, installing fonts in /usr/X11R6/lib/X11/fonts/misc/
is not a bad choice. In that directory, run these command, <TT>mkfontdir,
<B>xset fp</B>+ <I><B>new_font_path</B>.</I></TT>Check new fonts by using
&quot;<B><TT>xlsfonts</TT> | grep thai</B>&quot; command. If you can not
find Thai fonts, you may have to log out and log in again.</P>

<P>The part that often occur error is &quot;<B><TT>xset fp+</TT> <I><TT>new_font_path</TT></I></B>&quot;
. If you get strange errors with <TT><B>xset</B> </TT>when you extend the
X server's font path with the fp+ command-line parameter, the error message
may not be descriptive of the real problem. If you're sure you've done
everything right, then check the file permissions on the directory you're
trying to add to the X server's font path. In order for xset to work, it
requires write access to this directory. In many systems, the font directories
allow only write access for root user. The xset error message, though,
doesn't give you a clue if this is the problem.</P>

<P>To run the xset command with fp+ option to add the new font directory
to your font path. There is another thing you need to be careful about
this that you use the font path as it would be known to your local server.
For example, your home directory <I><TT>/home/your_login_name</TT></I>
on the machine <TT>machine_B</TT> were NFS-mounted to your work station
<TT>machine_A</TT> under the name <I><TT>/machine_B/home/your_login_name</TT></I>,
then you need to specify <I><TT>/machine_B/home/your_login_name/new_font_path</TT></I>
in your font path. Otherwise, if you use the wrong font path, the local
server can't find the directory locally and gives you the error,</P>

<UL>
<PRE><TT>machine_B%<B>xset fp+ <I>/home/your_login_name/new_font_path
</I></B>X Error of failed request: BadValue (integer parameter out of range for operation)
 Major opcode of failed request: 51 (X_SetFontPath)
 Value in failed request: 0x5
 Serial number of failed request: 4
 Current serial number in output stream: 6</TT></PRE>
</UL>

<P>If you look from <TT>machine_A</TT> you will find that <I><TT>/home/your_login_name</TT></I>
doesn't exist.</P>

<UL>
<PRE>machine_A%<B><TT>ls -d <I>/home/your_login_name
</I></TT></B>/home/your_login_name not found
machine_A%<B><TT>ls -d <I>/machine_B/home/your_login_name
</I></TT></B>/machine_B/home/your_login_name</PRE>
</UL>

<P>This is the NFS-mounted problem. If you succeeded installing new fonts
try &quot;<B><TT>xset -q</TT></B>&quot; see font path, you will see the
new font directory.</P>

<P>If you fail to set new fontpath, try </P>

<UL>
<PRE>%xset fp+ tcp/130.153.137.1:7000</PRE>
</UL>

<P>This will add the new font path from our font server.</P>

<P><B><FONT COLOR="#FF0000">Total solution: </FONT></B><FONT COLOR="#000000">ask
your administrator to install new fonts.</FONT></P>

<H3><A NAME="1.2"></A>1.2.Now, what can I do with these Thai fonts?</H3>

<P>Now, at least you can <B>view</B> Thai characters on your <TT>xterm
</TT>with option<TT> &quot;<B>-fn <I>thai_font</I></B>&quot;.</TT></P>

<CENTER><P><IMG SRC="xterm_th.gif" HEIGHT=351 WIDTH=384></P></CENTER>

<P>You can also view Thai documents by using netscape navigator. Don't
forget to select Thai font.</P>

<H3><A NAME="1.3"></A>1.3.Which font is the best?</H3>

<P>There are many fonts for you to choose. From our ftp sites you can get
these fonts. Some fonts has a trouble with displaying. For example, <TT>etl
fonts</TT> display font worst than <TT>thai8x16</TT> in <B><TT>xedit</TT></B>.
The position of &quot;wannayuk,sara&quot; are not correct. You can use
program <B><TT>xfd</TT></B> to see different between these fonts.</P>

<UL>
<PRE>%xfd -fn thai8x16 &amp;
%xfd -fn -etl-fixed-medium-r-normal--14-140-72-72-m-70-tis620.2529-1<TT> &amp;</TT></PRE>
</UL>

<P><TT>You will see the difference.</TT></P>

<P><TT>There are 44 fonts from </TT><A HREF="ftp://ftp.fedu.uec.ac.jp/pub/thai/UEC/ZzzThai/Software/UNIX/Fonts/nets-fonts.tar">ftp://ftp.fedu.uec.ac.jp/pub/thai/UEC/ZzzThai/Software/UNIX/Fonts/nets-fonts.tar
</A>In <I><TT>nets-fonts.tar</TT></I>, there are <I><TT>dbttbdfx.tar</TT></I>
and <I><TT>fix_fonts.tar</TT></I>. You must extract them too.</P>

<P>See <A HREF="font_list">the list of font</A>. </P>

<P>These are some X programs that you can use to decide the fonts.</P>

<BLOCKQUOTE>
<CENTER><TABLE BORDER=1 WIDTH="80%" HEIGHT="40%" BGCOLOR="#C0C0C0" >
<CAPTION>
<P>X programs for working with fonts</P>
</CAPTION>

<TR>
<TD ALIGN=CENTER BGCOLOR="#8080C0"><B>Program</B></TD>

<TD ALIGN=CENTER BGCOLOR="#8080C0"><B>Use</B></TD>
</TR>

<TR>
<TD><B><TT>bdftopcf</TT></B></TD>

<TD>Converts bitmap font file to binary X server font file</TD>
</TR>

<TR>
<TD><B><TT>fs</TT></B></TD>

<TD>Font server; can scale fonts for X server</TD>
</TR>

<TR>
<TD><B><TT>fsinfo</TT></B></TD>

<TD>Prints information on font server</TD>
</TR>

<TR>
<TD><B><TT>fslsfonts</TT></B></TD>

<TD>Lists font server fonts</TD>
</TR>

<TR>
<TD><B><TT><A HREF="xfd_th.gif">xfd</A></TT></B></TD>

<TD>Displays characters in a font</TD>
</TR>

<TR>
<TD><B>fstobdf</B></TD>

<TD>Converts a font server scaled font to a bitmap font file</TD>
</TR>

<TR>
<TD><B><TT><A HREF="xfonsel_th.gif">xfontsel</A></TT></B></TD>

<TD>Allow you to choose a font graphically</TD>
</TR>

<TR>
<TD><B>mkfontdir</B></TD>

<TD>Set up a font directory</TD>
</TR>

<TR>
<TD><B><TT>xlsfonts</TT></B></TD>

<TD>Lists available font names</TD>
</TR>

<TR>
<TD><B><A HREF="xfed_th.gif">xfed</A></B></TD>

<TD>Font editor, not part of standard X distribution</TD>
</TR>

<TR>
<TD><B>xset</B></TD>

<TD>X setting utility, <B><TT>xset fp+</TT></B> <I><TT>font_path </TT></I>to
set font path</TD>
</TR>
</TABLE></CENTER>
</BLOCKQUOTE>

<P>
<HR WIDTH="100%"></P>

<H2><A NAME="2"></A><FONT COLOR="#008000">2.The main point, xmodmap</FONT></H2>

<P>The <B><TT>xmodmap</TT></B> program is used to edit and display the
keyboard modifier map and keymap table that are used by client applications
to convert event keycodes into keysyms. It is usually run from the user's
session startup script to configure the keyboard according to personal
tastes.</P>

<P>Example:</P>

<PRE>         %<B><TT>xmodmap -e &quot;keysym CapsLock =&quot;</TT></B></PRE>

<P>The position of Control key in workstation and PC-UNIX are different.
If you use PC-UNIX and workstation, I think you have hit the wrong key
accidentally. To solve this problem, above example will disable Caps Lock
entirely. This example shows how to edit key with command line. Actually,
you may provide the file that contains configuration, then run <TT>&quot;<B>xmodmap
<I>config_file</I></B>&quot;</TT>.</P>

<H3><A NAME="2.1"></A>2.1.Prepairation for Thai input with xmodmap</H3>

<P><FONT COLOR="#FF0000">Step 1:</FONT></P>

<P>Download xmodmap's configuration file to your home directory. This file
shold work with any QWERTY English keyboard layout. </P>

<UL>
<P>Download file <A HREF="Xmopmap">Xmodmap</A></P>
</UL>

<P><FONT COLOR="#FF0000">Step2:</FONT></P>

<P>Rename downloaded configuretion file to <I><TT>.xmodmaprc</TT></I> or
<I><TT>.Xmodmap</TT></I></P>

<UL>
<PRE>%<B>mv <I><TT>config_file </TT></I>.xmodmaprc</B></PRE>
</UL>

<P><FONT COLOR="#FF0000">Step 3:</FONT></P>

<P>Add the following line in your <I>.xsession</I> file (if you start X
with <I>xdm</I>) or <I>.xinitrc </I>(if you start X with <B><TT>startx</TT></B>
or <B><TT>xinit</TT></B> command).</P>

<UL>
<PRE><B>xmodmap .xmodmaprc</B></PRE>
</UL>

<P>This will load xmodmap's configuration automatically when you start
X. If you want to try Thai input now, run the following command,</P>

<UL>
<PRE>%<B>xmodmap <I>.xmodmaprc</I></B></PRE>
</UL>

<H3><A NAME="2.2"></A>2.2.Edit a simple Thai document with xedit</H3>

<P>Now, I will show you what can you do with Thai fonts and <B><TT>xmodmap.
</TT></B></P>

<P><FONT COLOR="#FF0000">Step 1:</FONT></P>

<P><B><TT>Xedit</TT></B> is a editor program that comes with X window system.
Actually it is not powerful as <B><TT>emacs</TT></B>, but <B><TT>xdit</TT></B>
can display thai font while <B><TT>emacs</TT></B> can not. Run the following
command,</P>

<UL>
<PRE>%<B><TT>xedit -fn thai8x16 &amp;</TT></B></PRE>
</UL>

<P>This tell <B><TT>xedit</TT></B> to use Thai font named <I><TT>thai8x16</TT></I>
for displaying. Make sure you already have Thai fonts in your system. You
may replace <TT><I>thai8x16</I> </TT>by any Thai fonts you like, here I
use font <TT><I>thai8x16</I> </TT>because xedit can display font's position
well.</P>

<P><FONT COLOR="#FF0000">Step 2:</FONT></P>

<P>After you type some English, to switch to Thai mode, press on <TT>Mode_Switch</TT>
key. You can change the <TT>Mode_Switch</TT> key as you want.</P>

<P><FONT COLOR="#FF0000">Step 3:</FONT></P>

<P>Type some Thai sentences, you will see something like this,</P>

<CENTER><P><IMG SRC="xedit_th.gif" HEIGHT=210 WIDTH=325></P></CENTER>

<P><FONT COLOR="#FF0000">Step 4:</FONT></P>

<P>To switch to English mode, press <TT>Mode_Switch</TT> key again.</P>

<P><FONT COLOR="#FF0000">Step 5:</FONT></P>

<P>Save file as the name you like. You may call <B><TT>xedit</TT></B> to
edit that file again, but remember you should add option &quot;<B><TT>-fn
<I>thai_font</I></TT></B><I><TT>&quot;</TT></I>. Thai document which created
from xedit can view on Windows95 with wordpad, Likit and other editor.
You may alias <TT>xedit </TT>to &quot;<B><TT>xedit- fn <I>thai_font</I></TT></B>&quot;
by using command alias, for example</P>

<UL>
<PRE>%<B>alias xedit &quot;xedit -fn <I>thai_font</I>&quot;</B>  ( in C-shell's case )</PRE>

<PRE>%<B>alias xedit='xedit -fn <I>thai_font</I>'</B>  ( in bash shell's case)</PRE>
</UL>

<P>You can also view that Thai documents with <B><TT>more</TT></B>, if
you use <B><TT>xterm</TT> </B>with option &quot;<B><TT>-fn <I>thai_font</I></TT></B>&quot;.</P>

<H3><A NAME="2.3"></A>2.3.I want to use emacs!</H3>

<P>I rarely use <B><TT>xedit</TT></B> because <B><TT>emacs </TT></B>is
more powerful. I try the same way to input Thai characters in <B><TT>emacs</TT></B>
but it did not work. If you want to input Thai in <B><TT>emacs</TT></B>,
I strongly recommend <B><TT>mule</TT></B> (MULti language Enhancement to
GNU Emacs). We can edit documents in about 30 languages and display in
one times. These are the language that you can use with mule. Amharic,
Arabic, Danish(Dansk), English, Esperanto, Finnish(Suomi), Freanch, German(Deutsh
Nord), German (Deutsh Sud), Greek, Hebrew, Italiano, Maltese, Nederlands(Vlaams),
Norwegian(Norsk), Polish, Russian, Spanish, Swedish, Thai, Tigrigna, Turkish,
Vietnamese, Yoguslavian, Japanese, Chinese, Cantonese, Hangul and difference
among Chinese characters inGB, JIS, KSC, BIG5. Really perfect if you are
looking for multilingual editor! <B>Xmodmap is not necessary at all</B>.
For more detail click <A HREF="http://www.fedu.uec.ac.jp/ZzzThai/unix/mule">http://www.fedu.uec.ac.jp/ZzzThai/unix/mule</A>.</P>

<P>If <B><TT>mule</TT></B> supply you too much, you can try <B><TT>Xemacs</TT></B>.
<B><TT>Xemacs</TT></B> is a better interface version for <B><TT>emacs</TT></B>.
You can choose Thai font from menu bar. Warning, you still want <B><TT>xmodmap</TT></B>
to input Thai characters. See <A HREF="http://www.xemacs.org/">http://www.xemacs.org/</A>
for information on xemacs.</P>

<CENTER><P><IMG SRC="xemacs_th.gif" HEIGHT=166 WIDTH=675></P></CENTER>

<H3><A NAME="2.4"></A>2.4.What can I do more?</H3>

<P>As I said you can input Thai characters with xmodmap in the same way
as above example with <B><TT>xedit</TT></B>, if the applications can display
Thai fonts <B>and </B>accept input from xmodmap. I tried the same way with
<B><TT>xterm -fn thai_font</TT></B> but failed. You may this input method
with <B><TT>xpaint,xemacs</TT></B>...( tell me if you know more :-) ) Some
application may have to add option &quot;<B><TT>-fn <I>thai_font</I></TT></B>&quot;
to display Thai font on X. You may make the <I><TT>.Xdefaults</TT></I>
or <I><TT>.Xresources</TT></I> file or set <B><TT>alias.</TT></B></P>

<P>To send E-mail see <A HREF="xmailer.html">http://www.fedu.uec.jp/ZzzThai/xio/xmailer.html</A></P>

<P>
<HR WIDTH="100%"></P>

<H2><A NAME="3"></A><FONT COLOR="#008000">3. More about xmodmap (X's Keyboard
layout)</FONT></H2>

<H3><A NAME="3.1"></A>3.1. Edit .xmodmaprc ( .Xmodmap )</H3>

<P>Our concept is to input 2 languages, Thai and English. <B><TT>Xmodmap</TT></B>
is a good choice with this concept but it is easier to make a Thai keyboard
layout with <B><TT>xkeycaps</TT></B> (<A HREF="#3.2">see <B><TT>xkeycaps</TT></B></A>).
If you look at the <I><TT>.xmodmaprc</TT></I>, you will see,</P>

<UL>
<PRE>! For Sun keyboard
keysym F1   = Mode_switch  &lt;-- choose F1 as Mode_switch key
remove  lock = Caps_Lock    &lt;-- remove Lock modifier from Caps Lock key 
add     lock = Mode_switch  &lt;-- add Lock modifier to F1
add     mod2 = Modeswitch   &lt;-- add mod2 (Thai input) to F1</PRE>
</UL>

<UL>
<PRE>.....</PRE>

<PRE>keysym bracketleft = 0x005b 0x007b 0272 0260
keysym bracketright = 0x005d 0x007d 0305 comma 
keysym a = a A 0277 0304
keysym s = s S 0313 0246
keysym d = d D 0241 0257</PRE>

<PRE>.....</PRE>
</UL>

<P>For example, <TT>keysym a = a A 0277 0304 </TT>tells computer to know
that, in English mode if we press the &quot;A&quot; key, the character
<TT>a</TT> or <TT>A</TT> (Shift) will be on screen. In Thai mode, the character
&quot;Thai_fofan&quot; or &quot;Thai_ru&quot; will be displayed on screen.</P>

<CENTER><P><IMG SRC="thai_tab.gif" HEIGHT=503 WIDTH=312 ALIGN=ABSBOTTOM></P></CENTER>

<P>If you look at tis-code table above, you can know that 0277 (0xbf) is
stand for &quot;Thai_fofan&quot; in octal code. You can change to hexadecimal
code, 0xbf that is equivalent to 0277. </P>

<P>You can find grammar from man page for <B><TT>xmodmap</TT></B> or <B><TT>xkeycaps</TT></B>.</P>

<UL>
<PRE>%<B><TT>man xmodmap</TT></B></PRE>

<PRE>or</PRE>

<PRE>%<B><TT>man xkeycaps</TT></B> ( if you have <B><TT>xkeycaps</TT></B> in your system )</PRE>
</UL>

<H3><A NAME="3.2"></A>3.2. A graphical front-end to xmodmap, xkeycaps (cool)</H3>

<P><B><TT>Xkeycaps</TT></B> is a graphical front-end <B><TT>xmodmap</TT></B>.
Copyright (c) by <A HREF="http://home.netscape.com/people/jwz">Jamie Zawinski.</A>
You can get information about xkeycaps from <A HREF="http://home.netscape.com/people/jwz/xkeycaps/">http://home.netscape.com/people/jwz/xkeycaps/
</A>I used <B><TT>xkeycaps</TT></B> to modify xmodmap's configuration file
for Sun type4 (X Consortium R4/R5 layout) keyboard to PC 101 key keyboard
#2 (Linux/XFree86 US layout) .</P>

<P><IMG SRC="xkeycaps.gif" HEIGHT=250 WIDTH=550></P>

<P>To edit the key, point to cursor to the key that you want to edit. Click
on right button of your mouse, select edit key. The expression &quot;<TT>keysym
a = a A 0277 0304</TT>&quot; can show graphically as</P>

<CENTER><P><IMG SRC="Aa.gif" HEIGHT=320 WIDTH=519></P></CENTER>

<P>That means the key &quot;A&quot; is set to &quot;a&quot;, &quot;A&quot;,
&quot;questiondown&quot; and &quot;Adiaeresis&quot; in <B>Latin1 character
set! </B>That is, or <B><TT>xmodmap</TT></B>, the followings sentences
are equal.</P>

<UL>
<PRE>keysym A = a A 0277 0304  &lt;-- mixed expression
keysym A = 0x61 0x41 0xbf 0xc4  &lt;-- hexadecimal expression
keysym A = 0141 0101 0277 0304  &lt;-- octal expression
keysym A = a A questiondown Adiaeresis  &lt;-- text expression</PRE>
</UL>

<P>Note that keycode for &quot;A a key&quot; is depend on keyboard type.
This example is PC 101 key keyboard #2 (Linux/XFree86 US layout) , keycode
for &quot;A&quot; is 0x26.</P>

<P>You can also write, </P>

<UL>
<PRE>keycode 0x26 = 0x61 0x41 0xbf 0xc4</PRE>
</UL>

<P>See <A HREF="./man/xmodmap">man page</A> for more information how to
use this program.</P>

<H3><A NAME="3.3"></A>3.3. Thai character set = Latin1 character set?</H3>

<P>From above section, you can see that we can express &quot;Thai_fofan&quot;
as &quot;questiondown&quot; and express &quot;Thia_ru&quot; as &quot;Adiaeresis&quot;.
The following are Latin1 character set table and tis620 character set table
that I modified from xfd.</P>

<PRE><IMG SRC="latin1.GIF" HEIGHT=548 WIDTH=504><IMG SRC="thai_tab.gif" HEIGHT=503 WIDTH=312></PRE>

<P>You can see that from 0xa0, Thai characters code and Latin1 are in the
same area. This Thai character code table is based on <A HREF="http://thaigate.rd.nacsis.ac.jp/refer/thaiconf/">tis620</A>.
Therefore if you use xapplication that does not display Thai font and you
input Thai characters, guess what will you see.</P>

<P>Because Thai font code use the same area with Latin1, this font code
can be category to <A HREF="http://user.cs.tu-berlin.de/~czyborra/charsets/">ISO8859</A>
, Information Processing - 8 bit Single-byte Code Graphic Character Sets,
character set. Most European character set are ISO8859. As you can see
from the table we can display one character by typing one key, so Thai
character set is on of ISO8859 series. When you choose fonts from netscape,
you may notice that DbThaiText font is in the Latin1 group.</P>

<H3><A NAME="3.4"></A>3.4. Modify xkeycaps' sources </H3>

<P><B><TT>xkeycaps </TT></B>can display Thai characters while you are clicking
on the key in <TT>Mode_Switch. </TT>You have to change the line</P>

<UL>
<PRE><TT>  &quot;*Label.font:                 *-courier-medium-r-*-*-*-120-*-*-*-*-*-*&quot;,</TT></PRE>
</UL>

<P>to</P>

<UL>
<PRE>  &quot;*Label.font:                  -etl-fixed-medium-r-normal--14-140-72-72-m-70-tis620.2529-1&quot;,</PRE>
</UL>

<P>You can get this font from <A HREF="ftp://ftp.fedu.uec.ac.jp/pub/thai/UEC/ZzzThai/Software/UNIX/Fonts/Mule/etl_fonts.tar">ftp.fedu.uec.ac.jp/pub/thai/UEC/ZzzThai/Software/UNIX/Fonts/Mule/etl_fonts.tar
</A>this font can display with <B><TT>xkeycaps</TT></B> properly. Complie
<B><TT>xkeycaps </TT></B>agian you will see the difference. When you se
mouse click on <TT>Mode_switch </TT>then click any key, you will see Thai
character in label (See picturs below). Use -fn option will not change
font of this label. Now you can check your keymap easier.</P>

<PRE><IMG SRC="xkeycaps_latin.gif" HEIGHT=418 WIDTH=469> 
 <IMG SRC="xkeycaps_th.gif" HEIGHT=415 WIDTH=421></PRE>

<H3><A NAME="3.5"></A>3.5. keysymdef.h</H3>

<P>If you view &quot;<I><TT><A HREF="Keysymde.h">keysymdef.h</A></TT></I>&quot;
under <I><TT>/usr/X11R6/include/X11/</TT></I> you will see,</P>

<UL>
<PRE>.....</PRE>

<PRE>#define XK_questiondown        0x0bf
#define XK_Agrave              0x0c0
#define XK_Aacute              0x0c1
#define XK_Acircumflex         0x0c2
#define XK_Atilde              0x0c3
#define XK_Adiaeresis          0x0c4</PRE>

<PRE>.....</PRE>

<PRE>/*
 * Thai
 * Byte 3 = d
 */

#ifdef XK_THAI
#define XK_Thai_kokai                                   0xda1
#define XK_Thai_khokhai                                 0xda2
.....</PRE>

<PRE>#define XK_Thai_fofan                                   0xdbf
#define XK_Thai_phosamphao                              0xdc0
#define XK_Thai_moma                                    0xdc1
#define XK_Thai_yoyak                                   0xdc2
#define XK_Thai_rorua                                   0xdc3
#define XK_Thai_ru                                      0xdc4

.....</PRE>
</UL>

<P>Surprize, Thai characters were included in this file too. That means
X11R6, keysym definition use one more byte to indicate specific keysym.
Thai and Latin1 should not use the same code for keysym anymore. However
we must create new font to support this. We must use program that accepts
2 bytes cahracter also. </P>

<H3><A NAME="3.6"></A>3.6. Modify sources code more</H3>

<P>Because X11R6 provide Keysym for Thai characters, we can modify <B><TT>xkeycaps</TT></B>'
sources code to select Thai characters from popup menu. In <I><TT>command.c,</TT></I>add
Thai after Hebrew. Change <TT>KEYBOARD_CHARSET_INDEX 13</TT> to <TT>KEYBOARD_CHARSET_INDEX
14 </TT>and change <TT>VENDOR_CHARSET_INDEX 14 </TT>to <TT>VENDOR_CHARSET_INDEX
15.</TT></P>

<UL>
<PRE>static char *all_keyset_names [] = {
  &quot;Latin1&quot;,
  &quot;Latin2&quot;,
  &quot;Latin3&quot;,
  &quot;Latin4&quot;,
  &quot;Kana&quot;,
  &quot;Arabic&quot;,
  &quot;Cyrillic&quot;,
  &quot;Greek&quot;,
  &quot;Technical&quot;,
  &quot;Special&quot;,
  &quot;Publishing&quot;,
  &quot;APL&quot;,
  &quot;Hebrew&quot;,
  &quot;Thai&quot;,       /* add this line */
  &quot;Keyboard&quot;,
#ifdef DO_VENDOR_KEYSYMS
  &quot;Vendor&quot;,
#endif
  0
};

#define KEYBOARD_CHARSET_INDEX 14  /* changed from 13 */
#ifdef DO_VENDOR_KEYSYMS
#define VENDOR_CHARSET_INDEX 15    /* changed from 14 */
#endif</PRE>
</UL>

<P>Complie sources code again you can select Thai characters from popup
menu.</P>

<CENTER><P><IMG SRC="popup_th.gif" HEIGHT=335 WIDTH=519></P></CENTER>

<P>This will help you to make keymap but it is <B>not useful</B>. Because
keysymdef.h defines Thai characters to be 2 bytes, therefore we have to
use Thai font that Thai characters locate from 0xda1 to 0xdfb and program
that accepts 2 bytes code. Modifying Thai font is not difficult but editors
that accept 2 bytes code rarely exist now.</P>

<H3><A NAME="3.7"></A>3.7. Unicode</H3>

<P>1 byte character set is not enough if we want to make multilingual environment.
Unicode provide the solution for this problem. Unicode is 2 bytes character
set, ideal for multilingual environment. Thai characters are located on
A partition, from 0E00 to 0E7F. See <A HREF="http://www.unicode.org/">Unicode
organization</A> for more information.</P>

<P><IMG SRC="uni_th.gif" HEIGHT=380 WIDTH=717></P>

<H2><A NAME="4"></A><FONT COLOR="#008000">4.References</FONT></H2>

<OL>
<LI>Linda Mui and Valerie Quercia, &quot;<B>X USER TOOLS</B>&quot;, <A HREF="http://www.ora.com/">O'Reilly
&amp; Associates,Inc</A>.</LI>

<LI><A HREF="http://ourworld.compuserve.com/homepages/efjohnson/">Eric
F. Johnson</A>, Kevin Reichard, &quot;<B>The UNIX System Administrator's
Guide to X</B>&quot;, M&amp;T Books.</LI>

<LI>&quot;<IMG SRC="book_jap.gif" ALT="jap book" HEIGHT=20 WIDTH=206 ALIGN=BOTTOM>&quot;,
Prentice Hall.</LI>

<LI><A HREF="http://www.fedu.uec.ac.jp/ZzzThai/unix/">http://www.fedu.uec.ac.jp/ZzzThai/unix/</A></LI>

<LI><A HREF="http://thaigate.rd.nacsis.ac.jp/refer/thaiconf/">http://thaigate.rd.nacsis.ac.jp/refer/thaiconf/</A></LI>
</OL>

<DIV ALIGN=right><P><I><A HREF="http://www.fedu.uec.ac.jp/ZzzThai/staff.html">-PLV</A></I></P></DIV>

<P><!--#include virtual="/FEDU/FEDUusers/Thailand/ZzzThai/unix/tail.shtml" --></P>

<CENTER><P>|<A HREF="mailto:uecthai@fedu.uec.ac.jp">--uecthai@fedu.uec.ac.jp--</A>|<A HREF="http://www.fedu.uec.ac.jp/ZzzThai/">--ZzzThai
Main Page--</A>|</P></CENTER>

<CENTER><P><!--#exec cmd="/export/www/cgi-bin2/ZzzThai/counter /export/www/cgi-bin2/ZzzThai/Counter/unix/iounix.dat" --></P></CENTER>

</BODY>
</HTML>
