[comp.windows.x] One down, one to go

snl@edrc.cmu.edu (Sean Levy) (06/16/89)

Thanks to Donna Converse for sending me an example which jarred me into
seeing my mistake re: XtAugmentTranslations(). As she noted, this works
just fine (once you declare your stupid arguments correctly...).

I'm having another problem, however. I'm writing a resource converter
from XtRFontStruct => XtRString (e.g. from the FontStruct to the name
of the font). XListFontsWithInfo is documented to stuff a pointer to
an array of XFontStruct's into what its last argument points at; I
call it thusly:

  Display *d;
  char **names;
  int n_fonts;
  XFontStruct *font_info;

  names = XListFontsWithInfo(d, "*", MAX_FONT_NAMES, &n_fonts, &font_info);

As expected, if MAX_FONT_NAMES is big enough, I get back the list of
all font the server knows about in names with corresponding
XFontStruct's in font_info. However, all of the fid members of the
XFontStruct's pointed at by font_info are zero.  It looks to me like
the only thing I have to compare the XFontStruct I'm handed in my
converter with some other XFontStruct is the font ID. Am I wrong? Is
there another way to go about converting from FontStruct => String
that I'm overlooking?

If I _am_ going about this in the correct way, then according to the
Xlib manual (under XListFontsWithInfo, 6.5.1)

  "The information returned for each font is identical to what
   XLoadQueryFont would return, except that the per-character
   metrics are not returned."

However, if I call XListFonts to get the names and then call XLoadFont
on each name I get back, the id I get back never matches the id I have
in (*(XFontStruct **)(fromVal->addr))->fid (MAX_FONT_NAMES is very big
here -- I'm getting the names of all the fonts the server knows of).
Is XLoadFont re-loading the font and assigning a new ID to the
re-loaded font? It seems so, since the XFontStruct I've been handed in
fromVal has an fid that is just a little lower than all of the id's I
get from XLoadFont (the manual doesn't explicitly say what XLoadFont
does if the font is already loaded).

Suggestions welcome (yes, I'm planning on posting the code, which is
otherwise functional; it seems to me that it'd be a pretty dinky
resource editor that didn't let you change fonts, though...).

TIA,
--
sean levy - research programmer / engineering design research center / cmu
  internet: snl@edrc.cmu.edu           bitnet: snl@edrc.cmu.edu%CMCCVMA
      uucp: ...!harvard!cs.cmu.edu!snl  2wire: 412 268 2257
      dirt: edrc / cmu / doherty hall a219 / pittsburgh pa 15213
-- 
sean levy - research programmer / engineering design research center / cmu
  internet: snl@edrc.cmu.edu           bitnet: snl@edrc.cmu.edu%CMCCVMA
      uucp: ...!harvard!cs.cmu.edu!snl  2wire: 412 268 2257
      dirt: edrc / cmu / doherty hall a219 / pittsburgh pa 15213
--