summaryrefslogtreecommitdiff
path: root/otk/font.hh
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2002-12-03 08:54:51 +0000
committerDana Jansens <danakj@orodu.net>2002-12-03 08:54:51 +0000
commitc6f228f3ff9ab7087669366a23d2ae61d8e5b9b9 (patch)
treebbf89e7eaa23d8986efe071ad41d4433301ff7da /otk/font.hh
parentf77502100a32a6f875f33ef2ab01802f1cbc7c69 (diff)
xft2 works. and works good.
Diffstat (limited to 'otk/font.hh')
-rw-r--r--otk/font.hh41
1 files changed, 18 insertions, 23 deletions
diff --git a/otk/font.hh b/otk/font.hh
index 8afd2bd1..8ff1f67d 100644
--- a/otk/font.hh
+++ b/otk/font.hh
@@ -4,6 +4,7 @@
extern "C" {
#include <X11/Xlib.h>
+#define _XFT_NO_COMPAT_ // no Xft 1 API
#include <X11/Xft/Xft.h>
}
@@ -23,6 +24,7 @@ class BFont {
*/
private:
static std::string _fallback_font;
+ static bool _xft_init;
public:
// the fallback is only used for X fonts, not for Xft fonts, since it is
@@ -37,13 +39,8 @@ public:
private:
int _screen_num;
- std::string _family;
- bool _simplename; // true if not spec'd as a -*-* string
- int _size;
- bool _bold;
- bool _italic;
+ std::string _fontstring;
- bool _antialias;
bool _shadow;
unsigned char _offset;
unsigned char _tint;
@@ -52,29 +49,27 @@ private:
bool createXftFont(void);
- bool _valid;
-
public:
// loads an Xft font
- BFont(int screen_num, const std::string &family, int size,
- bool bold, bool italic, bool shadow, unsigned char offset,
- unsigned char tint, bool antialias = True);
- virtual ~BFont(void);
-
- inline bool valid(void) const { return _valid; }
+ BFont(int screen_num, const std::string &fontstring, bool shadow,
+ unsigned char offset, unsigned char tint);
+ virtual ~BFont();
- inline std::string family(void) const { assert(_valid); return _family; }
- inline int size(void) const { assert(_valid); return _size; }
- inline bool bold(void) const { assert(_valid); return _bold; }
- inline bool italic(void) const { assert(_valid); return _italic; }
+ inline const std::string &fontstring() const { return _fontstring; }
- unsigned int height(void) const;
- unsigned int maxCharWidth(void) const;
+ unsigned int height() const;
+ unsigned int maxCharWidth() const;
- unsigned int measureString(const std::string &string) const;
+ unsigned int measureString(const std::string &string,
+ bool utf8 = false) const;
- void drawString(Drawable d, int x, int y, const BColor &color,
- const std::string &string) const;
+ //! Draws a string into an XftDraw object
+ /*!
+ Be Warned: If you use an XftDraw object and a color, or a font from
+ different screens, you WILL have unpredictable results! :)
+ */
+ void drawString(XftDraw *d, int x, int y, const BColor &color,
+ const std::string &string, bool utf8 = false) const;
};
}