🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sgi.misc
Article #175

Re: Help needed(2): Xlib

#175
From: Ralf Beyer DLR
Date: Thu, 07 Jan 1993 11:47
108 lines
3498 bytes
	
	I tried this with various other applications (all XLib-based) with
	the very same crash at the same point. In each case, XLoadFont() goes
	through allright. XQueryFont() does not. XLoadQueryFont() does not.
	
The following code taken from one of my programs which runs on SGI with
the display being the same SGI, on SGI with the display being another
SGI and on SGI with the display being a SUN. SGI OS is 4.0.5, SUN OS
is 4.1.1 (Open Windows). May be this is of any help.

Regards

Ralf Beyer

----------------------------------------------------------------------
typedef struct
	{
	short	number;
	short	input;				/* input channel */
	Widget	parent;
	int	xrel;
	int	yrel;
	short	fontindx;
	short	foreground;
	short	background;
	char	string[20];
	Widget	widget;
	short	fontsizeclass;
	} LAbel;
	
char	*fontname[NO_OF_FONTS] = {
		"*courier-bold-o-*-80-*",
		"*courier-bold-o-*-100-*",
		"*courier-bold-o-*-120-*",
		"*courier-bold-o-*-140-*",
		"*courier-bold-o-*-180-*",
		"*courier-bold-o-*-240-*",
		"*courier-bold-r-*-80-*",
		"*courier-bold-r-*-100-*",
		"*courier-bold-r-*-120-*",
		"*courier-bold-r-*-140-*",
		"*courier-bold-r-*-180-*",
		"*courier-bold-r-*-240-*"};

void CreateLabel(llabel)

LAbel	*llabel;

	{
	XmString	label_string;
	XmFontList	fontlist = NULL;
	XFontStruct	*lfont = NULL;
	XmStringCharSet	charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET;
	Arg		args[10];
	Cardinal	n;

	/* Return if this widget is disabled by dummy parent (app_shell) */

	if (llabel->parent == app_shell)
		{
		if (debug > 0)
			printf("CreateLabel: dummy parent\n");
		return;
		}

	/* Return if the widget has no parent (error) */

	if (llabel->parent == NULL)
		{
		if (debug > 0)
			printf("CreateLabel: no parent\n");
		return;
		}

	lfont = XLoadQueryFont(XtDisplay(app_shell),fontname[llabel->fontindx]);
	if (!lfont)
		printf("CreateLabel: unable to load font %s\n",
			fontname[llabel->fontindx]);
		else
		fontlist = XmFontListCreate(lfont,charset);

	label_string = XmStringCreateLtoR(llabel->string,charset);

	n = 0;
	XtSetArg(args[n],XmNfontList,fontlist); n++;
	XtSetArg(args[n],XmNleftAttachment,XmATTACH_POSITION); n++;
	XtSetArg(args[n],XmNbottomAttachment, XmATTACH_POSITION); n++;
	XtSetArg(args[n],XmNleftPosition,llabel->xrel); n++;
	XtSetArg(args[n],XmNbottomPosition,llabel->yrel); n++;
	XtSetArg(args[n],XmNlabelString,label_string); n++;
	llabel->widget = XmCreateLabel(llabel->parent,llabel->string,args,n);
	StoreWidgetColors(llabel->widget,llabel->foreground,llabel->background,0);
	XtManageChild(llabel->widget);

	ichan[llabel->input] = llabel->widget;

	if (label_string) XmStringFree(label_string);
	if (fontlist) XmFontListFree(fontlist);
	return;
	}

----------------------------------------------------------------------
Ralf Beyer
German Aerospace Research Establishment (DLR), Institute for Flight
Guidance, Flughafen, D-3300 Braunschweig, Fed. Rep. of Germany
Internet: beyer@bflsgu.fl.bs.dlr.de (EARN/BITNET: fl17@dlrvmbs.bitnet) 
----------------------------------------------------------------------
Technical Details
Message-ID: <34902@adm.brl.mil>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!gatech!rutgers!cmcl2!adm!news

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!gatech!rutgers!cmcl2!adm!news
From: beyer@bflsgu.fl.bs.dlr.de (Ralf Beyer DLR)
Newsgroups: comp.sys.sgi.misc
Subject: Re:  Help needed(2): Xlib
Message-ID: <34902@adm.brl.mil>
Date: 7 Jan 93 11:47:53 GMT
Sender: news@adm.brl.mil
Lines: 108