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



Am 03.09.2002 22:12 schrieb(en) Martin Schulze:
Am 03.09.2002 21:05 schrieb(en) Patrick Crosby:
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();
}

I guess you should try:

Glib::RefPtr<Pango::Context> pContext = win.get_pango_context();

or

Glib::RefPtr<Pango::Layout> pLayout = win.create_pango_layout("Pango Test Application");

The output sounds as if some fields of the context were not set.

Further investigations lead to the result that Pango::Context::create()
is malfunctioning. It doesn't initialize the Context object correctly.
This is due to the fact that the generation of PangoContext structures
in pango is only provided by backend specific c functions,
e.g. pango_x_get_context(). These functions are currently not wrapped.

I don't find them very user friendly either because a program aiming
to be platform independant can't know which backend to use. So until
the pango people learn how to write a proper backend infrastructure
(like the one the ggi people use: http://www.ggi-project.org) I
propose to just get rid of Pango::Context::create() and not to
wrap the backend specific stuff. If you want to create a pango
Context, you have to use:

Gtk::Widget::create_pango_context() or Gtk::Widget::get_pango::context()

which automatically chooses the right backend or you must create the
context with an unwrapped c function like:

Glib::wrap(pango_x_get_context())

Regards,

  Martin



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