Allow variable tinting of the shadow. Use *.xft.tint: integer

integer is a number -100 to 100 that specifies the alpha channel, with
negative numbers meaning lighten the background and positive being
darken.
This commit is contained in:
Scott Moynes 2002-10-23 02:46:47 +00:00
parent dc4957eed8
commit 1e36acfd91
3 changed files with 20 additions and 10 deletions

View file

@ -49,7 +49,7 @@ string BFont::_fallback_font = "fixed";
#ifdef XFT #ifdef XFT
BFont::BFont(Display *d, BScreen *screen, const string &family, int size, BFont::BFont(Display *d, BScreen *screen, const string &family, int size,
bool bold, bool italic, bool shadow, unsigned char offset, bool bold, bool italic, bool shadow, unsigned char offset,
unsigned char tint, bool antialias) : int tint, bool antialias) :
_display(d), _display(d),
_screen(screen), _screen(screen),
_family(family), _family(family),
@ -265,14 +265,22 @@ void BFont::drawString(Drawable d, int x, int y, const BColor &color,
_screen->getColormap()); _screen->getColormap());
assert(draw); assert(draw);
if (_shadow) { if (_shadow) {
XftColor c; XftColor c;
if (_tint >= 0) {
c.color.red = 0; c.color.red = 0;
c.color.green = 0; c.color.green = 0;
c.color.blue = 0; c.color.blue = 0;
c.color.alpha = _tint | _tint << 8; // transparent shadow c.color.alpha = 0xffff * _tint/100; // transparent shadow
c.pixel = BlackPixel(_display, _screen->getScreenNumber()); c.pixel = BlackPixel(_display, _screen->getScreenNumber());
} else {
c.color.red = 0xffff * -_tint/100;
c.color.green = 0xffff * -_tint/100;
c.color.blue = 0xffff * -_tint/100;
c.color.alpha = 0xffff * -_tint/100;
c.pixel = WhitePixel(_display, _screen->getScreenNumber());
}
#ifdef XFT_UTF8 #ifdef XFT_UTF8
XftDrawStringUtf8( XftDrawStringUtf8(
#else #else

View file

@ -73,7 +73,7 @@ private:
bool _antialias; bool _antialias;
bool _shadow; bool _shadow;
unsigned char _offset; unsigned char _offset;
unsigned char _tint; int _tint;
XftFont *_xftfont; XftFont *_xftfont;
@ -99,7 +99,7 @@ public:
// loads an Xft font // loads an Xft font
BFont(Display *d, BScreen *screen, const std::string &family, int size, BFont(Display *d, BScreen *screen, const std::string &family, int size,
bool bold, bool italic, bool shadow, unsigned char offset, bool bold, bool italic, bool shadow, unsigned char offset,
unsigned char tint, bool antialias = True); int tint, bool antialias = True);
#endif #endif
// loads a standard X font // loads a standard X font
BFont(Display *d, BScreen *screen, const std::string &xlfd); BFont(Display *d, BScreen *screen, const std::string &xlfd);

View file

@ -2750,11 +2750,13 @@ BFont *BScreen::readDatabaseFont(const string &rbasename,
offset = 1; offset = 1;
} }
unsigned char tint = 0x40; int tint = 25;
if (style.getValue(rbasename + "xft.shadow.tint", s)) { if (style.getValue(rbasename + "xft.shadow.tint", s)) {
tint = atoi(s.c_str()); tint = atoi(s.c_str());
} }
if (tint > 100) tint = 100;
if (tint < -100) tint = -100;
BFont *b = new BFont(blackbox->getXDisplay(), this, family, i, bold, BFont *b = new BFont(blackbox->getXDisplay(), this, family, i, bold,
italic, dropShadow && resource.shadow_fonts, offset, italic, dropShadow && resource.shadow_fonts, offset,