--- rxvt-unicode/src/rxvtfont.h 2007/10/18 09:11:43 1.24 +++ rxvt-unicode/src/rxvtfont.h 2010/05/23 00:08:53 1.38 @@ -15,7 +15,8 @@ struct rxvt_term; -struct rxvt_fontprop { +struct rxvt_fontprop +{ enum { unset = -1, medium = 100, bold = 200, @@ -25,20 +26,21 @@ int weight, slant; }; -struct rxvt_font { +struct rxvt_font +{ // managed by the fontset 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 int ascent, descent, width, height; - void set_name (char *name); + void set_name (char *name_); rxvt_font (); virtual ~rxvt_font () { free (name); }; @@ -56,28 +58,41 @@ 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; + 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_fontset (rxvt_term *term); ~rxvt_fontset (); bool populate (const char *desc); void set_prop (const rxvt_fontprop &prop, bool force_prop) { this->prop = prop; this->force_prop = force_prop; } - int find_font (uint32_t unicode); + 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, and within 0..255 rxvt_font *operator [] (int id) const { - return fonts[id & 0x7f]; + return fonts[id >> 1]; + } + + int + find_font (unicode_t unicode) + { + return min ((fontCount << 1) | 1, find_font_idx (unicode)); } private: @@ -92,7 +107,9 @@ 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_ */