[Python] How to use a custom font in a GTK app

Discussão em 'Python' iniciado por Stack, Fevereiro 15, 2025.

  1. Stack

    Stack Membro Participativo

    I have a font file /path/to/app/fonts/custom-font.ttf and I want to use it. How do you import a custom TTF for use in a GTK+3.0 app?

    from gi.repository import Gtk, Pango

    # ...

    lbl = Gtk.Label()
    lbl.modify_font(Pango.FontDescription("sans 48"))
    # lbl.modify_font(Pango.FontDescription("custom-font 48"))

    Continue reading...

Compartilhe esta Página