Font changes not aplying
-
Did you check that the application can find it ? QFontDatabase comes to mind for that.
-
@SGaist said:
QFontDatabase
So What I did using QFontDatabase:
QFontDatabase::addApplicationFont( "/usr/share/fonts/truetype/Open_Sans/OpenSans-Regular.ttf");
But nothing happened, so I checked that the font was currently installed using
fc-list
And indeed, it was installed but I don't know why not recognized by Qt.
-
Did you check the returned id from addApplicationFont ?
-
@SGaist More or less, what I did to test that the font is working is this:
int id = QFontDatabase::addApplicationFont( "/usr/share/fonts/truetype/Open_Sans/OpenSans-Regular.ttf"); QString family = QFontDatabase::applicationFontFamilies(id).at(0); QFont monospace(family); qApp->setFont(monospace);
But it doesn't work.... No idea what can be happening
-
What is the value of id ?
-
Use the debugger then or a dummy widget.
-
@cxam said:
hi, just small question.
Since addApplicationFont dont return -1 for error, i wonder if he need to NEW the font as they talk about here
https://forum.qt.io/topic/23875/how-to-use-qfontdatabase-addapplicationfont
?