Determining the Font Being Used - Motif

This is a discussion on Determining the Font Being Used - Motif ; I am specifying a font for my widget using the XLFD with some wildcarding. How can I determine the complete XLFD for the font Motif actually selected? If I have to do this from code using XtVaGetValue() what is the ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Determining the Font Being Used

  1. Determining the Font Being Used


    I am specifying a font for my widget using the XLFD with some wildcarding.
    How can I determine the complete XLFD for the font Motif actually selected?
    If I have to do this from code using XtVaGetValue() what is the data type of
    the variable that will receive the font string?

    Thanks!

    --
    Jake Colman

    Principia Partners LLC Phone: (201) 209-2467
    Harborside Financial Center Fax: (201) 946-0320
    902 Plaza Two E-mail: colman@ppllc.com
    Jersey City, NJ 07311 www.principiapartners.com

  2. Re: Determining the Font Being Used

    In article <76wu7kt4nb.fsf@newjersey.ppllc.com> Jake Colman writes:
    >
    >I am specifying a font for my widget using the XLFD with some wildcarding.
    >How can I determine the complete XLFD for the font Motif actually selected?
    >If I have to do this from code using XtVaGetValue() what is the data type of
    >the variable that will receive the font string?


    Actually, I just had to figure this out the other day.

    The XFontStruct for the font has a member called properties which is a pointer
    to an array of n_properties XFontProp properties. Loop through the array
    looking for the property whose name atom is XA_FONT. The card32 member of
    that XFontProp structure is the atom corresponding to the full font
    description. Use XGetAtomName to get the string.

    So, if you have the fontStruct:

    #include Xatoms.h

    XFontStruct *fs = ;
    int i;
    char *fontString = 0;

    for (i = 0; i < fs->n_properties; i++) {
    if (fs->properties[i].name == XA_FONT) {
    fontString = XGetAtomName(myDisplay,
    (Atom) fs->properties[i].card32);
    }
    }

    Use XFree to free the font string once you are done with it.

    -Pete Zakel
    (phz@seeheader.nospam)

    Westheimer's Rule:
    To estimate the time it takes to do a task: estimate the time you
    think it should take, multiply by 2, and change the unit of measure
    to the next higher unit. Thus we allocate 2 days for a one-hour task.

+ Reply to Thread