--- deliantra/Deliantra-Client/Client.xs 2006/04/09 00:06:09 1.5 +++ deliantra/Deliantra-Client/Client.xs 2006/04/09 01:35:40 1.9 @@ -18,8 +18,7 @@ BOOT: { fontmap = pango_ft2_font_map_new (); - context = pango_context_new (); - pango_context_set_font_map (context, fontmap); + context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); } char * @@ -37,7 +36,19 @@ RETVAL void -font_render (SV *text_, int height) +set_font (char *file) + CODE: +{ + int count; + FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); + FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ + PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern); + FcPatternDestroy (pattern); + pango_context_set_font_description (context, font); +} + +void +font_render (SV *text_, int height = 10) PPCODE: { STRLEN textlen; @@ -47,14 +58,15 @@ FT_Bitmap bitmap; PangoLayout *layout; PangoFontDescription *font = pango_context_get_font_description (context); - pango_font_description_set_absolute_size (font, 40 * PANGO_SCALE); + pango_font_description_set_absolute_size (font, height * PANGO_SCALE); layout = pango_layout_new (context); pango_layout_set_markup (layout, text, textlen); pango_layout_get_pixel_size (layout, &w, &h); w = (w + 3) & ~3; - if (h == 0) h = 1; + if (!w) w = 1; + if (!h) h = 1; retval = newSV (w * h); SvPOK_only (retval);