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"))
If you want to using it as a preview to your own app, install the font and uncomment the last line (provide the right name). If you want to use it as custom font for final release, i suggest you package with the font and make a script to install it. A little note, (in C), ".modify_font" deprecated since Gtk 3.0, use .override_font instead.
来源:https://stackoverflow.com/questions/16598777/how-to-use-a-custom-font-in-a-gtk-app