devanagari fonts rendering in python-Tkinter
Private: (?)
No
My email address is siva@mail.cern.ch
Hi,
I hope a tkinter question can be addressed here as well.
I am trying to display Devanagari unicode fonts in a
tkinter label/text
widget.
To make new characters, the unicode fonts provide this
functionality of
using combination of unicode codes to make a single new
character. Like
for instance the kSa in unicode is
u'\u0915\u094D\u0937'. In Linux, this
looks perfect in a web-browser or in my shell-konsole
which supports
unicode.
I am using Python-2.4.2 which definitely supports
unicode. But the
problem is in the final visual rendering that it does
not show the kSa
character but shows it as k Sa as two separate
characters. For example,
u'\u0915\u093f'. u0915 stands for 'ka' the first
consonant in devanagari.
u093f stands for the third vowel 'i' pronounced as 'e'
as in 'pre'. This
vowel when combined to 'ka' must have a line+curve that
visually looks
like 'f' should be to the left of the consonant 'ka'.
Though in windows,
when I give u'\u0915\u093f', it renders correctly, in
redhat linux, it shows the 'f' to the right which makes
it look like it is adding the
vowel to the next consonant in a word. Now there is
also this another
problem but both in windows and linux alike. The
making of new
characters like the kSa or using the Zero-Width-Joiner and
Zero-Width-Non-Joiner to make half characters etc....
Is there by any chance these things could be correctly
rendered?? I mean,
I use PyQt, it correctly renders the fonts. But, PyQt
needs Qt and
getting Qt for Windows is a whole big story. So, I
want to stick to
Tkinter and try. Can you please suggest any method
that would allow me
to make the Tkinter-Python to give the correct visual
rendering of the
characters. We use the X11 fonts while running PyQt
which I guess the Qt
uses. If my xterm shell-konsole could render unicode
fonts correctly, I
would guess Python Tkinter as a GUI package must
definitely be able to
render the fonts correctly.
please let me know if you can help me, if yes, then how??
Thanks in advance!!
Cheers,
-Siva.
One more comment I need to add is the reply I got from the
Python help group. They mentioned that, it is because of
the limitation of the Tcl/Tk and asked me to contact the
Tcl/Tk help group. That is why I am here. Can you please
suggest, if Tcl/Tk current or next version will support
this
kind of unicode rendering?? Or can you suggest some very
simple thing that I could change to get this working like a
iso10646-1.enc file??
Logged In: YES
user_id=79902
At a guess, this is an area where the Xft font renderer (an
option in 8.5) is more able than Tk's old one. I'd guess
that Qt probably uses Xft to render anyway.
Given that, the real question is whether the Xft support is
backportable to 8.4? Assigning to our font handling wizard
for consideration.
Logged In: YES
user_id=68433
A quick test shows that "\u0915\u093f" and
"\u0915\u094D\u0937" are rendered the same in Tk 8.4 and Tk
8.5+Xft. (I have no idea if it's correct or not, just that
they look the same). So Xft isn't helping any here.
Gtk+ uses a library called "Pango" for text rendering that
takes care of this sort of thing; Qt uses something similar
(though I don't know what.)
Sorry I don't have any other information on this...
Logged In: YES
user_id=143885
Indic scripts fall into the category of scripts
that require non-trivial rendering mechanisms
(so-called "shaping"). Usually this is driven
by rendering information contained in TrueType
fonts (OpenType or AAT). Windows and Mac OS X
have the interpretation of these rendering hints
built-in (although Tk gets easily confused about
the results even on those platforms), on X11 you
need a separate rendering engine like Pango.
Last I looked, Pango was rather dependent on
Gnome and also it's GPL, so it's not a solution
for Tk.
Freedesktop.org might be the place to develop
something generic and stand-alone. From their
software list, HarfBuzz
<http://www.freedesktop.org/wiki/Software_2fHarfBuzz>
sounds like something that might help, although
it's not a complete solution. I'm not sure if
their license is acceptable for Tk.