Parent document is top of "Motif FAQ (Part 6 of 9)"
Previous document is "218) Why doesn't XmStringGetNextSegment() work properly?"
Next document is "220) How can I control color of individual strings to show status,"
219) Why does using XmStringDraw cause a Bad Font error?
[Last modified: Mar 96]
Answer: Thomas Berlage (berlage@gmdzi.gmd.de) wrote: You could call this a
bug in Motif. You pass a GC to XmStringDraw, however, Motif wants to use the
fonts from the font list to draw the string. Therefore it replaces the font
of the GC temporarily with some fonts of its own as specified in the font
list. In the end it tries to restore the old font of the GC. There comes the
problem:
If a GC uses the default font, the client side GC structure does not have a
valid font id (that is the 0xffffffff you may see in the error message). Motif
tries to restore this invalid id at the end.
The workaround is: Before drawing with XmStringDraw, set the font id of the GC
to any valid font id, for example using
XSetFont (display, gc, XLoadFont (display, "fixed"));
Another solution is available from "Harry's Motif Programming Corner", Harald
Albrecht, albrecht@igpm.rwth-aachen.de, who writes:
"It's somewhat longer but doesn't rely on a font named "fixed" installed on
your platform. Instead it takes a fontlist and then uses the first font listed
there. You'll find this source together with a short demo program (which
creates a DrawingArea and then paints some text in it) on:
ftp.igpm.rwth-aachen.de (134.130.161.30)
in: /arc/pub/unix/motif/RenderXmString.tar.gz
There's also a html page available:
Harry's Motif Programming Corner
http://www.igpm.rwth-aachen.de/~albrecht/motifcorner.html
Thanks to Harald Albrecht (albrecht@igpm.rwth-aachen.de). URL corrected by
irca (irca@zip.cra.enel.it).
Parent document is top of "Motif FAQ (Part 6 of 9)"
Previous document is "218) Why doesn't XmStringGetNextSegment() work properly?"
Next document is "220) How can I control color of individual strings to show status,"