X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FFont.cc;h=68114a989c237972c4c0d7ba4d96f5d47d3a8382;hb=01732a20dbb6b75431dc34fbe8401bfca952f43a;hp=979c4c215a64b24385baa8c7ada2c9f010f37c43;hpb=1618ecc845e9191a383ea9ffd1e6ab7e31caec15;p=chaz%2Fopenbox diff --git a/src/Font.cc b/src/Font.cc index 979c4c21..68114a98 100644 --- a/src/Font.cc +++ b/src/Font.cc @@ -44,23 +44,24 @@ using std::endl; #include "GCCache.hh" #include "Color.hh" -bool BFont::_antialias = True; string BFont::_fallback_font = "fixed"; - #ifdef XFT BFont::BFont(Display *d, BScreen *screen, const string &family, int size, - bool bold, bool italic) : _display(d), - _screen(screen), - _family(family), - _simplename(False), - _size(size), - _bold(bold), - _italic(italic), - _xftfont(0), - _font(0), - _fontset(0), - _fontset_extents(0) { + bool bold, bool italic, bool shadow, bool antialias) : + _display(d), + _screen(screen), + _family(family), + _simplename(False), + _size(size), + _bold(bold), + _italic(italic), + _antialias(antialias), + _shadow(shadow), + _xftfont(0), + _font(0), + _fontset(0), + _fontset_extents(0) { _valid = False; _xftfont = XftFontOpen(_display, _screen->getScreenNumber(), @@ -90,6 +91,8 @@ BFont::BFont(Display *d, BScreen *screen, const string &xlfd) : _display(d), _screen(screen), #ifdef XFT + _antialias(False), + _shadow(False), _xftfont(0), #endif // XFT _font(0), @@ -259,13 +262,26 @@ void BFont::drawString(Drawable d, int x, int y, const BColor &color, _screen->getColormap()); assert(draw); + if (_shadow) { + XftColor c; + c.color.red = 0; + c.color.green = 0; + c.color.blue = 0; + c.color.alpha = 0x40 | 0x40 << 8; // transparent shadow + c.pixel = BlackPixel(_display, _screen->getScreenNumber()); + + + XftDrawStringUtf8(draw, &c, _xftfont, x + 1, _xftfont->ascent + y + 1, + (XftChar8 *) string.c_str(), string.size()); + } + XftColor c; c.color.red = color.red() | color.red() << 8; c.color.green = color.green() | color.green() << 8; c.color.blue = color.blue() | color.blue() << 8; - c.color.alpha = 0xff | 0xff << 8; // no transparency in BColor yet c.pixel = color.pixel(); - + c.color.alpha = 0xff | 0xff << 8; // no transparency in BColor yet + XftDrawStringUtf8(draw, &c, _xftfont, x, _xftfont->ascent + y, (XftChar8 *) string.c_str(), string.size()); @@ -274,22 +290,16 @@ void BFont::drawString(Drawable d, int x, int y, const BColor &color, } #endif // XFT - BGCCache *_cache = color.display()->gcCache(); - BGCCacheItem *_item = _cache->find(color, _font, GXcopy, ClipByChildren); - - assert(_cache); - assert(_item); + BPen pen(color, _font); if (i18n.multibyte()) - XmbDrawString(_display, d, _fontset, _item->gc(), + XmbDrawString(_display, d, _fontset, pen.gc(), x, y - _fontset_extents->max_ink_extent.y, string.c_str(), string.size()); else - XDrawString(_display, d, _item->gc(), + XDrawString(_display, d, pen.gc(), x, _font->ascent + y, string.c_str(), string.size()); - - _cache->release(_item); } @@ -301,7 +311,7 @@ unsigned int BFont::measureString(const string &string) const { XGlyphInfo info; XftTextExtentsUtf8(_display, _xftfont, (XftChar8 *) string.c_str(), string.size(), &info); - return info.xOff; + return info.xOff + (_shadow ? 1 : 0); } #endif // XFT @@ -320,7 +330,7 @@ unsigned int BFont::height(void) const { #ifdef XFT if (_xftfont) - return _xftfont->height; + return _xftfont->height + (_shadow ? 1 : 0); #endif // XFT if (i18n.multibyte())