--- rxvt-unicode/src/defaultfont.h 2003/12/24 09:07:01 1.8 +++ rxvt-unicode/src/defaultfont.h 2004/02/24 00:44:23 1.14 @@ -1,9 +1,10 @@ -/* - * $Id: defaultfont.h,v 1.8 2003/12/24 09:07:01 pcg Exp $ - */ +#ifndef DEFAULTFONT_H_ +#define DEFAULTFONT_H_ -#ifndef _DEFAULTFONT_H_ -#define _DEFAULTFONT_H_ +#include +#if XFT +# include +#endif #ifdef HAVE_XSETLOCALE # define X_LOCALE @@ -21,7 +22,7 @@ #include "rxvtlib.h" #include "feature.h" #include "encoding.h" -#include "rxvtvec.h" +#include "rxvtstl.h" struct rxvt_fontprop { enum { @@ -32,6 +33,20 @@ int weight, slant; }; +struct rxvt_drawable { + rxvt_display *display; + Drawable drawable; +# if XFT + XftDraw *xftdrawable; +#endif + rxvt_drawable (rxvt_display *display, Drawable drawable) + : display(display), drawable(drawable), xftdrawable(0) { } + ~rxvt_drawable (); + + operator Drawable() { return drawable; } + operator XftDraw *(); +}; + struct rxvt_font { // managed by the fontset rxvt_t r; @@ -53,9 +68,9 @@ } rxvt_font () { name = 0; } - ~rxvt_font () { free (name); clear (); }; + ~rxvt_font () { free (name); }; - void clear_rect (int x, int y, int w, int h, int color); + void clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color); virtual void clear () { }; @@ -64,14 +79,13 @@ virtual bool load (const rxvt_fontprop &prop) = 0; virtual bool has_codepoint (uint32_t unicode) = 0; - virtual void draw (int x, int y, + virtual void draw (rxvt_drawable &d, + int x, int y, const text_t *text, int len, int fg, int bg) = 0; }; -//#define FONT_REF(obj) (obj)->refcnt++ -//#define FONT_UNREF(obj) if (!--(obj)->refcnt) delete (obj) -#define FONT_UNREF(f) delete f +#define FONT_UNREF(f) do { (f)->clear (); delete (f); } while (0) struct rxvt_fallback_font; @@ -81,10 +95,10 @@ rxvt_font *new_font (const char *name, codeset cs); - void populate (const char *desc); + bool populate (const char *desc); int find_font (uint32_t unicode); - rxvt_font *operator [](int id) const + rxvt_font *operator [] (int id) const { return fonts[id]; }