Copying widget layout into a cairo layout

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

 



Hi,

I need to create a scrolling label widget.
I already succeeded marrying gtklabel and gtkimage,
I use a Cairo surface and created PangoLayout out of it,
I render the label text into the Cairo+Pango layout,
I use the expose method used by GtkImage to display
the pixbuf in the widget, and added a timer so the
pixbuf is scrolled in a double buffered way.

Now, the problem is that the text rendered into the pixbuf
is much larger than the usual widget texts, like on stock
GtkButton and GtkLabel. I attached the screenshot from
my example application.

How can I copy the PangoContext that a plain widget use?
E.g. the following code doesn't seem to work:

=================================
  label->surface = cairo_image_surface_create_for_data(cairo_data,
                        CAIRO_FORMAT_ARGB32, width, height, rowstride);

  label->cairo = cairo_create (label->surface);
  
  label->layout = pango_cairo_create_layout(label->cairo);

  /* This is the layout used by GtkLabel, etc. */
  layout = gtk_widget_create_pango_layout (GTK_WIDGET (label),
                              "This long string gives a good enough
length for any line to have.");

  pango_cairo_context_set_font_options(
            pango_layout_get_context(label->layout),
           
pango_cairo_context_get_font_options(pango_layout_get_context(layout)));

  pango_cairo_update_context(label->cairo,
pango_layout_get_context(layout));
  pango_layout_context_changed(label->layout);

  g_object_unref (layout);
=================================

What is the proper way to get the same font, fontsize, etc. on a Cairo
layout?

Thanks in advance,
Zoltán Böszörményi

JPEG image

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux