XQueryTextExtents16() XQueryTextExtents16()
Name
XQueryTextExtents16 - query the server for string and font metrics of a 16-bit character string.
Synopsis
XQueryTextExtents16(display, font_ID, string, nchars, direction_return, font_ascent_return, descent, overall_returnf(CW)
Display *display;
XID font_ID;
XChar2b *string;
int nchars;
int *direction_return;
int *font_ascent_return, *font_descent_return;
XCharStruct *overall_returnf(CW;
Arguments
display Specifies a connection to an X server; returned from XOpenDisplay().
font_ID Specifies the appropriate font ID previously returned by XLoadFont(), or the GContext that specifies the font.
string Specifies the character string for which metrics are to be returned.
nchars Specifies the number of characters in string.
direction_return
Returns the direction of painting in the specified font. Either FontLefttoRight or FontRighttoLeft.
font_ascent_return
Returns the maximum ascent in pixels for the specified font.
descent Returns the maximum descent in pixels for the specified font.
overall_return
Returns the overall characteristics of the string. These are the sum of the width measurements for each character, the maximum
font_ascent_return and descent, the minimum lbearing added to the width of all characters up to the character with the smallest
lbearing, and the maximum rbearing added to the width of all characters up to the character with the largest rbearing.
Description
XQueryTextExtents16() returns the dimensions in pixels that specify the bounding box of the specified string of characters in the named
font, and the maximum ascent and descent for the entire font. This function queries the server and, therefore, suffers the round trip
overhead that is avoided by XTextExtents16(), but XQueryTextExtents() does not require a filled XFontInfo structure.
The returned font_ascent_return and font_descent_return should be used to calculate the line spacing, while the width, rbearing and lbear-
ing members of overall_return should be used for horizontal measures. The total height of the bounding rectangle for any string in this
font is font_ascent_return + font_descent_return
overall_return.font_ascent_return is the maximum of the ascent metrics of all characters in the string. The overall_return.descent is the
maximum of the descent metrics. The overall_return.width is the sum of the character-width metrics of all characters in the string. The
overall_return.lbearing is usually the lbearing of the first character in the string, and overall_return.rbearing is the rbearing of the
last character in the string plus the sum of the widths of all the characters up to but not including the last character. More techni-
cally, here is the X protocol definition: For each character in the string, let W be the sum of the character-width metrics of all charac-
ters preceding it in the string, let L be the lbearing metric of the character plus W, and let R be the rbearing metric of the character
plus W. The overall_return.lbearing is the minimum L of all characters in the string, and the overall_return.rbearing is the maximum R.
For fonts defined with linear indexing rather than two-byte matrix indexing, the server interprets each XChar2b as a 16-bit number that has
been transmitted with the most significant byte first. That is, byte one of the XChar2b is taken as the most significant byte.
If the font has no defined default character, then undefined characters in the string are taken to have all zero metrics.
Structures
typedef struct { /* normal 16-bit characters are two bytes */
unsigned char byte1;
unsigned char byte2;
} XChar2b;
typedef struct {
short lbearing; /* origin to left edge of character */
short rbearing; /* origin to right edge of character */
short width; /* advance to next char's origin */
short ascent; /* baseline to top edge of character */
short descent; /* baseline to bottom edge of character */
unsigned short attributes; /* per char flags (not predefined) */
} XCharStruct;
Errors
BadFont
BadGC
See Also
XDrawImageString(), XDrawImageString16(), XDrawString(), XDrawString16(), XDrawText(), XDrawText16(), XQueryTextExtents(), XTextExtents(),
XTextExtents16(), XTextWidth(), XTextWidth16().
Xlib - Text XQueryTextExtents16()