[comp.windows.x] VMS DECwindows XQueryFont problem

jansen@larry.sal.wisc.edu (Stephen Jansen) (06/13/90)

I have been having a problem with the XQueryFont function in VMS DECwindows.

#define FontName "6x10"

/******* Load the font for text writing ******/
static void doLoadFont( )
{
    Font font;

    if(!(font = XLoadQueryFont(dpy, FontName)))
      font = XQueryFont(dpy,XGContextFromGC(DefaultGC(dpy,DefaultScreen(dpy)))); 
    else
      XSetFont(dpy, gc, font);
}

This bit of code works fine when it is executed using the local transport,
but when I set host to another VMS machine and execute the code using the
DECnet transport the program *often* (ie. not always, some machines dont 
seem to do this at all) crashes with this (or very simmilar) error message.

X error event received from server:  BadFont - parameter not a Font
  Failed request major op code 47 (X_QueryFont)
  Failed request minor op code 0 (if applicable)
  ResourceID 0x400029 in failed request (if applicable)
  Serial number of failed request 245
  Current serial number in output stream 266


According to every X book I have it is valid to use a GContext ID instead of
an actual font ID.

My question is, Does anyone have any idea what is going on here?, and, if so,
What can I do about it?


-------------------------------------------------------------------------------
| Stephan Jansen           | SPAN:     MADRAF::JANSEN (MADRAF=7309)           |
| Systems Programmer       | BITnet:   SJANSEN@WISCMACC                       |
| Astronomy Department     | INTERnet: JANSEN%MADRAF.DECNET@VMS.MACC.WISC.EDU |
| U. Wisconsin - Madison   | Phone:    (608) 262 - 2198                       |
-------------------------------------------------------------------------------

fisher@skylab.enet.dec.com (06/14/90)

In article <1102@larry.sal.wisc.edu>, jansen@larry.sal.wisc.edu (Stephen
Jansen) writes:

> static void doLoadFont( )
> {
>     Font font;
> 
>     if(!(font = XLoadQueryFont(dpy, FontName)))
>       font =
XQueryFont(dpy,XGContextFromGC(DefaultGC(dpy,DefaultScreen(dpy)))); 
>     else
>       XSetFont(dpy, gc, font);
> }

One problem here is that you are assigning the result of XLoadQueryFont
or XQueryFont
(which should be an *XFontStruct) font, which is a Font.

> This bit of code works fine when it is executed using the local transport,
> but when I set host to another VMS machine and execute the code using the
> DECnet transport the program *often* (ie. not always, some machines dont 
> seem to do this at all) crashes with this (or very simmilar) error message.
> 
> X error event received from server:  BadFont - parameter not a Font
>   Failed request major op code 47 (X_QueryFont)

I'm not sure why this happens, or why it should make any difference if you are
using local or DECnet.  One guess is that the remote machines have "6x10" while
the local machine does not.  Thus on the remote machines, the XSetFont gets
executed causing an error since you are passing XFontStruct rather than Font.
But that does not explain why the error message says it is a QueryFont request.

You said you thougt it was ok to specify a GCID as well as a font.  It is.
You have to be careful, though, to realize that the ID which comes back
in the XFontStruct will be the GC ID and not the Font ID if you specify a GCID
in the original request.  (Probably not relavent to this discussion, but who
knows?)


Burns Fisher
VMS DECwindows and Display PostScript
fisher@decwin.enet.dec.com



Burns Fisher
VMS DECwindows and Display PostScript
fisher@decwin.enet.dec.com