]> Dogcows Code - chaz/openbox/blobdiff - otk/font.cc
set the global display var
[chaz/openbox] / otk / font.cc
index b9cc7075ce9c4c8f87a52f856635071c7fa01b5d..a9f2fd3ee352e41220a7b49bfcd2e80a5e9e4edc 100644 (file)
@@ -56,14 +56,14 @@ Font::Font(int screen_num, const std::string &fontstring,
     _xft_init = true;
   }
 
-  if ((_xftfont = XftFontOpenName(Display::display, _screen_num,
+  if ((_xftfont = XftFontOpenName(**display, _screen_num,
                                   _fontstring.c_str())))
     return;
 
   printf(_("Unable to load font: %s\n"), _fontstring.c_str());
   printf(_("Trying fallback font: %s\n"), _fallback_font.c_str());
 
-  if ((_xftfont = XftFontOpenName(Display::display, _screen_num,
+  if ((_xftfont = XftFontOpenName(**display, _screen_num,
                                   _fallback_font.c_str())))
     return;
 
@@ -77,7 +77,7 @@ Font::Font(int screen_num, const std::string &fontstring,
 Font::~Font(void)
 {
   if (_xftfont)
-    XftFontClose(Display::display, _xftfont);
+    XftFontClose(**display, _xftfont);
 }
 
 
@@ -92,11 +92,16 @@ void Font::drawString(XftDraw *d, int x, int y, const Color &color,
     c.color.green = 0;
     c.color.blue = 0;
     c.color.alpha = _tint | _tint << 8; // transparent shadow
-    c.pixel = BlackPixel(Display::display, _screen_num);
-
-    XftDrawStringUtf8(d, &c, _xftfont, x + _offset,
-                      _xftfont->ascent + y + _offset,
-                      (FcChar8*)string.c_str(), string.size());
+    c.pixel = BlackPixel(**display, _screen_num);
+
+    if (string.utf8())
+      XftDrawStringUtf8(d, &c, _xftfont, x + _offset,
+                        _xftfont->ascent + y + _offset,
+                        (FcChar8*)string.c_str(), string.size());
+    else
+      XftDrawString8(d, &c, _xftfont, x + _offset,
+                     _xftfont->ascent + y + _offset,
+                     (FcChar8*)string.c_str(), string.size());
   }
     
   XftColor c;
@@ -106,8 +111,12 @@ void Font::drawString(XftDraw *d, int x, int y, const Color &color,
   c.pixel = color.pixel();
   c.color.alpha = 0xff | 0xff << 8; // no transparency in Color yet
 
-  XftDrawStringUtf8(d, &c, _xftfont, x, _xftfont->ascent + y,
-                    (FcChar8*)string.c_str(), string.size());
+  if (string.utf8())
+    XftDrawStringUtf8(d, &c, _xftfont, x, _xftfont->ascent + y,
+                      (FcChar8*)string.c_str(), string.size());
+  else
+    XftDrawString8(d, &c, _xftfont, x, _xftfont->ascent + y,
+                   (FcChar8*)string.c_str(), string.size());
 
   return;
 }
@@ -117,8 +126,12 @@ unsigned int Font::measureString(const ustring &string) const
 {
   XGlyphInfo info;
 
-  XftTextExtentsUtf8(Display::display, _xftfont,
-                     (FcChar8*)string.c_str(), string.size(), &info);
+  if (string.utf8())
+    XftTextExtentsUtf8(**display, _xftfont,
+                       (FcChar8*)string.c_str(), string.size(), &info);
+  else
+    XftTextExtents8(**display, _xftfont,
+                    (FcChar8*)string.c_str(), string.size(), &info);
 
   return info.xOff + (_shadow ? _offset : 0);
 }
This page took 0.023052 seconds and 4 git commands to generate.