Re: Typing Right-To-Left language characters in GtkEntry

Yes, this time it worked!  In fact even without setting the font to
the Code2000 font for the GtkEntry, I'm able to type Arabic text into
the entry.  Thanks so much for your help!

One think I still wish to know is why I'm unable to type on the
terminal window.  Is it possible to enable keyboard layout for only my
GTK application?

Thanks again,

On 6/9/05, Alem Dain <alem dain gmail com> wrote:
Ah, it's a mistake I make all the time.  When I said "en" it should
have been "us".  The setxkbmap command is actually:

setxkbmap -rules xfree86 -model pc104 -layout us,ar

possibly with -option grp:menu_toggle if that's what you want.  This
is why you were getting "Error loading keyboard description": there is
no "en" layout.  Anyway, try this out.  If it still doesn't work, let
me know.  Note that most likely, you do not want to be typing these
things in a terminal... something like a GtkEntry, however, will
certainly produce proper text.

The other thing to do, of course, is tell GTK that you want to use a
font that supports Arabic.  You do something like this:

  PangoFontDescription *font;
  GtkEntry *entry;
  font = pango_font_description_from_string("Code2000");
  entry = gtk_entry_new();
  gtk_widget_modify_font(entry, font);

Just a note, I've noticed that other Unicode X fonts (such as, for
example, whatever GTK uses by default) seem to support Arabic as well;
you may want to try them also.  This might just be me, since I've
install a hajillion extra fonts on my system....

Anyway, the above bits *should* do it for you.  To summarize, use
setxkbmap (I can't speak for any KDE-controlpanel-setting-thingy) to
make sure your keyboard does what you want, and use
PangoFontDescription to make sure you have are using a font that can


On 6/8/05, Gaurav Jain <gaurav anywhere gmail com> wrote:
Hello Alem,

Thanks for the detailed response.  I installed the CODE2000 unicode
font that you mentioned according to the rules given at
 ( using the mkfontscale and mkfontdir commands, and then adding the
path to /etc/X11/XF86Config).

I then tried to exeute the setxkbmap command that you mentioned, but
it failed with the error: "Error loading new keyboard description".

I'm using KDE session, so I also tried setting the Keyboard Layout
from the "Control Center > Regional & Accessibility > Keyboard Layout"
to Arabic.  However, if I do that, whatever I type on the terminal is
not shown on the screen (it looks like an empty space), and it doesn't
even show the square blocks that you mentioned.

Have I missed some step here?
Thanks again,

On 6/9/05, Alem Dain <alem dain gmail com> wrote:
Hmmm, with almost no work at all, I managed to type right-to-left in
Arabic (not that I know a word of it...)

For the purpose of input, no locale information is necessary.  All you
need is the appropriate keyboard mapping loaded in X, as well an an
Arabic-capable unicode font; Pango knows how to render right-to-left

More interesting than the version of Linux you are running are the
versions of GTK and Pango.  As for the keyboard map, I'm not familiar
with the inner workings of xmodmap; I recommend XKB.  You use this
program to dynamically change the keyboard mapping as though you had
edited XF86Config.

So what I did was functionally equivalent to:

setxkbmap -rules xfree86 -model pc104 -layout en,ar -option grp:menu_toggle

Just a quick explanation may be required here.  Most likely you will
leave the "rules" and "model" option alone; if you have something
other than a standard keyboard (with the extra Windows keys) you will
want to change that.  Unfortunately, I'm not sure where you find a
list of other models.  Anyway, the important ones is "layout".  It
specifies that the first one should be english (basic), and the
second, arabic (basic).  You can have up to for.  I like to use the
Menu key to toggle, hence the "-option grp:menu_toggle" bit.

What I in fact did was ran a little GTK program I've written that does
all these things for me, as well as displaying the current keyboard
layout... whee :)  Source code can be provided, fixed bugs would be
most appreciated :)


Now, you also need an Arabic capable Unicode font.  If you are typing
characters appropriately, but lack the font, you'll see little squares
with four digits in them, representing the otherwise unrepresentable
unicode character.  What Unicode font supports Arabic?  I use James
Kass's Code2000 (just google for it).  It's free, and it also supports
Tengwar (again, whee).  I'm sure there are thousands of other fonts
that have Arabic, tho.  In fact, in might come with ... whatever X
comes with.

Hope this helps,

On 6/8/05, Gaurav Jain <gaurav anywhere gmail com> wrote:

I need to enter Right-To-Left language characters (such as Arabic and
Hebrew) in a GtkEntry widget.  I'm using Red Hat Linux 9.0 and have
logged in the Arabic language session.  I then set the locale to
"ar_SA.utf8".  Then I run my small GTK program which has a GtkEntry

But I'm stuck at this point where I need an input method to enter the
arabic characters.  Could somebody help?

(I tried using xmodmap to load an arabic keyboard mapping, but then
nothing happened.  I also need to know where I can get arabic fonts
from, if required).

gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]