Re: Pango Speed
- From: "zitan" <zitan mediasculpt net>
- To: gtk-i18n-list gnome org
- Cc:
- Subject: Re: Pango Speed
- Date: Wed, 5 May 2004 09:40:19 -0400
Ok, my main conclusion in this exercise is that calling pango from the command line causes the overhead. Would this be consistent with the architecture and other users experience? If so I may need to look at something like swig so I can call c functions directly.
I managed to cobble together the code to calculate widths for multiple fonts + text strings given single input strings (comma separated). I also broke up the code into sections which I only call when required (see below). From playing with this I found that only calling layout_font when required saved a little time, but it still basically takes the same amount of time to run this code with one font + text as with 5+. This implies to me that it is the method of calling pango which is giving the overhead.
Thanks, Z.
Functions::
PangoLayout *pl;
PangoContext *context;
PangoFontMap *fontmap;
PangoFontDescription *pfd;
static int init()
{
//Set Context using fontmap
fontmap = pango_ft2_font_map_new ();
pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fontmap), 96, 96);
context = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (fontmap));
pl = pango_layout_new(context);
return 0;
}
static int layout_font(const gchar *font)
{
pfd = pango_font_description_from_string(font);
pango_context_set_font_description(context, pfd);
return 0;
}
static gint char_width_from_layout (const gchar *s)
{
gint width;
pango_layout_set_text(pl, s, -1);
pango_layout_get_pixel_size(pl, &width, NULL);
return width;
}
static int close()
{
g_object_unref(G_OBJECT(pl));
g_object_unref(G_OBJECT(context));
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]