00001
00002 #ifndef __font_hh
00003 #define __font_hh
00004
00005 #include "ustring.hh"
00006 #include "truerendercontrol.hh"
00007
00008 extern "C" {
00009 #include <X11/Xlib.h>
00010 #define _XFT_NO_COMPAT_ // no Xft 1 API
00011 #include <X11/Xft/Xft.h>
00012 }
00013
00014 #include <assert.h>
00015
00016 namespace otk {
00017
00018 class Color;
00019 class Surface;
00020
00021 class Font {
00022
00023
00024
00025 private:
00026 static std::string _fallback_font;
00027 static bool _xft_init;
00028
00029 public:
00030
00031
00032 inline static std::string fallbackFont(void) { return _fallback_font; }
00033 inline static void setFallbackFont(const std::string &f)
00034 { _fallback_font = f; }
00035
00036
00037
00038
00039 private:
00040 int _screen_num;
00041
00042 std::string _fontstring;
00043
00044 bool _shadow;
00045 unsigned char _offset;
00046 unsigned char _tint;
00047
00048 XftFont *_xftfont;
00049
00050 bool createXftFont(void);
00051
00052 public:
00053
00054 Font(int screen_num, const std::string &fontstring, bool shadow,
00055 unsigned char offset, unsigned char tint);
00056 virtual ~Font();
00057
00058 inline const std::string &fontstring() const { return _fontstring; }
00059
00060 int height() const;
00061 int maxCharWidth() const;
00062
00063 int measureString(const ustring &string) const;
00064
00065
00066
00067 friend class RenderControl;
00068 };
00069
00070 }
00071
00072 #endif // __font_hh