]> Dogcows Code - chaz/openbox/blob - otk/font.hh
xft2 works. and works good.
[chaz/openbox] / otk / font.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 #ifndef __Font_hh
3 #define __Font_hh
4
5 extern "C" {
6 #include <X11/Xlib.h>
7 #define _XFT_NO_COMPAT_ // no Xft 1 API
8 #include <X11/Xft/Xft.h>
9 }
10
11 #include <assert.h>
12 #include <string>
13
14 namespace otk {
15
16 class BGCCache;
17 class BGCCacheItem;
18 class BColor;
19 class ScreenInfo;
20
21 class BFont {
22 /*
23 * static members
24 */
25 private:
26 static std::string _fallback_font;
27 static bool _xft_init;
28
29 public:
30 // the fallback is only used for X fonts, not for Xft fonts, since it is
31 // assumed that X fonts will be the fallback from Xft.
32 inline static std::string fallbackFont(void) { return _fallback_font; }
33 inline static void setFallbackFont(const std::string &f)
34 { _fallback_font = f; }
35
36 /*
37 * instance members
38 */
39 private:
40 int _screen_num;
41
42 std::string _fontstring;
43
44 bool _shadow;
45 unsigned char _offset;
46 unsigned char _tint;
47
48 XftFont *_xftfont;
49
50 bool createXftFont(void);
51
52 public:
53 // loads an Xft font
54 BFont(int screen_num, const std::string &fontstring, bool shadow,
55 unsigned char offset, unsigned char tint);
56 virtual ~BFont();
57
58 inline const std::string &fontstring() const { return _fontstring; }
59
60 unsigned int height() const;
61 unsigned int maxCharWidth() const;
62
63 unsigned int measureString(const std::string &string,
64 bool utf8 = false) const;
65
66 //! Draws a string into an XftDraw object
67 /*!
68 Be Warned: If you use an XftDraw object and a color, or a font from
69 different screens, you WILL have unpredictable results! :)
70 */
71 void drawString(XftDraw *d, int x, int y, const BColor &color,
72 const std::string &string, bool utf8 = false) const;
73 };
74
75 }
76
77 #endif // __Font_hh
This page took 0.035158 seconds and 4 git commands to generate.