--- rxvt-unicode/src/rxvtfont.h 2004/08/15 00:37:04 1.1 +++ rxvt-unicode/src/rxvtfont.h 2010/05/22 23:55:56 1.37 @@ -6,135 +6,110 @@ # include #endif -#ifdef HAVE_XSETLOCALE -# define X_LOCALE -# include -#else -# ifdef HAVE_SETLOCALE -# include -# endif -#endif /* HAVE_XLOCALE */ - -#ifdef HAVE_NL_LANGINFO -# include -#endif - #include -#include "rxvtlib.h" #include "feature.h" #include "encoding.h" #include "rxvtutil.h" +#include "rxvttoolkit.h" + +struct rxvt_term; -struct rxvt_fontprop { +struct rxvt_fontprop +{ enum { + unset = -1, medium = 100, bold = 200, roman = 0, italic = 100, }; - int width, height; + int width, height, ascent; int weight, slant; }; -struct rxvt_drawable { - rxvt_display *display; - Drawable drawable; -#if XFT - XftDraw *xftdrawable; - operator XftDraw *(); -#endif - - rxvt_drawable (rxvt_display *display, Drawable drawable) - : display(display), -#if XFT - xftdrawable(0), -#endif - drawable(drawable) - { } - -#if XFT - ~rxvt_drawable (); -#endif - - operator Drawable() { return drawable; } -}; - -struct rxvt_font { - struct rxvt_fontset *fs; +struct rxvt_font +{ // managed by the fontset - rxvt_t r; - void set_term (rxvt_t r) { this->r = r; } + rxvt_term *term; + void set_term (rxvt_term *term) { this->term = term; } char *name; codeset cs; - bool loaded; // wether we tried loading it before (not wether it's loaded) + bool loaded; // whether we tried loading it before (not whether it's loaded) // managed by the font object - bool slow; // wether this is a proportional font or has other funny characteristics int ascent, descent, width, height; - void set_name (char *name) - { - if (this->name) free (this->name); // let the compiler optimize - this->name = name; - } - - rxvt_font () { name = 0; } - ~rxvt_font () { free (name); }; + void set_name (char *name_); - void clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color); + rxvt_font (); + virtual ~rxvt_font () { free (name); }; virtual void clear () { }; + void clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const; + virtual rxvt_fontprop properties () = 0; - virtual bool load (const rxvt_fontprop &prop) = 0; - virtual bool has_codepoint (uint32_t unicode) = 0; + virtual bool load (const rxvt_fontprop &morph, bool force_prop) = 0; + virtual bool has_char (uint32_t unicode, const rxvt_fontprop *prop, bool &careful) const = 0; virtual void draw (rxvt_drawable &d, int x, int y, const text_t *text, int len, int fg, int bg) = 0; -}; -#define FONT_UNREF(f) do { (f)->clear (); delete (f); } while (0) + void unref () + { + clear (); + delete this; + } +}; struct rxvt_fallback_font; -struct rxvt_fontset { +struct rxvt_fontset +{ char *fontdesc; - rxvt_fontset (rxvt_t r); - ~rxvt_fontset (); + enum { fontCount = 7 }; // must be power-of-two - 1, also has to match RS_fontMask in rxvt.h + enum { firstFont = 2 }; // index of first font in set - rxvt_font *new_font (const char *name, codeset cs); + rxvt_fontset (rxvt_term *term); + ~rxvt_fontset (); bool populate (const char *desc); - int find_font (uint32_t unicode, bool bold = false); + void set_prop (const rxvt_fontprop &prop, bool force_prop) { this->prop = prop; this->force_prop = force_prop; } + int find_font_idx (uint32_t unicode); int find_font (const char *name) const; + bool realize_font (int i); - // font-id's MUST fit into a signed 16 bit integer. rxvt_font *operator [] (int id) const { - return fonts[id]; + return fonts[id >> 1]; } - rxvt_font *base_font () const + int + find_font (unicode_t unicode) { - return fonts[base_id]; + return min ((fontCount << 1) | 1, find_font_idx (unicode)); } private: - rxvt_t r; + rxvt_term *term; + rxvt_fontprop prop; + bool force_prop; simplevec fonts; const rxvt_fallback_font *fallback; - rxvt_fontprop base_prop; - int base_id; + typedef unsigned char pagemap[256]; + vector fmap; - bool realize_font (int i); - void add_fonts (const char *desc); void clear (); + rxvt_font *new_font (const char *name, codeset cs); + void prepare_font (rxvt_font *font, codeset cs); + void add_fonts (const char *desc); + void push_font (rxvt_font *font); }; #endif /* _DEFAULTFONT_H_ */