]> Dogcows Code - chaz/openbox/blob - otk/font.hh
use the rect
[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 #include <X11/Xft/Xft.h>
8 }
9
10 #include <assert.h>
11 #include <string>
12
13 namespace otk {
14
15 class BGCCache;
16 class BGCCacheItem;
17 class BColor;
18 class ScreenInfo;
19
20 class BFont {
21 /*
22 * static members
23 */
24 private:
25 static std::string _fallback_font;
26
27 public:
28 // the fallback is only used for X fonts, not for Xft fonts, since it is
29 // assumed that X fonts will be the fallback from Xft.
30 inline static std::string fallbackFont(void) { return _fallback_font; }
31 inline static void setFallbackFont(const std::string &f)
32 { _fallback_font = f; }
33
34 /*
35 * instance members
36 */
37 private:
38 int _screen_num;
39
40 std::string _family;
41 bool _simplename; // true if not spec'd as a -*-* string
42 int _size;
43 bool _bold;
44 bool _italic;
45
46 bool _antialias;
47 bool _shadow;
48 unsigned char _offset;
49 unsigned char _tint;
50
51 XftFont *_xftfont;
52
53 bool createXftFont(void);
54
55 bool _valid;
56
57 public:
58 // loads an Xft font
59 BFont(int screen_num, const std::string &family, int size,
60 bool bold, bool italic, bool shadow, unsigned char offset,
61 unsigned char tint, bool antialias = True);
62 virtual ~BFont(void);
63
64 inline bool valid(void) const { return _valid; }
65
66 inline std::string family(void) const { assert(_valid); return _family; }
67 inline int size(void) const { assert(_valid); return _size; }
68 inline bool bold(void) const { assert(_valid); return _bold; }
69 inline bool italic(void) const { assert(_valid); return _italic; }
70
71 unsigned int height(void) const;
72 unsigned int maxCharWidth(void) const;
73
74 unsigned int measureString(const std::string &string) const;
75
76 void drawString(Drawable d, int x, int y, const BColor &color,
77 const std::string &string) const;
78 };
79
80 }
81
82 #endif // __Font_hh
This page took 0.035302 seconds and 4 git commands to generate.