From 02c028d8ae0a80206eeb97c662cd3ceebf900977 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 6 Sep 2002 16:14:55 +0000 Subject: [PATCH] (optional) drop shadows for fonts --- src/Font.cc | 17 ++++++++++++++++- src/Font.hh | 3 ++- src/Screen.cc | 13 ++++++++++++- src/Screen.hh | 4 +++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/Font.cc b/src/Font.cc index bc4f6440..d4a6950d 100644 --- a/src/Font.cc +++ b/src/Font.cc @@ -48,7 +48,7 @@ string BFont::_fallback_font = "fixed"; #ifdef XFT BFont::BFont(Display *d, BScreen *screen, const string &family, int size, - bool bold, bool italic, bool antialias) : + bool bold, bool italic, bool shadow, bool antialias) : _display(d), _screen(screen), _family(family), @@ -57,6 +57,7 @@ BFont::BFont(Display *d, BScreen *screen, const string &family, int size, _bold(bold), _italic(italic), _antialias(antialias), + _shadow(shadow), _xftfont(0), _font(0), _fontset(0), @@ -91,6 +92,7 @@ BFont::BFont(Display *d, BScreen *screen, const string &xlfd) : _screen(screen), #ifdef XFT _antialias(False), + _shadow(False), _xftfont(0), #endif // XFT _font(0), @@ -260,6 +262,19 @@ 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 = 0x55 | 0x55 << 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; diff --git a/src/Font.hh b/src/Font.hh index 9f083db9..e29f41b1 100644 --- a/src/Font.hh +++ b/src/Font.hh @@ -71,6 +71,7 @@ private: #ifdef XFT bool _antialias; + bool _shadow; XftFont *_xftfont; @@ -95,7 +96,7 @@ public: #ifdef XFT // loads an Xft font BFont(Display *d, BScreen *screen, const std::string &family, int size, - bool bold, bool italic, bool antialias = True); + bool bold, bool italic, bool shadow, bool antialias = True); #endif // loads a standard X font BFont(Display *d, BScreen *screen, const std::string &xlfd); diff --git a/src/Screen.cc b/src/Screen.cc index 6288b43f..72e601e8 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -407,6 +407,13 @@ void BScreen::saveAAFonts(bool f) { } +void BScreen::saveShadowFonts(bool f) { + resource.shadow_fonts = f; + reconfigure(); + config->setValue(screenstr + "dropShadowFonts", resource.shadow_fonts); +} + + void BScreen::saveHideToolbar(bool h) { resource.hide_toolbar = h; if (resource.hide_toolbar) @@ -593,6 +600,7 @@ void BScreen::save_rc(void) { saveSloppyFocus(resource.sloppy_focus); saveAutoRaise(resource.auto_raise); saveImageDither(doImageDither()); + saveShadowFonts(resource.shadow_fonts); saveAAFonts(resource.aa_fonts); saveResizeZones(resource.resize_zones); saveOpaqueMove(resource.opaque_move); @@ -646,6 +654,9 @@ void BScreen::load_rc(void) { if (! config->getValue(screenstr + "opaqueMove", resource.opaque_move)) resource.opaque_move = false; + if (! config->getValue(screenstr + "dropShadowFonts", resource.shadow_fonts)) + resource.shadow_fonts = true; + if (! config->getValue(screenstr + "antialiasFonts", resource.aa_fonts)) resource.aa_fonts = true; @@ -2561,7 +2572,7 @@ BFont *BScreen::readDatabaseFont(const string &rbasename, } BFont *b = new BFont(blackbox->getXDisplay(), this, family, i, bold, - italic, resource.aa_fonts); + italic, resource.shadow_fonts, resource.aa_fonts); if (b->valid()) return b; else diff --git a/src/Screen.hh b/src/Screen.hh index cb9a8ae2..dee0a962 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -148,7 +148,7 @@ private: bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither, opaque_move, full_max, focus_new, focus_last, click_raise, allow_scroll_lock, hide_toolbar, window_corner_snap, aa_fonts, - ignore_shaded, ignore_maximized, workspace_warping; + ignore_shaded, ignore_maximized, workspace_warping, shadow_fonts; int snap_to_windows, snap_to_edges; unsigned int snap_offset; @@ -212,6 +212,7 @@ public: inline bool doAutoRaise(void) const { return resource.auto_raise; } inline bool doClickRaise(void) const { return resource.click_raise; } inline bool isScreenManaged(void) const { return managed; } + inline bool doShadowFonts(void) const { return resource.shadow_fonts; } inline bool doAAFonts(void) const { return resource.aa_fonts; } inline bool doImageDither(void) const { return image_control->doDither(); } inline bool doOrderedDither(void) const { return resource.ordered_dither; } @@ -296,6 +297,7 @@ public: void saveSnapOffset(int o); void saveResistanceSize(int s); void saveImageDither(bool d); + void saveShadowFonts(bool f); void saveAAFonts(bool f); void saveOpaqueMove(bool o); void saveFullMax(bool f); -- 2.39.2