]> Dogcows Code - chaz/openbox/blobdiff - src/Font.cc
merged with 2_1-merged-to-HEAD-2002-09-30
[chaz/openbox] / src / Font.cc
index ac315d507598f72d060c33d03979f55bd593f136..fd7a0fbe3bb47111ca3aa650c53f62796f18a4a9 100644 (file)
@@ -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,37 +262,53 @@ 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());
+
+#ifdef XFT_UTF8
+      XftDrawStringUtf8(
+#else
+      XftDrawString8(
+#endif
+                     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();
-    
-    XftDrawStringUtf8(draw, &c, _xftfont, x, _xftfont->ascent + y,
-                      (XftChar8 *) string.c_str(), string.size());
+    c.color.alpha = 0xff | 0xff << 8; // no transparency in BColor yet
+
+#ifdef XFT_UTF8
+    XftDrawStringUtf8(
+#else
+    XftDrawString8(
+#endif
+                   draw, &c, _xftfont, x, _xftfont->ascent + y,
+                   (XftChar8 *) string.c_str(), string.size());
 
     XftDrawDestroy(draw);
     return;
   }
 #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);
 }
 
 
@@ -300,9 +318,16 @@ unsigned int BFont::measureString(const string &string) const {
 #ifdef    XFT
   if (_xftfont) {
     XGlyphInfo info;
-    XftTextExtentsUtf8(_display, _xftfont, (XftChar8 *) string.c_str(),
-                       string.size(), &info);
-    return info.xOff;
+
+#ifdef XFT_UTF8
+    XftTextExtentsUtf8(
+#else
+    XftTextExtents8(
+#endif
+                    _display, _xftfont, (XftChar8 *) string.c_str(),
+                    string.size(), &info);
+
+    return info.xOff + (_shadow ? 1 : 0);
   }
 #endif // XFT
 
@@ -321,7 +346,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())
This page took 0.02702 seconds and 4 git commands to generate.