From e6b35b92a3edebccfbe42f1e1d3f9c0dbacfc74a Mon Sep 17 00:00:00 2001 From: sf-exg Date: Wed, 31 Mar 2010 21:52:05 +0000 Subject: [PATCH] First incomplete stab at changing font index logic. --- src/rxvtfont.C | 59 +++++++++++++++++++++++++++++++++++++++++++++++++- src/rxvtfont.h | 2 ++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/rxvtfont.C b/src/rxvtfont.C index 42fa49a2..39b678e0 100644 --- a/src/rxvtfont.C +++ b/src/rxvtfont.C @@ -484,6 +484,56 @@ rxvt_font_default::draw (rxvt_drawable &d, int x, int y, } } +struct rxvt_font_meta : rxvt_font { + struct rxvt_fontset *fs; + + rxvt_font_meta (rxvt_fontset *fs) + : rxvt_font () + { + this->fs = fs; + } + + rxvt_fontprop properties () + { + rxvt_fontprop p; + + p.width = p.height = 1; + p.ascent = rxvt_fontprop::unset; + p.weight = rxvt_fontprop::medium; + p.slant = rxvt_fontprop::roman; + + return p; + } + + bool load (const rxvt_fontprop &prop, bool force_prop) + { + width = 1; height = 1; + ascent = 1; descent = 0; + + set_name (strdup ("built-in meta font")); + + return true; + } + + bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const + { + return false; + } + + void draw (rxvt_drawable &d, int x, int y, + const text_t *text, int len, + int fg, int bg) + { + while (len--) + { + int fid = fs->find_font_idx (*text); + (*fs)[fid]->draw (d, x, y, text, 1, fg, bg); + ++text; + x += term->fwidth; + } + } +}; + ///////////////////////////////////////////////////////////////////////////// struct rxvt_font_x11 : rxvt_font { @@ -1588,7 +1638,7 @@ rxvt_fontset::find_font (const char *name) const } int -rxvt_fontset::find_font (unicode_t unicode) +rxvt_fontset::find_font_idx (unicode_t unicode) { if (unicode >= 1<<20) return 0; @@ -1711,3 +1761,10 @@ found: return i; } +int +rxvt_fontset::find_font (unicode_t unicode) +{ + int id = find_font_idx (unicode); + + return min (fontCount, id & 127) | (id & 128 ? Careful : 0); +} diff --git a/src/rxvtfont.h b/src/rxvtfont.h index 78276b52..92711e6b 100644 --- a/src/rxvtfont.h +++ b/src/rxvtfont.h @@ -69,12 +69,14 @@ struct rxvt_fontset char *fontdesc; enum { fontCount = 127 }; // must be power-of-two - 1, also has to match RS_fontMask in rxvt.h + enum { Careful = fontCount + 1 }; 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_idx (uint32_t unicode); int find_font (uint32_t unicode); int find_font (const char *name) const; bool realize_font (int i); -- 2.34.1