+ RrFont *out;
+ PangoWeight pweight;
+ PangoStyle pstyle;
+
+ out = g_new(RrFont, 1);
+ out->inst = inst;
+ out->ref = 1;
+ out->font_desc = pango_font_description_new();
+ out->layout = pango_layout_new(inst->pango);
+
+ switch (weight) {
+ case RR_FONTWEIGHT_LIGHT: pweight = PANGO_WEIGHT_LIGHT; break;
+ case RR_FONTWEIGHT_NORMAL: pweight = PANGO_WEIGHT_NORMAL; break;
+ case RR_FONTWEIGHT_SEMIBOLD: pweight = PANGO_WEIGHT_SEMIBOLD; break;
+ case RR_FONTWEIGHT_BOLD: pweight = PANGO_WEIGHT_BOLD; break;
+ case RR_FONTWEIGHT_ULTRABOLD: pweight = PANGO_WEIGHT_ULTRABOLD; break;
+ default: g_assert_not_reached();
+ }
+
+ switch (slant) {
+ case RR_FONTSLANT_NORMAL: pstyle = PANGO_STYLE_NORMAL; break;
+ case RR_FONTSLANT_ITALIC: pstyle = PANGO_STYLE_ITALIC; break;
+ case RR_FONTSLANT_OBLIQUE: pstyle = PANGO_STYLE_OBLIQUE; break;
+ default: g_assert_not_reached();
+ }
+
+ /* setup the font */
+ pango_font_description_set_family(out->font_desc, name);
+ pango_font_description_set_weight(out->font_desc, pweight);
+ pango_font_description_set_style(out->font_desc, pstyle);
+ pango_font_description_set_size(out->font_desc, size * PANGO_SCALE);
+
+ /* setup the layout */
+ pango_layout_set_font_description(out->layout, out->font_desc);
+ pango_layout_set_single_paragraph_mode(out->layout, TRUE);
+ pango_layout_set_ellipsize(out->layout, PANGO_ELLIPSIZE_MIDDLE);
+
+ /* get the ascent and descent */
+ measure_font(inst, out);