otk/font.hh (raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
// -*- mode: C++; indent-tabs-mode: nil; -*- #ifndef __Font_hh #define __Font_hh extern "C" { #include <X11/Xlib.h> #include <X11/Xft/Xft.h> } #include <assert.h> #include <string> class BGCCache; class BGCCacheItem; class BColor; #include "screen.hh" class BFont { /* * static members */ private: static std::string _fallback_font; public: // the fallback is only used for X fonts, not for Xft fonts, since it is // assumed that X fonts will be the fallback from Xft. inline static std::string fallbackFont(void) { return _fallback_font; } inline static void setFallbackFont(const std::string &f) { _fallback_font = f; } /* * instance members */ private: Display *_display; BScreen *_screen; std::string _family; bool _simplename; // true if not spec'd as a -*-* string int _size; bool _bold; bool _italic; bool _antialias; bool _shadow; unsigned char _offset; unsigned char _tint; XftFont *_xftfont; 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; } 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; } unsigned int height(void) const; unsigned int maxCharWidth(void) const; unsigned int measureString(const std::string &string) const; void drawString(Drawable d, int x, int y, const BColor &color, const std::string &string) const; }; #endif // __Font_hh |