1XTextExtents(3)                 XLIB FUNCTIONS                 XTextExtents(3)
2
3
4

NAME

6       XTextExtents,  XTextExtents16, XQueryTextExtents, XQueryTextExtents16 -
7       compute or query text extents
8

SYNTAX

10       int XTextExtents(XFontStruct *font_struct, _Xconst  char  *string,  int
11              nchars,  int  *direction_return,  int  *font_ascent_return,  int
12              *font_descent_return, XCharStruct *overall_return);
13
14       int XTextExtents16(XFontStruct *font_struct, _Xconst  XChar2b  *string,
15              int  nchars, int *direction_return, int *font_ascent_return, int
16              *font_descent_return, XCharStruct *overall_return);
17
18       int  XQueryTextExtents(Display  *display,  XID  font_ID,  _Xconst  char
19              *string, int nchars, int *direction_return, int *font_ascent_re‐
20              turn, int *font_descent_return, XCharStruct *overall_return);
21
22       int XQueryTextExtents16(Display *display, XID font_ID, _Xconst  XChar2b
23              *string, int nchars, int *direction_return, int *font_ascent_re‐
24              turn, int *font_descent_return, XCharStruct *overall_return);
25

ARGUMENTS

27       direction_return
28                 Returns the value of the direction hint  (FontLeftToRight  or
29                 FontRightToLeft).
30
31       display   Specifies the connection to the X server.
32
33       font_ID   Specifies either the font ID or the GContext ID that contains
34                 the font.
35
36       font_ascent_return
37                 Returns the font ascent.
38
39       font_descent_return
40                 Returns the font descent.
41
42       font_struct
43                 Specifies the XFontStruct structure.
44
45       nchars    Specifies the number of characters in the character string.
46
47       string    Specifies the character string.
48
49       overall_return
50                 Returns the overall size in the specified XCharStruct  struc‐
51                 ture.
52

DESCRIPTION

54       The XTextExtents and XTextExtents16 functions perform the size computa‐
55       tion locally and, thereby, avoid the round-trip overhead of  XQueryTex‐
56       tExtents and XQueryTextExtents16.  Both functions return an XCharStruct
57       structure, whose members are set to the values as follows.
58
59       The ascent member is set to the maximum of the ascent  metrics  of  all
60       characters  in the string.  The descent member is set to the maximum of
61       the descent metrics.  The width member is set to the sum of the charac‐
62       ter-width  metrics of all characters in the string.  For each character
63       in the string, let W be the sum of the character-width metrics  of  all
64       characters  preceding it in the string.  Let L be the left-side-bearing
65       metric of the character plus W.  Let R be the right-side-bearing metric
66       of  the  character plus W.  The lbearing member is set to the minimum L
67       of all characters in the string.  The rbearing member  is  set  to  the
68       maximum R.
69
70       For fonts defined with linear indexing rather than 2-byte matrix index‐
71       ing, each XChar2b structure is interpreted  as  a  16-bit  number  with
72       byte1 as the most significant byte.  If the font has no defined default
73       character, undefined characters in the string are  taken  to  have  all
74       zero metrics.
75
76       The  XQueryTextExtents  and  XQueryTextExtents16  functions  return the
77       bounding box of the specified 8-bit and 16-bit character string in  the
78       specified  font or the font contained in the specified GC.  These func‐
79       tions query the X server and, therefore, suffer the round-trip overhead
80       that is avoided by XTextExtents and XTextExtents16.  Both functions re‐
81       turn a XCharStruct structure, whose members are set to  the  values  as
82       follows.
83
84       The  ascent  member  is set to the maximum of the ascent metrics of all
85       characters in the string.  The descent member is set to the maximum  of
86       the descent metrics.  The width member is set to the sum of the charac‐
87       ter-width metrics of all characters in the string.  For each  character
88       in  the  string, let W be the sum of the character-width metrics of all
89       characters preceding it in the string.  Let L be the  left-side-bearing
90       metric of the character plus W.  Let R be the right-side-bearing metric
91       of the character plus W.  The lbearing member is set to the  minimum  L
92       of  all  characters  in  the string.  The rbearing member is set to the
93       maximum R.
94
95       For fonts defined with linear indexing rather than 2-byte matrix index‐
96       ing,  each  XChar2b  structure  is  interpreted as a 16-bit number with
97       byte1 as the most significant byte.  If the font has no defined default
98       character,  undefined  characters  in  the string are taken to have all
99       zero metrics.
100
101       Characters with all zero metrics are ignored.  If the font has  no  de‐
102       fined default_char, the undefined characters in the string are also ig‐
103       nored.
104
105       XQueryTextExtents and  XQueryTextExtents16  can  generate  BadFont  and
106       BadGC errors.
107

DIAGNOSTICS

109       BadFont   A  value  for a Font or GContext argument does not name a de‐
110                 fined Font.
111
112       BadGC     A value for a GContext argument does not name a defined GCon‐
113                 text.
114

SEE ALSO

116       XLoadFont(3), XTextWidth(3)
117       Xlib - C Language X Interface
118
119
120
121X Version 11                     libX11 1.8.1                  XTextExtents(3)
Impressum