]> Dogcows Code - chaz/openbox/blobdiff - otk/font.hh
kill the const, use g_new instead of malloc, g_free the font in font_close()
[chaz/openbox] / otk / font.hh
index 8ff1f67dfd528e11d06d57bfab9fcb250da13938..53e48c4ebad194546cdd99e1716f98b7f4966a36 100644 (file)
@@ -1,6 +1,9 @@
-// -*- mode: C++; indent-tabs-mode: nil; -*-
-#ifndef   __Font_hh
-#define   __Font_hh
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+#ifndef   __font_hh
+#define   __font_hh
+
+#include "ustring.hh"
+#include "truerendercontrol.hh"
 
 extern "C" {
 #include <X11/Xlib.h>
@@ -8,35 +11,20 @@ extern "C" {
 #include <X11/Xft/Xft.h>
 }
 
-#include <assert.h>
-#include <string>
+#include <cassert>
 
 namespace otk {
 
-class BGCCache;
-class BGCCacheItem;
-class BColor;
-class ScreenInfo;
+class Color;
+class Surface;
 
-class BFont {
+class Font {
   /*
    * static members
    */
 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
-  // 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; }
+  static bool       _xft_init;
 
-  /*
-   * instance members
-   */
-private:
   int               _screen_num;
 
   std::string       _fontstring;
@@ -51,27 +39,22 @@ private:
   
 public:
   // loads an Xft font
-  BFont(int screen_num, const std::string &fontstring, bool shadow,
+  Font(int screen_num, const std::string &fontstring, bool shadow,
         unsigned char offset, unsigned char tint);
-  virtual ~BFont();
+  virtual ~Font();
 
   inline const std::string &fontstring() const { return _fontstring; }
 
-  unsigned int height() const;
-  unsigned int maxCharWidth() const;
+  int height() const;
+  int maxCharWidth() const;
 
-  unsigned int measureString(const std::string &string,
-                             bool utf8 = false) const;
+  int measureString(const ustring &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;
+  // The RenderControl classes use the internal data to render the fonts, but
+  // noone else needs it, so its private.
+  friend class RenderControl;
 };
 
 }
 
-#endif // __Font_hh
+#endif // __font_hh
This page took 0.024663 seconds and 4 git commands to generate.