X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Ffont.cc;h=a38946f02ad4efc3efccf72e5ea71c92de714154;hb=9f705c02b9c412c053fc12a2ebdc5cebe83400c8;hp=b9cc7075ce9c4c8f87a52f856635071c7fa01b5d;hpb=8b73f6f02517e717842d122d82e1eb08cda95e19;p=chaz%2Fopenbox diff --git a/otk/font.cc b/otk/font.cc index b9cc7075..a38946f0 100644 --- a/otk/font.cc +++ b/otk/font.cc @@ -51,19 +51,20 @@ Font::Font(int screen_num, const std::string &fontstring, ::exit(3); } int version = XftGetVersion(); - printf(_("Using Xft %d.%d.%d.\n"), - version / 10000 % 100, version / 100 % 100, version % 100); + printf(_("Using Xft %d.%d.%d (Built against %d.%d.%d).\n"), + version / 10000 % 100, version / 100 % 100, version % 100, + XFT_MAJOR, XFT_MINOR, XFT_REVISION); _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 +78,7 @@ Font::Font(int screen_num, const std::string &fontstring, Font::~Font(void) { if (_xftfont) - XftFontClose(Display::display, _xftfont); + XftFontClose(**display, _xftfont); } @@ -92,11 +93,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.bytes()); + else + XftDrawString8(d, &c, _xftfont, x + _offset, + _xftfont->ascent + y + _offset, + (FcChar8*)string.c_str(), string.bytes()); } XftColor c; @@ -106,8 +112,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.bytes()); + else + XftDrawString8(d, &c, _xftfont, x, _xftfont->ascent + y, + (FcChar8*)string.c_str(), string.bytes()); return; } @@ -117,8 +127,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.bytes(), &info); + else + XftTextExtents8(**display, _xftfont, + (FcChar8*)string.c_str(), string.bytes(), &info); return info.xOff + (_shadow ? _offset : 0); }