XTextExtents16()XTextExtents16()Name
XTextExtents16 – get string and font metrics of a 16-bit character
string, locally.
Synopsis
XTextExtents16(font_struct, string, nchars, direction_return,
font_ascent_return, font_descent_return, overall_return)
XFontStruct *font_struct;
XChar2b *string;
int nchars;
int *direction_return;
int *font_ascent_return, *font_descent_return;
XCharStruct *overall_return;
Arguments
font_struct
Specifies an XFontStruct structure.
string Specifies the character string made up of XChar2b structures.
nchars Specifies the number of characters in the character string.
direction_return
Returns the value of the direction element of the
XFontStruct. FontRightToLeft of FontLeftToRight.
font_ascent_return
Returns the font ascent element of the XFontStruct. This is
the overall maximum ascent for the font.
font_descent_return
Returns the font descent element of the XFontStruct. This is
the overall maximum descent for the 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 font_descent_return, the mini‐
mum lbearing added to the width of all characters up to the
character with the smallest lbearing, and the maximum rbear‐
ing added to the width of all characters up to the character
with the largest rbearing.
DescriptionXTextExtents16() 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
performs the size computation locally and, thereby, avoids the
roundtrip overhead of XQueryTextExtents16(), but it requires a filled
XFontStruct.
font_ascent_return and font_descent_return return information about the
font, while overall_return returns information about the given string.
The returned font_ascent_return and font_descent_return should usually
be used to calculate the line spacing, while the width, rbearing, and
lbearing members of overall_return should be used for horizontal mea‐
sures. The total height of the bounding rectangle, good for any string
in this font, is font_ascent_return+font_descent_return.
overall_return.ascent is the maximum of the ascent metrics of all char‐
acters 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 over‐
all_return.lbearing is the lbearing of the character in the string with
the smallest lbearing plus the width of all the characters up to but
not including that character. The overall_return.rbearing is the
rbearing of the character in the string with the largest rbearing plus
the width of all the characters up to but not including that character.
For fonts defined with linear indexing rather than 2-byte matrix index‐
ing, each XChar2b structure is interpretd as a 16-bit number with byte1
as the most-significant byte. If the font has no defined default char‐
acter, undefined characters in the string are taken to have all zero
metrics. For more information on drawing text, see Volume One, Chapter
6, Drawing Graphics and Text.
Structures
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;
typedef struct {
XExtData *ext_data; /* hook for extension to hang data */
Font fid; /* font ID for this font */
unsigned direction; /* hint about 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 have non-zero size*/
unsigned default_char; /* char to print for undefined character */
int n_properties; /* how many properties there are */
XFontProp *properties; /* pointer to array of additional properties*/
XCharStruct min_bounds; /* minimum bounds over all existing char*/
XCharStruct max_bounds; /* maximum bounds over all existing char*/
XCharStruct *per_char; /* first_char to last_char information */
int ascent; /* logical extent above baseline for spacing */
int descent; /* logical descent below baseline for spacing */
} XFontStruct;
typedef struct { /* normal 16 bit characters are two bytes */
unsigned char byte1;
unsigned char byte2;
} XChar2b;
See AlsoXDrawImageString(), XDrawImageString16(), XDrawString(), XDraw‐
String16(), XDrawText(), XDrawText16(), XQueryTextExtents(), XQueryTex‐
tExtents16(), XTextExtents(), XTextWidth(), XTextWidth16().
Xlib - Text XTextExtents16()