3 #include "../src/gettext.h"
4 #define _(str) gettext(str)
6 font_open(const std::string &fontstring,
7 bool shadow, unsigned char offset, unsigned char tint)
9 assert(screen_num >= 0);
10 assert(tint <= CHAR_MAX);
14 printf(_("Couldn't initialize Xft.\n\n"));
18 int version = XftGetVersion();
19 printf("Using Xft %d.%d.%d (Built against %d.%d.%d).\n",
20 version / 10000 % 100, version / 100 % 100, version % 100,
21 XFT_MAJOR, XFT_MINOR, XFT_REVISION);
26 if ((_xftfont = XftFontOpenName(ob_display, _screen_num,
30 printf(_("Unable to load font: %s\n"), _fontstring.c_str());
31 printf(_("Trying fallback font: %s\n"), "fixed");
33 if ((_xftfont = XftFontOpenName(ob_display, _screen_num,
37 printf(_("Unable to load font: %s\n"), "fixed");
38 printf(_("Aborting!.\n"));
40 exit(3); // can't continue without a font
47 XftFontClose(ob_display, _xftfont);
51 int font_measure_string(const char *)
56 XftTextExtentsUtf8(**display, _xftfont,
57 (FcChar8*)string.c_str(), string.bytes(), &info);
59 XftTextExtents8(ob_display, _xftfont,
60 (FcChar8*)string.c_str(), string.bytes(), &info);
62 return (signed) info.xOff + (_shadow ? _offset : 0);
68 return (signed) _xftfont->height + (_shadow ? _offset : 0);
72 int font_max_char_width(void)
74 return (signed) _xftfont->max_advance_width;