]> Dogcows Code - chaz/openbox/blobdiff - otk/font.cc
use the byte size for utf strings, not the character size
[chaz/openbox] / otk / font.cc
index 6fbdb0957f1d7dddf9622028aeb8afc2edde4e00..a51e158c1613fa92d898b31a6c19a0aa8968e429 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,16 +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);
+    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());
+                        (FcChar8*)string.c_str(), string.bytes());
     else
       XftDrawString8(d, &c, _xftfont, x + _offset,
                      _xftfont->ascent + y + _offset,
-                     (FcChar8*)string.c_str(), string.size());
+                     (FcChar8*)string.c_str(), string.bytes());
   }
     
   XftColor c;
@@ -113,10 +113,10 @@ void Font::drawString(XftDraw *d, int x, int y, const Color &color,
 
   if (string.utf8())
     XftDrawStringUtf8(d, &c, _xftfont, x, _xftfont->ascent + y,
-                      (FcChar8*)string.c_str(), string.size());
+                      (FcChar8*)string.c_str(), string.bytes());
   else
     XftDrawString8(d, &c, _xftfont, x, _xftfont->ascent + y,
-                   (FcChar8*)string.c_str(), string.size());
+                   (FcChar8*)string.c_str(), string.bytes());
 
   return;
 }
@@ -127,11 +127,11 @@ unsigned int Font::measureString(const ustring &string) const
   XGlyphInfo info;
 
   if (string.utf8())
-    XftTextExtentsUtf8(Display::display, _xftfont,
-                       (FcChar8*)string.c_str(), string.size(), &info);
+    XftTextExtentsUtf8(**display, _xftfont,
+                       (FcChar8*)string.c_str(), string.bytes(), &info);
   else
-    XftTextExtents8(Display::display, _xftfont,
-                    (FcChar8*)string.c_str(), string.size(), &info);
+    XftTextExtents8(**display, _xftfont,
+                    (FcChar8*)string.c_str(), string.bytes(), &info);
 
   return info.xOff + (_shadow ? _offset : 0);
 }
This page took 0.028429 seconds and 4 git commands to generate.