[comp.windows.x] Problem with non-ascii letters in XTextWidth.

anubis@skinfaxe.diku.dk (Steen Linden) (07/14/89)

When trying to use characters with ASCII codes greater than 127,
XTextWidth returns zero. The specific problem is that I am trying to
get letters like Aring from the Adobe fonts to work in xpaint but both
XDrawString and XTextWidth can't handle characters with ASCII codes
greater than 127. 

Shouldn't these functions be able to handle characters from firstCol
and NumCols ahead like specified in the function GetGlyphs in
XTextExt.c of the Xlib code ? In my case firstCol is 32 and NumCols
224 giving the maximum character code 255.

I can hack xpaint to output Aring by casting the characters returned
by XLookupString to unsigned char. Unfortunately I can't make
XTextWidth return the right width unless I hack the function GetCS in
XTextExt.c to work on unsigned chars as well. It is the first line
that needs to be changed to "c = (unsigned char) chars[ind] -
firstCol".  The problem that "chars[ind]" are sign extended when
operated upon as an int.

In case is is of any interest I am using X11R3. The server is a qvss
server running on a VAXStation2000 with MORE/bsd from Mt. Xinu and is
compiled with the native cc. xpaint is running on a Sun4 with SunOS 4.0
and is compiled with gcc-1.34. Xlib is compiled as a shared library
with gcc-1.34.

--Steen

Steen Linden (anubis@diku.dk)    |   It's all absolutely devastatingly true -
The Computer Department		 |   except the bits that are lies.
DIKU, U. of Copenhagen		 |	Douglas Adams:
Denmark				 |	  The Hitchhikers Guide to the Galaxy.

rws@EXPO.LCS.MIT.EDU (07/25/89)

    When trying to use characters with ASCII codes greater than 127,
    XTextWidth returns zero.

Yup, the R3 version is buggy for character codes > 127.

net@TUB.BITNET (Oliver Laumann) (07/25/89)

> When trying to use characters with ASCII codes greater than 127,
> XTextWidth returns zero.

The function GetCS() in lib/X/XTextExt.c is broken.  I have already
reported this some months ago.  You can easily write your own text
width function by adding the widths found in the XCharStructs of the
font you are using.

--
Oliver Laumann              net@TUB.BITNET              net@tub.UUCP