1XDrawText(3) XLIB FUNCTIONS XDrawText(3)
2
3
4
6 XDrawText, XDrawText16, XTextItem, XTextItem16 - draw polytext text and
7 text drawing structures
8
10 int XDrawText(Display *display, Drawable d, GC gc, int x, int y, XTex‐
11 tItem *items, int nitems);
12
13 int XDrawText16(Display *display, Drawable d, GC gc, int x, int y,
14 XTextItem16 *items, int nitems);
15
17 d Specifies the drawable.
18
19 display Specifies the connection to the X server.
20
21 gc Specifies the GC.
22
23 items Specifies an array of text items.
24
25 nitems Specifies the number of text items in the array.
26
27 x
28 y Specify the x and y coordinates, which are relative to the
29 origin of the specified drawable and define the origin of the
30 first character.
31
33 The XDrawText16 function is similar to XDrawText except that it uses
34 2-byte or 16-bit characters. Both functions allow complex spacing and
35 font shifts between counted strings.
36
37 Each text item is processed in turn. A font member other than None in
38 an item causes the font to be stored in the GC and used for subsequent
39 text. A text element delta specifies an additional change in the posi‐
40 tion along the x axis before the string is drawn. The delta is always
41 added to the character origin and is not dependent on any characteris‐
42 tics of the font. Each character image, as defined by the font in the
43 GC, is treated as an additional mask for a fill operation on the draw‐
44 able. The drawable is modified only where the font character has a bit
45 set to 1. If a text item generates a BadFont error, the previous text
46 items may have been drawn.
47
48 For fonts defined with linear indexing rather than 2-byte matrix index‐
49 ing, each XChar2b structure is interpreted as a 16-bit number with
50 byte1 as the most significant byte.
51
52 Both functions use these GC components: function, plane-mask, fill-
53 style, font, subwindow-mode, clip-x-origin, clip-y-origin, and clip-
54 mask. They also use these GC mode-dependent components: foreground,
55 background, tile, stipple, tile-stipple-x-origin, and tile-stipple-y-
56 origin.
57
58 XDrawText and XDrawText16 can generate BadDrawable, BadFont, BadGC, and
59 BadMatch errors.
60
62 The XTextItem and XTextItem16 structures contain:
63
64 typedef struct {
65 char *chars; /* pointer to string */
66 int nchars; /* number of characters */
67 int delta; /* delta between strings */
68 Font font; /* Font to print it in, None don't change */
69 } XTextItem;
70
71 typedef struct {
72 XChar2b *chars; /* pointer to two-byte characters */
73 int nchars; /* number of characters */
74 int delta; /* delta between strings */
75 Font font; /* font to print it in, None don't change */
76 } XTextItem16;
77
78 If the font member is not None, the font is changed before printing and
79 also is stored in the GC. If an error was generated during text draw‐
80 ing, the previous items may have been drawn. The baseline of the char‐
81 acters are drawn starting at the x and y coordinates that you pass in
82 the text drawing functions.
83
84 For example, consider the background rectangle drawn by XDrawIm‐
85 ageString. If you want the upper-left corner of the background rectan‐
86 gle to be at pixel coordinate (x,y), pass the (x,y + ascent) as the
87 baseline origin coordinates to the text functions. The ascent is the
88 font ascent, as given in the XFontStruct structure. If you want the
89 lower-left corner of the background rectangle to be at pixel coordinate
90 (x,y), pass the (x,y - descent + 1) as the baseline origin coordinates
91 to the text functions. The descent is the font descent, as given in
92 the XFontStruct structure.
93
95 BadDrawable
96 A value for a Drawable argument does not name a defined Win‐
97 dow or Pixmap.
98
99 BadFont A value for a Font or GContext argument does not name a de‐
100 fined Font.
101
102 BadGC A value for a GContext argument does not name a defined GCon‐
103 text.
104
105 BadMatch An InputOnly window is used as a Drawable.
106
108 XDrawImageString(3), XDrawString(3), XLoadFont(3)
109 Xlib - C Language X Interface
110
111
112
113X Version 11 libX11 1.7.3.1 XDrawText(3)