(optional) drop shadows for fonts

This commit is contained in:
Dana Jansens 2002-09-06 16:14:55 +00:00
parent a0537f89e7
commit 02c028d8ae
4 changed files with 33 additions and 4 deletions

View file

@ -48,7 +48,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 antialias) : bool bold, bool italic, bool shadow, bool antialias) :
_display(d), _display(d),
_screen(screen), _screen(screen),
_family(family), _family(family),
@ -57,6 +57,7 @@ BFont::BFont(Display *d, BScreen *screen, const string &family, int size,
_bold(bold), _bold(bold),
_italic(italic), _italic(italic),
_antialias(antialias), _antialias(antialias),
_shadow(shadow),
_xftfont(0), _xftfont(0),
_font(0), _font(0),
_fontset(0), _fontset(0),
@ -91,6 +92,7 @@ BFont::BFont(Display *d, BScreen *screen, const string &xlfd) :
_screen(screen), _screen(screen),
#ifdef XFT #ifdef XFT
_antialias(False), _antialias(False),
_shadow(False),
_xftfont(0), _xftfont(0),
#endif // XFT #endif // XFT
_font(0), _font(0),
@ -260,6 +262,19 @@ void BFont::drawString(Drawable d, int x, int y, const BColor &color,
_screen->getColormap()); _screen->getColormap());
assert(draw); 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; XftColor c;
c.color.red = color.red() | color.red() << 8; c.color.red = color.red() | color.red() << 8;
c.color.green = color.green() | color.green() << 8; c.color.green = color.green() | color.green() << 8;

View file

@ -71,6 +71,7 @@ private:
#ifdef XFT #ifdef XFT
bool _antialias; bool _antialias;
bool _shadow;
XftFont *_xftfont; XftFont *_xftfont;
@ -95,7 +96,7 @@ public:
#ifdef XFT #ifdef XFT
// 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 antialias = True); bool bold, bool italic, bool shadow, 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

@ -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) { void BScreen::saveHideToolbar(bool h) {
resource.hide_toolbar = h; resource.hide_toolbar = h;
if (resource.hide_toolbar) if (resource.hide_toolbar)
@ -593,6 +600,7 @@ void BScreen::save_rc(void) {
saveSloppyFocus(resource.sloppy_focus); saveSloppyFocus(resource.sloppy_focus);
saveAutoRaise(resource.auto_raise); saveAutoRaise(resource.auto_raise);
saveImageDither(doImageDither()); saveImageDither(doImageDither());
saveShadowFonts(resource.shadow_fonts);
saveAAFonts(resource.aa_fonts); saveAAFonts(resource.aa_fonts);
saveResizeZones(resource.resize_zones); saveResizeZones(resource.resize_zones);
saveOpaqueMove(resource.opaque_move); saveOpaqueMove(resource.opaque_move);
@ -646,6 +654,9 @@ void BScreen::load_rc(void) {
if (! config->getValue(screenstr + "opaqueMove", resource.opaque_move)) if (! config->getValue(screenstr + "opaqueMove", resource.opaque_move))
resource.opaque_move = false; resource.opaque_move = false;
if (! config->getValue(screenstr + "dropShadowFonts", resource.shadow_fonts))
resource.shadow_fonts = true;
if (! config->getValue(screenstr + "antialiasFonts", resource.aa_fonts)) if (! config->getValue(screenstr + "antialiasFonts", resource.aa_fonts))
resource.aa_fonts = true; resource.aa_fonts = true;
@ -2561,7 +2572,7 @@ BFont *BScreen::readDatabaseFont(const string &rbasename,
} }
BFont *b = new BFont(blackbox->getXDisplay(), this, family, i, bold, BFont *b = new BFont(blackbox->getXDisplay(), this, family, i, bold,
italic, resource.aa_fonts); italic, resource.shadow_fonts, resource.aa_fonts);
if (b->valid()) if (b->valid())
return b; return b;
else else

View file

@ -148,7 +148,7 @@ private:
bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither, bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither,
opaque_move, full_max, focus_new, focus_last, click_raise, opaque_move, full_max, focus_new, focus_last, click_raise,
allow_scroll_lock, hide_toolbar, window_corner_snap, aa_fonts, 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; int snap_to_windows, snap_to_edges;
unsigned int snap_offset; unsigned int snap_offset;
@ -212,6 +212,7 @@ public:
inline bool doAutoRaise(void) const { return resource.auto_raise; } inline bool doAutoRaise(void) const { return resource.auto_raise; }
inline bool doClickRaise(void) const { return resource.click_raise; } inline bool doClickRaise(void) const { return resource.click_raise; }
inline bool isScreenManaged(void) const { return managed; } 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 doAAFonts(void) const { return resource.aa_fonts; }
inline bool doImageDither(void) const { return image_control->doDither(); } inline bool doImageDither(void) const { return image_control->doDither(); }
inline bool doOrderedDither(void) const { return resource.ordered_dither; } inline bool doOrderedDither(void) const { return resource.ordered_dither; }
@ -296,6 +297,7 @@ public:
void saveSnapOffset(int o); void saveSnapOffset(int o);
void saveResistanceSize(int s); void saveResistanceSize(int s);
void saveImageDither(bool d); void saveImageDither(bool d);
void saveShadowFonts(bool f);
void saveAAFonts(bool f); void saveAAFonts(bool f);
void saveOpaqueMove(bool o); void saveOpaqueMove(bool o);
void saveFullMax(bool f); void saveFullMax(bool f);