I've got two 591's running 4.2 with GL (and OpenGL) installed
for GXT1000-002 graphics boxes. The GL demos run fine, but
the code dies when trying to load multiple X fonts via 'loadXfont'.
The test program below works on our 3.2.5 systems set up for GL, but
won't run on the 591/4.2/GXT1000-002 systems. I'm reinstallying X stuff
on one, but haven't any real clue what to do with this. Oh, the
591's give the following response for the code (given below and compiled
with 'cc file.c -lgl -lX11').
# a.out
found 247 fonts
loading font number 0 -adobe-helvetica-bold-o-normal--0-0-75-75-p-0-iso8859-1
loading font number 1 -adobe-helvetica-bold-o-normal--0-0-75-75-p-0-ucs2.base-0
loading font number 2 -adobe-helvetica-bold-r-normal--0-0-75-75-p-0-iso8859-1
Segmentation fault (core dumped)
#
A huge thanks to anybody who can provide a tip on this one,
-Carl
[file.c]
/* xfonts.c Example C Language Program for GL /
/
xfonts.c
This program demonstrates how to use Enhanced X-Windows
fonts in a GL application
*/
#include <gl/gl.h>
#include <X11/Xlib.h>
#include <stdio.h>
main()
{
Int32 i, wid; /* the GL window ID */
Display *dpy; /* structure describing X session*/
int num_fonts; /* number of fonts X server found */
char **fontlist; /* array of strings
(available font names) */
prefsize (150,150);
wid = winopen ("xfonts");
color (BLACK);
clear();
/* get the connection to X */
/* Normally, the default display is unix:0 */
dpy = XOpenDisplay ("unix:0");
/* Get the names of all fonts that might be Helvetica fonts */
/* (have "helv" appearing in their font name) */
fontlist = XListFonts (dpy, "*helv*", 1000, &num_fonts);
/* other useful X font subroutines are:
* XListFonts
* XListFontsWithInfo
* XFreeFontNames
* XFreeFontInfo
* XSetFontPath
* XGetFontPath
* XFreeFontPath
*/
/* We have decided, by some criteria, to use the fifth
* available Helvetica font (assuming that at least five
* Helvetica fonts are found). We will give it an id of 433.
*/
if ( num_fonts < 4 ) {
fprintf (stderr,"Not enough fonts found!!!\n");
exit (-1);
}
printf("found %d fonts\n",num_fonts);
for(i=0;i<num_fonts;i++)
{
printf("loading font number %d %s\n",i,fontlist[i]);
loadXfont (i, fontlist[i]);
}
/* get rid of the font name list */
XFreeFontNames (fontlist);
/* we want to use this font to draw a string */
font (150); /* do it */
cmov2 (43.0, 56.0);
color (RED);
charstr ("Hello, World");
sleep (20);
/*Quote:}
Changes:
- from wid = winopen "xfonts"); to wid = winopen ("xfonts");
*/
--