Getting an XLFD for the current font from XmText (OM 2.2.3)

I am currently using a XmFontSelector to allow the user to change fonts in an XmText on the fly. However, I also want the XmFS to display the currentFont the user may be using. I know this can be done with render tables (I tried it), but I want to do it with fontLists (for better compatibility as renderTable support seemed flaky to me---it is also mentioned in the OM TODO).

So, how do I get an XLFD from a fontList? I did this:

1) Extract the fontList from XmText.
2) Get the default entry from the list (*not* using fontsets)
3) Get the XFontStruct from the entry.

I successfully reached here, but I can't figure out how to get the XLFD from this. The man pages are no help. The XGetFontProperty with XA_FONT_NAME returns an unsigned long as the value.

Am I doing something wrong? Is there a better way to do this?
Of course, it would be *very* convenient if the XmFontSelector itself took something higher level as currentFont than an XLFD.


Andriy Konoval

Andriy Konoval's picture

Getting an XLFD for the current font from XmText (OM 2.2.3)

Probably part of this code could help you.

XfontStruct font; //font what you've got previously.
unsigned long nameAtom;
char *fontName;
XGetFontProperty( font, XA_FONT, &nameAtom );
fontName = XGetAtomName( XtDisplay(root), nameAtom );