Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a custom font in Qt

Tags:

fonts

qt

There's anyway to add a custom font (Such as Console Font) to Qt? How? And how do we set it to a Text Editor (QPlainTextEdit, QTextEdit, etc)?

Thanks

like image 504
Kazuma Avatar asked Feb 02 '23 10:02

Kazuma


1 Answers

Qt uses your window system as a font provider. You can find out all the fonts available by using the QFontDatabase class. Anyway, it is possible to add a specific custom font for your application to use using QFontDatabase::addApplicationFont from C++ (available under X11 only if fontconfig is available) or using the FontLoader component in QML.

For QTextEdit you can use this and for QPlainTextEdit you might try the font property.

like image 88
Luca Carlon Avatar answered Feb 09 '23 04:02

Luca Carlon