From bea8660b81eb9ac79d1bf708e5a48fe2c6e770e7 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 30 Mar 2010 23:54:29 +0000 Subject: [PATCH] revert fontidx stupidity --- src/command.C | 2 +- src/main.C | 2 +- src/rxvtfont.C | 42 ++++++++++++++++-------------------------- src/rxvtfont.h | 12 +++--------- src/screen.C | 2 +- 5 files changed, 22 insertions(+), 38 deletions(-) diff --git a/src/command.C b/src/command.C index 986fc7fc..efc6f688 100644 --- a/src/command.C +++ b/src/command.C @@ -200,7 +200,7 @@ rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) fname = rxvt_temp_buf (len); for (int i = 0; i < len; i++) { - rxvt_font *f = fs->get (chr[i]); + rxvt_font *f = (*fs)[fs->find_font (chr[i])]; fname[i] = rxvt_utf8towcs (f->name); max_it (width, wcswidth (fname[i], wcslen (fname[i]))); } diff --git a/src/main.C b/src/main.C index 0c323bc3..c0aefd70 100644 --- a/src/main.C +++ b/src/main.C @@ -690,7 +690,7 @@ rxvt_term::set_fonts () delete fontset[0]; fontset[0] = fs; - prop = fs->get (0, 1)->properties (); + prop = (*fs)[1]->properties (); prop.height += lineSpace; prop.width += letterSpace; diff --git a/src/rxvtfont.C b/src/rxvtfont.C index 9b4815ad..9a38cfc7 100644 --- a/src/rxvtfont.C +++ b/src/rxvtfont.C @@ -450,7 +450,7 @@ rxvt_font_default::draw (rxvt_drawable &d, int x, int y, 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 @@ rxvt_font_default::draw (rxvt_drawable &d, int x, int y, *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); } @@ -1588,23 +1588,17 @@ rxvt_fontset::find_font (const char *name) const } int -rxvt_fontset::find_font_idx (unicode_t unicode, bool &careful) +rxvt_fontset::find_font (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 +1621,14 @@ rxvt_fontset::find_font_idx (unicode_t unicode, bool &careful) if (f->cs == CS_UNKNOWN) goto next_font; + bool careful; if (f->has_char (unicode, &prop, careful)) - goto found; + { + if (careful) + i |= 128; + + goto found; + } next_font: if (i == fonts.size () - 1) @@ -1691,11 +1691,10 @@ rxvt_fontset::find_font_idx (unicode_t unicode, bool &careful) /* 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,18 +1705,9 @@ found: memset (fmap[hi], 0xff, sizeof (pagemap)); } - (*fmap[hi])[unicode & 0xff] = i | (careful ? 128 : 0); + (*fmap[hi])[unicode & 0xff] = i; } return i; } -int -rxvt_fontset::find_font (unicode_t unicode) -{ - bool careful; - int id = find_font_idx (unicode, careful); - - return min (fontCount, id) | (careful ? Careful : 0); -} - diff --git a/src/rxvtfont.h b/src/rxvtfont.h index bb539cdf..ed20a2e1 100644 --- a/src/rxvtfont.h +++ b/src/rxvtfont.h @@ -68,8 +68,7 @@ struct rxvt_fontset { char *fontdesc; - enum { fontCount = 3 }; // must be power-of-two - 1, also has to match RS_fontMask in rxvt.h - enum { Careful = fontCount + 1 }; + enum { fontCount = 127 }; // must be power-of-two - 1, also has to match RS_fontMask in rxvt.h rxvt_fontset (rxvt_term *term); ~rxvt_fontset (); @@ -81,13 +80,9 @@ struct rxvt_fontset bool realize_font (int i); // font-id's MUST fit into a signed 16 bit integer, and within 0..255 - rxvt_font *get (uint32_t unicode, int id = fontCount) + rxvt_font *operator [] (int id) const { - bool dummy; - - id &= fontCount; - - return fonts[id == fontCount ? find_font_idx (unicode, dummy) : id]; + return fonts[id & fontCount]; } private: @@ -103,7 +98,6 @@ private: void clear (); rxvt_font *new_font (const char *name, codeset cs); void add_fonts (const char *desc); - int find_font_idx (uint32_t unicode, bool &careful); // same as find_font, but does not limit index }; #endif /* _DEFAULTFONT_H_ */ diff --git a/src/screen.C b/src/screen.C index 0a204235..8ccba89c 100644 --- a/src/screen.C +++ b/src/screen.C @@ -2379,7 +2379,7 @@ rxvt_term::scr_refresh () NOTHROW /* * Actually do the drawing of the string here */ - rxvt_font *font = fontset [GET_STYLE (rend)]->get (*text, GET_FONT (rend)); + rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; if (expect_true (have_bg && back == Color_bg)) { -- 2.34.1