NAME

XTextExtents, XTextExtents16, XQueryTextExtents, XQueryTextExtents16 - compute or query text extents

SYNTAX

int XTextExtents(XFontStruct *_f_o_n_t___s_t_r_u_c_t, char *_s_t_r_i_n_g, int _n_c_h_a_r_s, int *_d_i_r_e_c_t_i_o_n___r_e_t_u_r_n, int *_f_o_n_t___a_s_c_e_n_t___r_e_t_u_r_n, int *_f_o_n_t___d_e_s_c_e_n_t___r_e_t_u_r_n, XCharStruct *_o_v_e_r_a_l_l___r_e_t_u_r_n); int XTextExtents16(XFontStruct *_f_o_n_t___s_t_r_u_c_t, XChar2b *_s_t_r_i_n_g, int _n_c_h_a_r_s, int *_d_i_r_e_c_t_i_o_n___r_e_t_u_r_n, int *_f_o_n_t___a_s_c_e_n_t___r_e_t_u_r_n, int *_f_o_n_t___d_e_s_c_e_n_t___r_e_t_u_r_n, XCharStruct *_o_v_e_r_a_l_l___r_e_t_u_r_n); int XQueryTextExtents(Display *_d_i_s_p_l_a_y, XID _f_o_n_t___I_D, char *_s_t_r_i_n_g, int _n_c_h_a_r_s, int *_d_i_r_e_c_t_i_o_n___r_e_t_u_r_n, int *_f_o_n_t___a_s_c_e_n_t___r_e_t_u_r_n, int *_f_o_n_t___d_e_s_c_e_n_t___r_e_t_u_r_n, XCharStruct *_o_v_e_r_a_l_l___r_e_t_u_r_n); int XQueryTextExtents16(Display *_d_i_s_p_l_a_y, XID _f_o_n_t___I_D, XChar2b *_s_t_r_i_n_g, int _n_c_h_a_r_s, int *_d_i_r_e_c_t_i_o_n___r_e_t_u_r_n, int *_f_o_n_t___a_s_c_e_n_t___r_e_t_u_r_n, int *_f_o_n_t___d_e_s_c_e_n_t___r_e_t_u_r_n, XCharStruct *_o_v_e_r_a_l_l___r_e_t_u_r_n);

ARGUMENTS

_d_i_r_e_c_t_i_o_n___r_e_t_u_r_n Returns the value of the direction hint
(_F_o_n_t_L_e_f_t_T_o_R_i_g_h_t or _F_o_n_t_R_i_g_h_t_T_o_L_e_f_t).
_d_i_s_p_l_a_y Specifies the connection to the X server.
_f_o_n_t___I_D Specifies either the font ID or the
_G_C_o_n_t_e_x_t ID that contains the font.
_f_o_n_t___a_s_c_e_n_t___r_e_t_u_r_n Returns the font ascent.
_f_o_n_t___d_e_s_c_e_n_t___r_e_t_u_r_n Returns the font descent.
_f_o_n_t___s_t_r_u_c_t Specifies the
_X_F_o_n_t_S_t_r_u_c_t structure.
_n_c_h_a_r_s Specifies the number of characters in the character string.
_s_t_r_i_n_g Specifies the character string.
_o_v_e_r_a_l_l___r_e_t_u_r_n Returns the overall size in the specified
_X_C_h_a_r_S_t_r_u_c_t structure.

DESCRIPTION

The _X_T_e_x_t_E_x_t_e_n_t_s and _X_T_e_x_t_E_x_t_e_n_t_s_1_6 functions perform the size computation locally and, thereby, avoid the round-trip overhead of _X_Q_u_e_r_y_T_e_x_t_E_x_t_e_n_t_s and _X_Q_u_e_r_y_T_e_x_t_E_x_t_e_n_t_s_1_6. Both functions return an _X_C_h_a_r_S_t_r_u_c_t structure, whose members are set to the values as follows.

The ascent member is set to the maximum of the ascent metrics of all characters in the string. The descent member is set to the maximum of the descent metrics. The width member is set to the sum of the character-width metrics of all characters in the string. For each character in the string, let W be the sum of the character-width metrics of all characters preceding it in the string. Let L be the left-side-bearing metric of the character plus W. Let R be the right-side-bearing metric of the character plus W. The lbearing member is set to the minimum L of all characters in the string. The rbearing member is set to the maximum R.

For fonts defined with linear indexing rather than 2-byte matrix indexing, each _X_C_h_a_r_2_b structure is interpreted as a 16-bit number with byte1 as the most significant byte. If the font has no defined default character, undefined characters in the string are taken to have all zero metrics.

The _X_Q_u_e_r_y_T_e_x_t_E_x_t_e_n_t_s and _X_Q_u_e_r_y_T_e_x_t_E_x_t_e_n_t_s_1_6 functions return the bounding box of the specified 8-bit and 16-bit character string in the specified font or the font contained in the specified GC. These functions query the X server and, therefore, suffer the round-trip overhead that is avoided by _X_T_e_x_t_E_x_t_e_n_t_s and _X_T_e_x_t_E_x_t_e_n_t_s_1_6. Both functions return a _X_C_h_a_r_S_t_r_u_c_t structure, whose members are set to the values as follows.

The ascent member is set to the maximum of the ascent metrics of all characters in the string. The descent member is set to the maximum of the descent metrics. The width member is set to the sum of the character-width metrics of all characters in the string. For each character in the string, let W be the sum of the character-width metrics of all characters preceding it in the string. Let L be the left-side-bearing metric of the character plus W. Let R be the right-side-bearing metric of the character plus W. The lbearing member is set to the minimum L of all characters in the string. The rbearing member is set to the maximum R.

For fonts defined with linear indexing rather than 2-byte matrix indexing, each _X_C_h_a_r_2_b structure is interpreted as a 16-bit number with byte1 as the most significant byte. If the font has no defined default character, undefined characters in the string are taken to have all zero metrics.

Characters with all zero metrics are ignored. If the font has no defined default_char, the undefined characters in the string are also ignored.

_X_Q_u_e_r_y_T_e_x_t_E_x_t_e_n_t_s and _X_Q_u_e_r_y_T_e_x_t_E_x_t_e_n_t_s_1_6 can generate _B_a_d_F_o_n_t and _B_a_d_G_C errors.

DIAGNOSTICS

_B_a_d_F_o_n_t
A value for a Font or GContext argument does not name a defined Font.
_B_a_d_G_C
A value for a GContext argument does not name a defined GContext.

SEE ALSO

XLoadFont(3X11), XTextWidth(3X11)
_X_l_i_b _- _C _L_a_n_g_u_a_g_e _X _I_n_t_e_r_f_a_c_e