Re: XLFD from GdkFont?



    Christian> Is there an easy way to obtain the XLFD string from a GdkFont?
    Christian> I know we can get to the XFontStruct from the GdkFont, but do
    Christian> any X experts know how to get the canonical XLFD from the
    Christian> XFontStruct itself?

Try the following.  You may need to include <gdk/gdkx.h>.

    int i;
    Display *d;
    XFontStruct *f;
    XFontProp *xfp;
    char *name;

    for (i = 0, xfp = f->properties; i < f->n_properties; i++, xfp++) {
        if (xfp->name == XA_FONT) {
            /*
             * Set the font name but don't add it to the list in the font.
             */
            name = XGetAtomName(d, (Atom) xfp->card32);
            break;
        }
    }

    /* Use 'name'. */

    free(name); /* You may have to use XFree(name). */
-----------------------------------------------------------------------------
Mark Leisher                           Rights surrendered are not easily
Computing Research Lab                 regained, and a police state is not
New Mexico State University            worth defending.
Box 30001, Dept. 3CRL                     -- Patrick O'Grady
Las Cruces, NM  88003




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]