Re: Copying widget layout into a cairo layout

Try copying setting the font description of the label on your PangoContext. widget->style->font_desc.

On 06/11/2009 08:33 AM, Zoltan Boszormenyi wrote:
Zoltan Boszormenyi írta:

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

The following code also doesn't work, I get the same large font
for my GtkScrollLabel that my previously attached screenshot showed:

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

Is there and easy way to render the text in the same size as
GtkLabel's default?

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

gtk-list mailing list
gtk-list gnome org

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