]> Dogcows Code - chaz/openbox/blob - otk/font.hh
default to 1 desktop if its not read from the configs
[chaz/openbox] / otk / font.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __font_hh
3 #define __font_hh
4
5 #include "userstring.hh"
6
7 extern "C" {
8 #include <X11/Xlib.h>
9 #define _XFT_NO_COMPAT_ // no Xft 1 API
10 #include <X11/Xft/Xft.h>
11 }
12
13 #include <assert.h>
14
15 #include <string>
16
17 namespace otk {
18
19 class Color;
20
21 class Font {
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 Font(int screen_num, const std::string &fontstring, bool shadow,
55 unsigned char offset, unsigned char tint);
56 virtual ~Font();
57
58 inline const std::string &fontstring() const { return _fontstring; }
59
60 unsigned int height() const;
61 unsigned int maxCharWidth() const;
62
63 //! Measures the length of a string
64 /*!
65 @param string The string to measure, it should be UTF8 encoded.
66 */
67 unsigned int measureString(const userstring &string) const;
68
69 //! Draws a string into an XftDraw object
70 /*!
71 Be Warned: If you use an XftDraw object and a color, or a font from
72 different screens, you WILL have unpredictable results! :)
73 @param d The drawable to render into.
74 @param x The X offset onto the drawable at which to start drawing.
75 @param x The Y offset onto the drawable at which to start drawing.
76 @param color The color to use for drawing the text.
77 @param string The string to draw, it should be UTF8 encoded.
78 */
79 void drawString(XftDraw *d, int x, int y, const Color &color,
80 const userstring &string) const;
81 };
82
83 }
84
85 #endif // __font_hh
This page took 0.039028 seconds and 4 git commands to generate.