openbox/otk/font.hh

78 lines
1.7 KiB
C++
Raw Normal View History

2002-11-01 03:27:41 +00:00
// -*- mode: C++; indent-tabs-mode: nil; -*-
#ifndef __Font_hh
#define __Font_hh
extern "C" {
#include <X11/Xlib.h>
2002-12-03 08:54:51 +00:00
#define _XFT_NO_COMPAT_ // no Xft 1 API
2002-11-01 03:27:41 +00:00
#include <X11/Xft/Xft.h>
}
#include <assert.h>
#include <string>
namespace otk {
2002-11-01 03:27:41 +00:00
class BGCCache;
class BGCCacheItem;
class BColor;
class ScreenInfo;
2002-11-01 03:27:41 +00:00
class BFont {
/*
* static members
*/
private:
static std::string _fallback_font;
2002-12-03 08:54:51 +00:00
static bool _xft_init;
2002-11-01 03:27:41 +00:00
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:
int _screen_num;
2002-11-01 03:27:41 +00:00
2002-12-03 08:54:51 +00:00
std::string _fontstring;
2002-11-01 03:27:41 +00:00
bool _shadow;
unsigned char _offset;
unsigned char _tint;
XftFont *_xftfont;
bool createXftFont(void);
public:
// loads an Xft font
2002-12-03 08:54:51 +00:00
BFont(int screen_num, const std::string &fontstring, bool shadow,
unsigned char offset, unsigned char tint);
virtual ~BFont();
2002-11-01 03:27:41 +00:00
2002-12-03 08:54:51 +00:00
inline const std::string &fontstring() const { return _fontstring; }
2002-11-01 03:27:41 +00:00
2002-12-03 08:54:51 +00:00
unsigned int height() const;
unsigned int maxCharWidth() const;
2002-11-01 03:27:41 +00:00
2002-12-03 08:54:51 +00:00
unsigned int measureString(const std::string &string,
bool utf8 = false) const;
2002-11-01 03:27:41 +00:00
2002-12-03 08:54:51 +00:00
//! 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;
2002-11-01 03:27:41 +00:00
};
}
2002-11-01 03:27:41 +00:00
#endif // __Font_hh