Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

/otk/font.hh

Go to the documentation of this file.
00001 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
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    * static members
00024    */
00025 private:
00026   static std::string  _fallback_font;
00027   static bool         _xft_init;
00028 
00029 public:
00030   // the fallback is only used for X fonts, not for Xft fonts, since it is
00031   // assumed that X fonts will be the fallback from Xft.
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    * instance members
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   // loads an Xft font
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   // The RenderControl classes use the internal data to render the fonts, but
00066   // noone else needs it, so its private.
00067   friend class RenderControl;
00068 };
00069 
00070 }
00071 
00072 #endif // __font_hh

Generated on Tue Feb 4 22:58:56 2003 for Openbox by doxygen1.3-rc2