uint defont_get_text_width(DEFont *font, const char *text, uint len) { if(font->fontset!=NULL){ XRectangle lext; #ifdef CF_DE_USE_XUTF8 if(ioncore_g.enc_utf8) Xutf8TextExtents(font->fontset, text, len, NULL, &lext); else #endif XmbTextExtents(font->fontset, text, len, NULL, &lext); return lext.width; }else if(font->fontstruct!=NULL){ if(ioncore_g.enc_utf8){ XChar2b *str16; int len16=0; uint res; toucs(text, len, &str16, &len16); res=XTextWidth16(font->fontstruct, str16, len16); free(str16); return res; }else{ return XTextWidth(font->fontstruct, text, len); } }else{ return 0; } }
extern int titleWidth(XFontSet font_set, Client *c) { XRectangle ink; XRectangle logical; char *name; int namelen; if (c == NULL) return 0; if (c->menu_name == NULL) { name = c->name; namelen = c->namelen; } else { name = c->menu_name; namelen = c->menu_namelen; } if (name == NULL) return 0; #ifdef X_HAVE_UTF8_STRING if (c->name_utf8 == True) Xutf8TextExtents(font_set, name, namelen, &ink, &logical); else #endif XmbTextExtents(font_set, name, namelen, &ink, &logical); return logical.width; }
uint defont_get_text_width(DEFont *font, const char *text, uint len) { if(font->fontset!=NULL){ XRectangle lext; #ifdef CF_DE_USE_XUTF8 if(ioncore_g.enc_utf8) Xutf8TextExtents(font->fontset, text, len, NULL, &lext); else #endif XmbTextExtents(font->fontset, text, len, NULL, &lext); return lext.width; }else if(font->fontstruct!=NULL){ return XTextWidth(font->fontstruct, text, len); }else{ return 0; } }
uint defont_get_text_width(DEFont *font, const char *text, uint len) { #ifdef HAVE_X11_XFT if(font->font!=NULL){ XGlyphInfo extents; if(ioncore_g.enc_utf8) XftTextExtentsUtf8(ioncore_g.dpy, font->font, (XftChar8*)text, len, &extents); else XftTextExtents8(ioncore_g.dpy, font->font, (XftChar8*)text, len, &extents); return extents.xOff; } #endif /* HAVE_X11_XFT */ #ifdef HAVE_X11_BMF if(font->fontset!=NULL){ XRectangle lext; #ifdef CF_DE_USE_XUTF8 if(ioncore_g.enc_utf8) Xutf8TextExtents(font->fontset, text, len, NULL, &lext); else #endif XmbTextExtents(font->fontset, text, len, NULL, &lext); return lext.width; }else if(font->fontstruct!=NULL){ if(ioncore_g.enc_utf8){ XChar2b *str16; int len16=0; uint res; toucs(text, len, &str16, &len16); res=XTextWidth16(font->fontstruct, str16, len16); free(str16); return res; }else{ return XTextWidth(font->fontstruct, text, len); } } #endif /* HAVE_X11_BMF */ else{ return 0; } }