pango_layout_get_pixel_extents crash on Win32



Hello,

I have a problem with pango_layout_get_pixel_extents()
crashing on Win32 with a layout created from FT2 context.

I cannot reproduce the problem myself which complicates
debugging a bit...  However, I extracted the problem into
a relatively minimal program that my users confirm crashing
the same way as the application -- it's attached at the end.

The program works flawlessly on Unix/X11.

It crashes on Windows XP -- for some people -- on the
pango_layout_get_pixel_extents() line (marked Bang!) with no
run-time errors messages before.

The users who report the crashes generally run the latest
(or about) version of GladeWin32 runtime if it matters.

Is there something obviously wrong in the program?
What kind of problem it can be that it just crashes without
any failed assertion message?

Yeti

--
http://gwyddion.net/


============================================================================
#include <pango/pangoft2.h>
#include <gtk/gtk.h>

PangoFontMap *ft2_font_map;

gboolean
try_layout(gpointer user_data)
{
    GtkWidget *widget = GTK_WIDGET(user_data);
    PangoFontDescription *fontdesc;
    PangoContext *context, *ft2_context;
    PangoRectangle rect;
    PangoLayout *layout;

    ft2_context
        = pango_ft2_font_map_create_context(PANGO_FT2_FONT_MAP(ft2_font_map));

    context = gtk_widget_get_pango_context(widget);
    fontdesc = pango_context_get_font_description(context);
    fontdesc = pango_font_description_copy_static(fontdesc);
    pango_font_description_set_size(fontdesc, 12*PANGO_SCALE);
    pango_context_set_font_description(ft2_context, fontdesc);
    pango_font_description_free(fontdesc);

    layout = pango_layout_new(ft2_context);
    pango_layout_set_width(layout, -1);
    pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);

    pango_layout_set_text(layout, "1", -1);
    /* Bang! */
    pango_layout_get_pixel_extents(layout, NULL, &rect);

    gtk_widget_destroy(widget);

    return FALSE;
}

int
main(int argc, char *argv[])
{
    GtkWidget *widget;

    gtk_init(&argc, &argv);

    /* FT2 font map */
    ft2_font_map = pango_ft2_font_map_new();
    pango_ft2_font_map_set_resolution(PANGO_FT2_FONT_MAP(ft2_font_map), 72, 72);

    /* Create some widget */
    widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(widget), 300, 300);
    g_signal_connect(widget, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    gtk_widget_show_all(widget);

    /* After the widget is realized, do not put it into the callback... */
    g_timeout_add(500, try_layout, widget);

    gtk_main();

    return 0;
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]