fname = rxvt_temp_buf<wchar_t *> (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])));
}
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)
*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);
}
}
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;
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)
/* 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);
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<int> (fontCount, id) | (careful ? Careful : 0);
-}
-
{
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 ();
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:
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_ */