The following example illustrates how
Xft's
version constants might be used:
#if (XFT_VERSION >= 20107) (void) puts("Version 2.1.7 or later of the Xft library is in" " use."); #else (void) printf("Insufficient version of Xft (%d.%d.%d) installed; " need at least version 2.1.7.\n", XFT_MAJOR, XFT_MINOR, XFT_REVISION); #endif
typedef struct _XftFont { int ascent; int descent; int height; int max_advance_width; FcCharSet *charset; FcPattern *pattern; } XftFont;An XftFont is the primary data structure of interest to programmers using Xft; it contains general font metrics and pointers to the Fontconfig character set and pattern associated with the font. The FcCharSet and FcPattern data types are defined by the Fontconfig library.
typedef struct _XftColor { unsigned long pixel; XRenderColor color; } XftColor;An XftColor object permits text and other items to be rendered in a particular color (or the closest approximation offered by the X visual in use). The XRenderColor data type is defined by the X Render Extension library.
typedef struct _XftCharSpec { FcChar32 ucs4; short x; short y; } XftCharSpec;
typedef struct _XftCharFontSpec { XftFont *font; FcChar32 ucs4; short x; short y; } XftCharFontSpec;
typedef struct _XftGlyphSpec { FT_UInt glyph; short x; short y; } XftGlyphSpec;
typedef struct _XftGlyphFontSpec { XftFont *font; FT_UInt glyph; short x; short y; } XftGlyphFontSpec;
XXffttFFoonntt ** XXffttFFoonnttOOppeenn ((DDiissppllaayy **_d_p_y,, iinntt _s_c_r_e_e_n,, ......));;XftFontOpen takes a list of pattern element triples of the form field, type,value (terminated with a NULL), matches that pattern against the available fonts, and opens the matching font, sizing it correctly for screen number screen on display dpy. The Display data type is defined by the X11 library. Returns NULL if no match is found.
Example:
font = XftFontOpen (dpy, screen, XFT_FAMILY, XftTypeString, "charter", XFT_SIZE, XftTypeDouble, 12.0, NULL);This opens the "charter" font at 12 points. The point size is automatically converted to the correct pixel size based on the resolution of the monitor.
XXffttFFoonntt ** XXffttFFoonnttOOppeennNNaammee ((DDiissppllaayy **_d_p_y,, iinntt _s_c_r_e_e_n,, uunnssiiggnneedd cchhaarr **_n_a_m_e));;XftFontOpenName behaves as XftFontOpen does, except that it takes a Fontconfig pattern string (which is passed to the Fontconfig library's FcNameParse() function).
XXffttFFoonntt ** XXffttFFoonnttOOppeennXXllffdd ((DDiissppllaayy **_d_p_y,, iinntt _s_c_r_e_e_n,, uunnssiiggnneedd cchhaarr **_x_l_f_d))XftFontOpenXlfd behaves as XftFontOpen does, except that it takes a string containing an X Logical Font Description (XLFD).
FFccPPaatttteerrnn ** XXffttFFoonnttMMaattcchh ((DDiissppllaayy **_d_p_y,, iinntt _s_c_r_e_e_n,, FFccPPaatttteerrnn **_p_a_t_t_e_r_n,, FFccRReessuulltt **_r_e_s_u_l_t));;Also used internally by the XftFontOpen* functions, XftFontMatch can also be used directly to determine the Fontconfig font pattern resulting from an Xft font open request. The FcPattern and FcResult data types are defined by the Fontconfig library.
vvooiidd XXffttTTeexxttEExxtteennttss88 ((DDiissppllaayy **_d_p_y,, XXffttFFoonntt **_f_o_n_t,, FFccCChhaarr88 **_s_t_r_i_n_g,, iinntt _l_e_n,, XXGGllyypphhIInnffoo **_e_x_t_e_n_t_s));;XftTextExtents8 computes the pixel extents on display dpy of no more than len glyphs of a string consisting of eight-bit characters when drawn with font, storing them in extents. The FcChar8 data type is defined by the Fontconfig library, and the XGlyphInfo data type is defined by the X Rendering Extension library.
vvooiidd XXffttTTeexxttEExxtteennttss1166 ((DDiissppllaayy **_d_p_y,, XXffttFFoonntt **_f_o_n_t,, FFccCChhaarr1166 **_s_t_r_i_n_g,, iinntt _l_e_n,, XXGGllyypphhIInnffoo **_e_x_t_e_n_t_s));;XftTextExtents16 computes the pixel extents on display dpy of no more than len glyphs of a string consisting of sixteen-bit characters when drawn with font, storing them in extents. The FcChar16 data type is defined by the Fontconfig library, and the XGlyphInfo data type is defined by the X Rendering Extension library.
vvooiidd XXffttTTeexxttEExxtteennttss3322 ((DDiissppllaayy **_d_p_y,, XXffttFFoonntt **_f_o_n_t,, FFccCChhaarr3322 **_s_t_r_i_n_g,, iinntt _l_e_n,, XXGGllyypphhIInnffoo **_e_x_t_e_n_t_s));;XftTextExtents32 computes the pixel extents on display dpy of no more than len glyphs of a string consisting of thirty-two-bit characters when drawn with font, storing them in extents. The FcChar32 data type is defined by the Fontconfig library, and the XGlyphInfo data type is defined by the X Rendering Extension library.
vvooiidd XXffttTTeexxttEExxtteennttssUUttff88 ((DDiissppllaayy **_d_p_y,, XXffttFFoonntt **_f_o_n_t,, FFccCChhaarr88 **_s_t_r_i_n_g,, iinntt _l_e_n,, XXGGllyypphhIInnffoo **_e_x_t_e_n_t_s));;XftTextExtentsUtf8 computes the pixel extents on display dpy of no more than len bytes of a UTF-8 encoded string when drawn with font, storing them in extents. The XGlyphInfo data type is defined by the X Rendering Extension library.
vvooiidd XXffttTTeexxttEExxtteennttssUUttff1166 ((DDiissppllaayy **_d_p_y,, XXffttFFoonntt **_f_o_n_t,, FFccCChhaarr88 **_s_t_r_i_n_g,, FFccEEnnddiiaann _e_n_d_i_a_n,, iinntt _l_e_n,, XXGGllyypphhIInnffoo **_e_x_t_e_n_t_s));;XftTextExtentsUtf16 computes the pixel extents on display dpy of no more than len bytes of a UTF-16LE- or UTF-16BE-encoded string when drawn with font, storing them in extents. The endianness of string must be specified in endian. The FcEndian data type is defined by the Fontconfig library, and the XGlyphInfo data type is defined by the X Rendering Extension library.
vvooiidd XXffttGGllyypphhEExxtteennttss ((DDiissppllaayy **_d_p_y,, XXffttFFoonntt **_f_o_n_t,, FFTT__UUIInntt **_g_l_y_p_h_s,, iinntt _n_g_l_y_p_h_s,, XXGGllyypphhIInnffoo **_e_x_t_e_n_t_s));;Also used internally by the XftTextExtents* functions, XftGlyphExtents computes the pixel extents on display dpy of no more than nglyphs in the array glyphs drawn with font, storing them in extents. The FT_UInt data type is defined by the FreeType library, and the XGlyphInfo data type is defined by the X Rendering Extension library.
XXffttDDrraaww ** XXffttDDrraawwCCrreeaattee ((DDiissppllaayy **_d_p_y,, DDrraawwaabbllee _d_r_a_w_a_b_l_e,, VViissuuaall **_v_i_s_u_a_l,, CCoolloorrmmaapp _c_o_l_o_r_m_a_p));;XftDrawCreate creates a structure that can be used to render text and rectangles using the specified drawable, visual, and colormap on display. The Drawable, Visual, and Colormap data types are defined by the X11 library.
XXffttDDrraaww ** XXffttDDrraawwCCrreeaatteeBBiittmmaapp ((DDiissppllaayy **_d_p_y,, PPiixxmmaapp _b_i_t_m_a_p));;XftDrawCreateBitmap behaves as XftDrawCreate, except it uses an X pixmap of color depth 1 instead of an X drawable. The Pixmap data type is defined by the X11 library.
XXffttDDrraaww ** XXffttDDrraawwCCrreeaatteeAAllpphhaa ((DDiissppllaayy **_d_p_y,, PPiixxmmaapp _p_i_x_m_a_p,, iinntt _d_e_p_t_h));;XftDrawCreateAlpha behaves as XftDrawCreate, except it uses an X pixmap of color depth depth instead of an X drawable. The Pixmap data type is defined by the X11 library.
vvooiidd XXffttDDrraawwCChhaannggee ((XXffttDDrraaww **_d_r_a_w,, DDrraawwaabbllee _d_r_a_w_a_b_l_e));;XftDrawChange changes the X drawable association of the existing Xft draw object draw from its current value to drawable.
DDiissppllaayy ** XXffttDDrraawwDDiissppllaayy ((XXffttDDrraaww **_d_r_a_w));;XftDrawDisplay returns a pointer to the display associated with the Xft draw object draw.
DDrraawwaabbllee XXffttDDrraawwDDrraawwaabbllee ((XXffttDDrraaww **_d_r_a_w));;XftDrawDrawable returns the X drawable associated with the Xft draw object draw.
CCoolloorrmmaapp XXffttDDrraawwCCoolloorrmmaapp ((XXffttDDrraaww **_d_r_a_w));;XftDrawColormap returns the colormap associatied with the Xft draw object draw.
VViissuuaall ** XXffttDDrraawwVViissuuaall ((XXffttDDrraaww **_d_r_a_w));;XftDrawVisual returns a pointer to the visual associated with the Xft draw object draw.
PPiiccttuurree XXffttDDrraawwPPiiccttuurree ((XXffttDDrraaww **_d_r_a_w));;XftDrawPicture returns the picture associated with the Xft draw object draw. If the the X server does not support the X Rendering Extension, 0 is returned.
PPiiccttuurree XXffttDDrraawwSSrrccPPiiccttuurree ((XXffttDDrraaww **_d_r_a_w,, XXffttCCoolloorr **_c_o_l_o_r));;This function is never called if the X server doesn't support the X Rendering Extension; instead, XftGlyphCore is used.
vvooiidd XXffttDDrraawwDDeessttrrooyy ((XXffttDDrraaww **_d_r_a_w));;XftDrawDestroy destroys draw (created by one of the XftCreate functions) and frees the memory that was allocated for it.
vvooiidd XXffttDDrraawwSSttrriinngg88 ((XXffttDDrraaww **_d,, XXRReennddeerrCCoolloorr **_c_o_l_o_r,, XXffttFFoonntt **_f_o_n_t,, iinntt _x,, iinntt _y,, uunnssiiggnneedd cchhaarr **_s_t_r_i_n_g,, iinntt _l_e_n));;XftDrawString8 draws no more than len glyphs of string to Xft drawable d using font in color at position x, y. The XRenderColor data type is defined by the X Rendering Extension library.
vvooiidd XXffttDDrraawwRReecctt ((XXffttDDrraaww **_d,, XXRReennddeerrCCoolloorr **_c_o_l_o_r,, iinntt _x,, iinntt _y,, uunnssiiggnneedd iinntt _w_i_d_t_h,, uunnssiiggnneedd iinntt _h_e_i_g_h_t));;XftDrawRect draws a solid rectangle of the specified color, width, and height at position x,y to Xft drawable d.
Xft does provide a compatibility interface to its previous major version, Xft described below.