XDrawText()XDrawText()NameXDrawText – draw 8-bit polytext strings.
Synopsis
XDrawText(display, drawable, gc, x, y, items, nitems)
Display *display;
Drawable drawable;
GC gc;
int x, y;
XTextItem *items;
int nitems;
Arguments
display Specifies a connection to an X server; returned from
XOpenDisplay().
drawable Specifies the drawable.
gc Specifies the graphics context.
x Specify the x and y coordinates of the baseline starting
y position for the initial string, relative to the origin of
the specified drawable.
items Specifies a pointer to an array of text items.
nitems Specifies the number of text items in the items array.
DescriptionXDrawText() is capable of drawing multiple strings on the same horizon‐
tal line and changing fonts between strings. Each XTextItem structure
contains a string, the number of characters in the string, the delta
offset from the starting position for the string, and the font. Each
text item is processed in turn. The font in each XTextItem is stored
in the specified GC and used for subsequent text. If the XTex‐
tItem.font is None, the font in the GC is used for drawing and is not
changed. Switching between fonts with different drawing directions is
permitted.
The delta in each XTextItem specifies the change in horizontal position
before the string is drawn. The delta is always added to the character
origin and is not dependent on the draw direction of the font. For
example, if x = 40, y = 20, and items[0].delta = 8, the string speci‐
fied by items[0].chars would be drawn starting at x = 48, y = 20. The
delta for the second string begins at the rbearing of the last charac‐
ter in the first string. A negative delta would tend to overlay subse‐
quent strings on the end of the previous string.
Only the pixels selected in the font are drawn (the background member
of the GC is not used to fill the bounding box).
In all X releases, there is a limit to the number and size of strings
that can be drawn in a single XDrawText() call, that varies according
to the server. To determine how much text you can draw in a single
call, you find out your server's maximum request size using XMaxRe‐
questSize(). Subtract four, and then subtract ((strlen(string)+2)/4)
for each string. This is the maximum amount of text you can draw in a
single XDrawText() call.
XDrawText() uses the following elements in the specified GC: function,
plane_mask, fill_style, font, subwindow_mode, clip_x_origin,
clip_y_origin, and clip_mask. This function also uses these graphics
context mode-dependent components: foreground, background, tile, stip‐
ple, ts_x_origin, and ts_y_origin.
For more information, see Volume One, Chapter 6, Drawing Graphics and
Text, and Chapter 5, The Graphics Context.
Structures
typedef struct {
char *chars; /* pointer to string */
int nchars; /* number of characters */
int delta; /* delta between strings */
Font font; /* font to print it in, None don't change */
} XTextItem;
Errors
BadDrawable
BadFont
BadGC
BadMatch
See AlsoXDrawImageString(), XDrawImageString16(), XDrawString(), XDraw‐
String16(), XDrawText16(), XQueryTextExtents(), XQueryTextExtents16(),
XTextExtents(), XTextExtents16(), XTextWidth(), XTextWidth16().
Xlib - Text XDrawText()