next up previous contents
Next: Finding the Width of Up: Rectangleslines, dots, arcs Previous: Rectangleslines, dots, arcs

Drawing Text in a Window

The simplest way to use a font is to call XLoadQueryfont which loads the font and returns a pointer to a XFontStruct structure which it fills. The fid field is what you use when setting the current font.

typedef struct {                                                    
    XExtData    *ext_data;      /* hook for extension to hang data */
    Font        fid;            /* Font id for this font */         
    unsigned    direction;      /* direction the font is painted */ 
    unsigned    min_char_or_byte2;/* first character */             
    unsigned    max_char_or_byte2;/* last character */              
    unsigned    min_byte1;      /* first row that exists */         
    unsigned    max_byte1;      /* last row that exists */          
    Bool        all_chars_exist;/* flag if all characters exist*/   
    unsigned    default_char;   /* char to print for undefined character */
    int         n_properties;   /* how many properties there are */    
    XFontProp   *properties;    /* pointer to additional properties*/  
    XCharStruct min_bounds;     /* minimum bounds over all existing char*/
    XCharStruct max_bounds;     /* minimum bounds over all existing char*/
    XCharStruct *per_char;      /* first_char to last_char information */
    int         ascent;         /* log. extent baseline for spacing */ 
    int         descent;        /* log. descent baseline for spacing */
} XFontStruct;

XFontStruct *XLoadQueryFont(display,name)  /* prepare a font for action       */
    char *name;          /* name of the font */

XFreeFont(display,font_struct)    /* tells the server that this font is no */
    XFontStruct *font_struct;     /* longer needed, and frees resources.   */

  figure284
Figure 2: Font dimensions



Tim Love
Mon Mar 11 17:03:18 GMT 1996