当前位置:网站首页>QT add external font ttf

QT add external font ttf

2022-04-23 18:15:00 Talent、me

Get local font

#include <QFontDatabase>

QFontDatabase fontbase;
// Traverse local font 
foreach (const QString &fontfamily, fontbase.families()) {
    
    qDebug()<<fontfamily;
}

Set the font used by the program

//"DejaVu Sans Mono" This is one of the word libraries found by the last traversal 
QFont font("DejaVu Sans Mono");
QApplication::setFont(font);

Add external font ttf To the system font

Because my program is in arm Executed under , So first we need to find font The path where the font is stored .
The path of my development board is /usr/lib/fonts . Put the word library under this path and give permission :chmod 777 xxx.ttf

following kacstOne It's my transplanted font
 Insert picture description here

版权声明
本文为[Talent、me]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210610471764.html