#include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { // application QApplication app(argc,argv); // directory of test font files const QString appdir(QCoreApplication::applicationDirPath()), fontdir(QCoreApplication::applicationDirPath()+QStringLiteral("/../../")); // regular and bold font files const int reguid = QFontDatabase::addApplicationFont(fontdir+QStringLiteral("NotoSans-Regular.ttf")), boldid = QFontDatabase::addApplicationFont(fontdir+QStringLiteral("NotoSans-Bold.ttf")); if(reguid==-1 || boldid==-1) { (void)QMessageBox::critical(nullptr,QStringLiteral("Error"),QStringLiteral("Could not open font file")); return 1; } // regular and bold fonts QFont regufont("Noto Sans",72), boldfont("Noto Sans Bold",72); regufont.setHintingPreference(QFont::PreferFullHinting); boldfont.setHintingPreference(QFont::PreferFullHinting); qDebug() << "regular " << regufont.toString(); qDebug() << "bold " << boldfont.toString(); // fonts used in labels QLabel *regulabel = new QLabel(QStringLiteral("Font regular qwerty")), *boldlabel = new QLabel(QStringLiteral("Font bold qwerty")); regulabel->setFont(regufont); boldlabel->setFont(boldfont); // show labels QWidget widget; QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(regulabel); layout->addWidget(boldlabel); widget.setLayout(layout); widget.show(); return QApplication::exec(); }