fname = rxvt_temp_buf<wchar_t *> (len);
for (int i = 0; i < len; i++)
{
- rxvt_font *f = (*fs)[fs->find_font (chr[i])];
+ rxvt_font *f = fs->get (chr[i]);
fname[i] = rxvt_utf8towcs (f->name);
max_it (width, wcswidth (fname[i], wcslen (fname[i])));
}
delete fontset[0];
fontset[0] = fs;
- prop = (*fs)[1]->properties ();
+ prop = fs->get (0, 1)->properties ();
prop.height += lineSpace;
prop.width += letterSpace;
chrs [1] = NOCHAR;
*chrs = cc->c1;
- rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)];
+ rxvt_font *f1 = fs->get (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)[fs->find_font (cc->c2)];
+ : fs->get (cc->c2);
f2->draw (d, x, y, chrs, width, fg, Color_none);
}
}
int
-rxvt_fontset::find_font (unicode_t unicode)
+rxvt_fontset::find_font_ (unicode_t unicode)
{
if (unicode >= 1<<20)
return 0;
return i;
}
+int
+rxvt_fontset::find_font (unicode_t unicode)
+{
+ return min<int> (fontCount, find_font_ (unicode));
+}
+
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); // same as find_font, but does not limit index
int find_font (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
+ rxvt_font *get (uint32_t unicode, int id = fontCount)
{
- return fonts[id & fontCount];
+ id &= fontCount;
+
+ return fonts[id == fontCount ? find_font_ (unicode) : id];
}
private:
/*
* Actually do the drawing of the string here
*/
- rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)];
+ rxvt_font *font = fontset [GET_STYLE (rend)]->get (*text, GET_FONT (rend));
if (expect_true (have_bg && back == Color_bg))
{