X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Ffont.hh;h=8ff1f67dfd528e11d06d57bfab9fcb250da13938;hb=bc88d310fea71823fb2c61d071ff499579bffaba;hp=c070bbff9a4511d2589878eca0f171c3daba0d7e;hpb=85c41a1aec90b8daefc425596ea34b6f9d0e643c;p=chaz%2Fopenbox diff --git a/otk/font.hh b/otk/font.hh index c070bbff..8ff1f67d 100644 --- a/otk/font.hh +++ b/otk/font.hh @@ -4,19 +4,19 @@ extern "C" { #include - +#define _XFT_NO_COMPAT_ // no Xft 1 API #include } #include - #include +namespace otk { + class BGCCache; class BGCCacheItem; class BColor; - -#include "screen.hh" +class ScreenInfo; class BFont { /* @@ -24,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 @@ -36,16 +37,10 @@ public: * instance members */ private: - Display *_display; - BScreen *_screen; + 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; @@ -54,29 +49,29 @@ private: bool createXftFont(void); - bool _valid; - public: // loads an Xft font - BFont(Display *d, BScreen *screen, 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; }; +} + #endif // __Font_hh