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