How to change font size in GTK?

Is there an easy way to change the font size of text elements in GTK? Right now, the best thing I can do is to do set_markupon a shortcut with something stupid:

lbl.set_markup("<span font_desc='Tahoma 5.4'>%s</span>" % text)

This 1) requires me to install the font, 2) it seems like a lot of overhead (it is necessary to parse the markup), and 3) it will make it annoying to change the font size of the buttons, etc. Is there a better way?

+3
source share
2 answers

, gtkrc ( google, "gtkrc font" ubuntu, gtkrc):

style "font"
{
font_name = "Corbel 8"
}
widget_class "*" style "font"
gtk-font-name = "Corbel 8"

( , )

, , , , . , , widget_class.

YMMV , AFAIK - , GTK , .

+7

C :

gtk_widget_modify_font(lbl, pango_font_description_from_string("Tahoma 5.4"));

PyGTK , - :

pangoFont = pango.FontDescription("Tahoma 5.4")
lbl.modify_font(pangoFont)
+3

Source: https://habr.com/ru/post/1715032/


All Articles