--- rxvt-unicode/src/rxvtfont.C 2010/03/30 23:38:02 1.157 +++ rxvt-unicode/src/rxvtfont.C 2010/03/31 22:22:32 1.161 @@ -450,7 +450,7 @@ chrs [1] = NOCHAR; *chrs = cc->c1; - rxvt_font *f1 = fs->get (cc->c1); + rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)]; f1->draw (d, x, y, chrs, width, fg, bg); if (cc->c2 != NOCHAR) @@ -461,7 +461,7 @@ *chrs = cc->c2; rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) ? f1 - : fs->get (cc->c2); + : (*fs)[fs->find_font (cc->c2)]; f2->draw (d, x, y, chrs, width, fg, Color_none); } @@ -484,6 +484,56 @@ } } +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 { @@ -501,7 +551,7 @@ const text_t *text, int len, int fg, int bg); - bool slow; // wether this is a proportional font or has other funny characteristics + bool slow; // whether this is a proportional font or has other funny characteristics XFontStruct *f; bool enc2b, encm; @@ -917,7 +967,7 @@ if (ch == NOCHAR) return false; - /* check wether the character exists in _this_ font. horrible. */ + /* check whether the character exists in _this_ font. horrible. */ XCharStruct *xcs; if (encm) @@ -957,7 +1007,7 @@ if (!prop || prop->width == rxvt_fontprop::unset) return true; - // check wether character overlaps previous/next character + // check whether character overlaps previous/next character int w = xcs->rbearing - xcs->lbearing; int wcw = max (WCWIDTH (unicode), 1); @@ -1588,23 +1638,17 @@ } int -rxvt_fontset::find_font_idx (unicode_t unicode, bool &careful) +rxvt_fontset::find_font_idx (unicode_t unicode) { if (unicode >= 1<<20) return 0; unicode_t hi = unicode >> 8; - if (hi < fmap.size () && fmap[hi]) - { - unsigned char m = (*fmap[hi])[unicode & 0xff]; - - if (m != 0xff) - { - careful = m & 128; - return m & 127; - } - } + if (hi < fmap.size () + && fmap[hi] + && (*fmap[hi])[unicode & 0xff] != 0xff) + return (*fmap[hi])[unicode & 0xff]; unsigned int i; @@ -1627,8 +1671,13 @@ if (f->cs == CS_UNKNOWN) goto next_font; + bool careful; if (f->has_char (unicode, &prop, careful)) - goto found; + { + i = (i << 1) | careful; + + goto found; + } next_font: if (i == fonts.size () - 1) @@ -1691,11 +1740,10 @@ /* we must return SOME font */ i = 0; - careful = false; found: // found a font, cache it - if (i < 127) + if (i < 255) { while (hi >= fmap.size ()) fmap.push_back (0); @@ -1706,7 +1754,7 @@ memset (fmap[hi], 0xff, sizeof (pagemap)); } - (*fmap[hi])[unicode & 0xff] = i | (careful ? 128 : 0); + (*fmap[hi])[unicode & 0xff] = i; } return i; @@ -1715,9 +1763,6 @@ int rxvt_fontset::find_font (unicode_t unicode) { - bool careful; - int id = find_font_idx (unicode, careful); - - return min (fontCount, id) | (careful ? Careful : 0); + return min ((fontCount << 1) | 1, find_font_idx (unicode)); }