Closed JackPieCZ closed 3 years ago
+1. For a temporary workaround, I removed the font-family: {{primaryFont}};
from material.css.template and applied the required font accordingly in the main python script
font_id=QtGui.QFontDatabase.addApplicationFont("path/to/font")
font_family=QtGui.QFontDatabase.applicationFontFamilies(font_id)[0]
app.setFont(QtGui.QFont(font_family))
or just
app.setFont(QtGui.QFont("font name"))
If that font is installed
Hi @JackPieCZ, as @FuturisticGoo says, you must use QFontDatabase
to load fonts from local files.
After that, you can select the font family from apply_stylesheet
with the argument extra
apply_stylesheet(app, theme='dark_blue.xml', extra={'font_family': 'CenturyGothic'})
There is an example in which I use two fonts, one installed on the system and one local.
I'm using Century Gothic font in my script and I would like to use e.g.
dark_blue
theme too. For some reason, theapply_theme
function sets all fonts to Roboto even afterfonts
folderfont-family
inmaterial.css.template
to CenturyGothicadd_fonts
function in__init__.py
So, is there any "normal" way to change the font? If not, is it possible to add that parameter to
apply_theme
function? Thx in advance!