protected int cur_el;
protected double distortion_factor;
- protected Pango.FontDescription[] fontdesc_cache;
+ protected Pango.Layout[] pango_cache;
// Number of items shown before and after the focus element
protected int focus_first;
for (int i = 0; i < 300; ++i)
list[i] = "Lorem Ipsum %d".printf(i);
- fontdesc_cache = new Pango.FontDescription[30];
+ pango_cache = new Pango.Layout[30];
for (int i = 0; i < 30; ++i)
- fontdesc_cache[i] = null;
+ pango_cache[i] = null;
cur_el = 0;
focus_centre = 0;
0, y0, allocation.width, y1-y0);
}
- var layout = create_pango_layout(list[idx]);
-
+ // TODO: cache pango contexts instead of fontdescs
int size = (y1-y0)*80/100;
if (size <= 0) size = 1;
- if (size >= fontdesc_cache.length) size = fontdesc_cache.length - 1;
- if (fontdesc_cache[size] == null)
+ if (size >= pango_cache.length) size = pango_cache.length - 1;
+ if (pango_cache[size] == null)
{
- fontdesc_cache[size] = style.font_desc.copy();
- fontdesc_cache[size].set_absolute_size(size*Pango.SCALE);
+ var fd = style.font_desc.copy();
+ fd.set_absolute_size(size*Pango.SCALE);
+ var pc = create_pango_context();
+ pc.set_font_description(fd);
+ pango_cache[size] = new Pango.Layout(pc);
}
- layout.set_font_description(fontdesc_cache[size]);
+ pango_cache[size].set_text(list[idx], -1);
+ var layout = pango_cache[size];
//stderr.printf("AZAZA %p\n", layout.get_attributes());
//var attrlist = layout.get_attributes().copy();
//stderr.printf("AL %p\n", attrlist);