Re: Copying widget layout into a cairo layout

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

 



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:>> 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>>>> 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> (GTK_WIDGET(label)));>    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@xxxxxxxxx> http://mail.gnome.org/mailman/listinfo/gtk-list>_______________________________________________gtk-list mailing listgtk-list@xxxxxxxxxxxxx://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