+ /* This function is called for each font in the theme file. */
+ /* It returns a pointer to a RrFont struct after filling it. */
+ RrFont *out;
+ FcPattern *pat;
+ gint tint;
+ gchar *sval;
+ gint ival;
+
+ if (!(pat = XftNameParse(fontstring)))
+ return NULL;
+
+ out = g_new(RrFont, 1);
+ out->inst = inst;
+ out->font_desc = pango_font_description_new();
+ out->layout = pango_layout_new(inst->pango);
+
+ /* get the data from the parsed xft string */
+
+ /* get the family */
+ if (FcPatternGetString(pat, "family", 0,
+ (FcChar8**)&sval) == FcResultMatch)
+ pango_font_description_set_family(out->font_desc, sval);
+
+ /* get the weight */
+ if (FcPatternGetInteger(pat, "weight", 0, &ival) == FcResultMatch) {
+ if (ival == FC_WEIGHT_LIGHT)
+ pango_font_description_set_weight(out->font_desc,
+ PANGO_WEIGHT_LIGHT);
+ else if (ival == FC_WEIGHT_DEMIBOLD)
+ pango_font_description_set_weight(out->font_desc,
+ PANGO_WEIGHT_SEMIBOLD);
+ else if (ival == FC_WEIGHT_BOLD)
+ pango_font_description_set_weight(out->font_desc,
+ PANGO_WEIGHT_BOLD);
+ else if (ival == FC_WEIGHT_BLACK)
+ pango_font_description_set_weight(out->font_desc,
+ PANGO_WEIGHT_ULTRABOLD);
+ }
+
+ /* get the style/slant */
+ if (FcPatternGetInteger(pat, "slant", 0, &ival) == FcResultMatch) {
+ if (ival == FC_SLANT_ITALIC)
+ pango_font_description_set_style(out->font_desc,
+ PANGO_STYLE_ITALIC);
+ else if (ival == FC_SLANT_OBLIQUE)
+ pango_font_description_set_style(out->font_desc,
+ PANGO_STYLE_OBLIQUE);
+ }
+
+ /* get the size */
+ if (FcPatternGetInteger(pat, "size", 0, &ival) == FcResultMatch)
+ pango_font_description_set_size(out->font_desc, ival * PANGO_SCALE);
+ else if (FcPatternGetInteger(pat, "pixelsize", 0, &ival) == FcResultMatch)
+ pango_font_description_set_absolute_size(out->font_desc,
+ ival * PANGO_SCALE);
+ else
+ pango_font_description_set_size(out->font_desc, 8 * PANGO_SCALE);
+
+ if (FcPatternGetBool(pat, OB_SHADOW, 0, &out->shadow) != FcResultMatch)
+ out->shadow = FALSE;
+
+ if (FcPatternGetInteger(pat, OB_SHADOW_OFFSET, 0, &out->offset) !=
+ FcResultMatch)
+ out->offset = 1;
+
+ if (FcPatternGetInteger(pat, OB_SHADOW_ALPHA, 0, &tint) != FcResultMatch)
+ tint = 25;
+ if (tint > 100) tint = 100;
+ else if (tint < -100) tint = -100;
+ out->tint = tint;
+
+ /* 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);
+
+ return out;