[gtkmm] problems using pangomm to render text on a drawable (1.3.21)



in converting one of my apps to gtkmm2 (using v1.3.21), i've been
trying to use pango for font rendering but haven't had much luck.  the
following program: 

#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <pangomm/layout.h>

int
main(int argc, char* argv[])
{
    Gtk::Main kit(argc, argv);

    Gtk::Window win(Gtk::WINDOW_TOPLEVEL);

    win.set_default_size(500, 100);
    win.show_all();
	
    Glib::RefPtr<Pango::Context> pContext = Pango::Context::create();
    pContext->set_font_description(Pango::FontDescription("fixed"));
    Glib::RefPtr<Pango::Layout> pLayout = Pango::Layout::create(pContext);
    pLayout->set_text("Pango Test Application");

    Glib::RefPtr<Gdk::GC> gc = win.get_style()->get_black_gc();
    win.get_window()->draw_layout(gc, 10, 10, pLayout);
	
    kit.run();
}

compiled with 

    g++ -g -o pangotest pango.cpp `pkg-config gtkmm-2.0 --libs --cflags`

aborts when run with the following errors:

** (pangotest:5101): CRITICAL **: file pango-fontmap.c: line 125
(pango_font_map_load_fontset): assertion `fontmap != NULL' failed

** (pangotest:5101): CRITICAL **: file pango-fontset.c: line 84
(pango_fontset_get_font): assertion `fontset != NULL' failed

[prev line repeated many times]

(pangotest:5102): GLib-GObject-CRITICAL **: file gobject.c: line 1307
(g_object_unref): assertion `G_IS_OBJECT (object)' failed

[prev line repeated many times]

what am i doing wrong?  i haven't been able to find any example code
that uses pangomm...they all "cheat" and use C functions to create the
pango layout. 

thanks.

patrick



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