Unsuccessfully adding new font in pyqt5
-
greetings,
I try to add new font in my pyqt5 apps with this code:
I am sure that it has correct file path points to right files. It can load it and add to font_db by succesfully printing font family.
font_db = QtGui.QFontDatabase() for f in ['resources/fonts/GothamNarrowBold.otf', 'resources/fonts/GothamNarrowBook.otf']: font_files = os.path.join(package_dir, f) print(font_files) font_id = font_db.addApplicationFont(font_files) font_family = font_db.applicationFontFamilies(font_id) print(font_family)
but I still get this error message.
qt.qpa.fonts: Populating font family aliases took 103 ms. Replace uses of missing font family "Gotham Narrow Bold" with one that exists to avoid this cost.
What I have missed? Somebody can help me to solve this problem?
thanks in advance.
same question posted here.
-
Are you placing your fonts on a
.qrc
as well, or you are only using the relative path? -
Are you placing your fonts on a
.qrc
as well, or you are only using the relative path?@CristianMaureira said in Unsuccessfully adding new font in pyqt5:
only using the relative path?
Depending what you mean by "relative", note that the OP makes the paths absolute with
font_files = os.path.join(package_dir, f)
. So assuming he has checked in there for the presence of the files.