Re: Example for doing gtk draw_string on a drawing area (newbie)

Cameron Kerr said:
According to the error message, its supposed to be of type
Gtk::Gdk::Font, but how do I specify it?

$font = Gtk::Gdk::Font->load ($font_spec);

where $font_spec is an X font specifier string, such as "fixed" or "7x14" or
"-*-helvetica-medium-*-*--*-*-*-*-*-*-*", etc.

Gtk+ 2.x is readily available these days, and we're working on perl bindings
for it (just about ready for release, actually), so you may wish to use gtk2
instead.  in gtk2, this sort of thing is easier and more powerful, using pango

  $layout = $drawing_area->create_pango_layout ($some_text);
  $font_desc = Gtk2::Pango::FontDescription->new_from_string ("sans");
  $layout->set_font_description ($font_desc);
  $drawing_area->window->draw_layout ($gc, $x_-f_left, $y_of_bottom, $layout);

there's some working sample code that does text drawing on a drawing area in
the gtk2-perl-xs respository under gtk2-perl-xs/Gtk2/examples/

muppet <scott at asofyet dot org>

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