Copying widget layout into a cairo layout


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.");



  g_object_unref (layout);

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

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

JPEG image

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