X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Ffont.cc;fp=otk%2Ffont.cc;h=0f1ad8c1cb5559d20647e21df54db7c4dead0ef8;hb=bc99e6a420c04b4607bffc90e528d9572649f95f;hp=6932971c1c3ca6c9cb83d8793d1b3616a7dcdf12;hpb=703ef4df2278adef66a65bcfc9455da41d0413e6;p=chaz%2Fopenbox diff --git a/otk/font.cc b/otk/font.cc index 6932971c..0f1ad8c1 100644 --- a/otk/font.cc +++ b/otk/font.cc @@ -10,7 +10,15 @@ extern "C" { #endif // HAVE_STDLIB_H } +#include +#include + +using std::string; +using std::cerr; +using std::endl; + #include "font.hh" +#include "util.hh" #include "display.hh" #include "color.hh" #include "screeninfo.hh" @@ -26,10 +34,10 @@ extern "C" { namespace otk { -std::string Font::_fallback_font = "fixed"; +string Font::_fallback_font = "fixed"; bool Font::_xft_init = false; -Font::Font(int screen_num, const std::string &fontstring, +Font::Font(int screen_num, const string &fontstring, bool shadow, unsigned char offset, unsigned char tint) : _screen_num(screen_num), _fontstring(fontstring), @@ -78,7 +86,7 @@ Font::~Font(void) void Font::drawString(XftDraw *d, int x, int y, const Color &color, - const userstring &string) const + const string &string, bool utf8) const { assert(d); @@ -90,7 +98,7 @@ void Font::drawString(XftDraw *d, int x, int y, const Color &color, c.color.alpha = _tint | _tint << 8; // transparent shadow c.pixel = BlackPixel(Display::display, _screen_num); - if (string.utf8()) + if (utf8) XftDrawStringUtf8(d, &c, _xftfont, x + _offset, _xftfont->ascent + y + _offset, (FcChar8*)string.c_str(), string.size()); @@ -107,7 +115,7 @@ 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 - if (string.utf8()) + if (utf8) XftDrawStringUtf8(d, &c, _xftfont, x, _xftfont->ascent + y, (FcChar8*)string.c_str(), string.size()); else @@ -118,11 +126,11 @@ void Font::drawString(XftDraw *d, int x, int y, const Color &color, } -unsigned int Font::measureString(const userstring &string) const +unsigned int Font::measureString(const string &string, bool utf8) const { XGlyphInfo info; - if (string.utf8()) + if (utf8) XftTextExtentsUtf8(Display::display, _xftfont, (FcChar8*)string.c_str(), string.size(), &info); else