Reputation: 387
I'm starting to use Genie with Pango + Gtk.
I want to change the text style of a label with Pango, but both modify_font and override_font are deprecated.
What is the alternative for this code using Pango?
uses Gtk
uses Pango
init
Gtk.init (ref args)
var TestGtk = new Ventana()
TestGtk.show_all()
Gtk.main()
class Ventana : Window
init
title = "Test Genie + Pango"
default_width = 500
default_height = 200
window_position = WindowPosition.CENTER
destroy.connect(Gtk.main_quit)
var etiqueta = new Label("Hola Genie + Pango")
var fontdesc = new Pango.FontDescription()
fontdesc.set_family("Purisa")
fontdesc.set_size((int)(24 * Pango.SCALE))
//etiqueta.modify_font(fontdesc) // funciona pero OBSOLETO desde v 3.0
etiqueta.override_font(fontdesc) // funciona pero OBSOLETO desde v 3.16
add (etiqueta)
Thank you
Upvotes: 2
Views: 2210
Reputation: 11588
For a GtkLabel, you use gtk_label_set_attributes()
and using an attribute list instead of a font descriptor. You can either turn your existing font descriptor into an attribute list or use a single font descriptor attribute with the existing font descriptor.
As for other widgets, some widgets allow you to specify a Pango attribute list or font descriptor directly; check their documentation. For all others, use CSS.
Upvotes: 1