void debrush_do_draw_string_default_bmf( DEBrush *brush, int x, int y, const char *str, int len, bool needfill, DEColourGroup *colours) { GC gc=brush->d->normal_gc; if(brush->d->font==NULL) return; XSetForeground(ioncore_g.dpy, gc, PIXEL(colours->fg)); if(!needfill){ if(brush->d->font->fontset!=NULL){ #ifdef CF_DE_USE_XUTF8 if(ioncore_g.enc_utf8) Xutf8DrawString(ioncore_g.dpy, brush->win, brush->d->font->fontset, gc, x, y, str, len); else #endif XmbDrawString(ioncore_g.dpy, brush->win, brush->d->font->fontset, gc, x, y, str, len); }else if(brush->d->font->fontstruct!=NULL){ if(ioncore_g.enc_utf8){ XChar2b *str16; int len16=0; toucs(str, len, &str16, &len16); XDrawString16(ioncore_g.dpy, brush->win, gc, x, y, str16, len16); free(str16); }else{ XDrawString(ioncore_g.dpy, brush->win, gc, x, y, str, len); } } }else{ XSetBackground(ioncore_g.dpy, gc, PIXEL(colours->bg)); if(brush->d->font->fontset!=NULL){ #ifdef CF_DE_USE_XUTF8 if(ioncore_g.enc_utf8) Xutf8DrawImageString(ioncore_g.dpy, brush->win, brush->d->font->fontset, gc, x, y, str, len); else #endif XmbDrawImageString(ioncore_g.dpy, brush->win, brush->d->font->fontset, gc, x, y, str, len); }else if(brush->d->font->fontstruct!=NULL){ if(ioncore_g.enc_utf8){ XChar2b *str16; int len16=0; toucs(str, len, &str16, &len16); XDrawImageString16(ioncore_g.dpy, brush->win, gc, x, y, str16, len16); free(str16); }else{ XDrawImageString(ioncore_g.dpy, brush->win, gc, x, y, str, len); } } } }
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; } }
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; } }