Text on QLabel with initalic will be changed to be oblong after addApplicationFont
-
@Mihan Do you mean the "italic" text becomes "upright" or all the characters become a box-like glyph (e.g. "▯") on-screen?
-
@Mihan Do you mean the "italic" text becomes "upright" or all the characters become a box-like glyph (e.g. "▯") on-screen?
-
@Mihan said in Text on QLabel with initalic will be changed to be oblong after addApplicationFont:
@ChrisW67 "italic" will become "▯▯▯▯" on screen;
Then it is likely that the font you have added to the database is a better match for the font family that the label is using, and the characters you are using in the label are not present in the new font.
What is the font family that the label is using, the characters in the string, and the new font you add?
-
@Mihan said in Text on QLabel with initalic will be changed to be oblong after addApplicationFont:
@ChrisW67 "italic" will become "▯▯▯▯" on screen;
Then it is likely that the font you have added to the database is a better match for the font family that the label is using, and the characters you are using in the label are not present in the new font.
What is the font family that the label is using, the characters in the string, and the new font you add?
-
So you are saying that this fails:
#include <QApplication> #include <QLabel> #include <QFontDatabase> #include <QDebug> int main(int argc, char *argv[]) { QApplication a(argc, argv); // Use you own path to the font here QFontDatabase::addApplicationFont("/usr/share/fonts-font-awesome/fonts/FontAwesome.otf"); QFont font("Sans Serif"); font.setItalic(true); QLabel label("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n" "tempor incididunt ut labore et dolore magna aliqua. "); label.setFont(font); label.show(); return a.exec(); }
-
So you are saying that this fails:
#include <QApplication> #include <QLabel> #include <QFontDatabase> #include <QDebug> int main(int argc, char *argv[]) { QApplication a(argc, argv); // Use you own path to the font here QFontDatabase::addApplicationFont("/usr/share/fonts-font-awesome/fonts/FontAwesome.otf"); QFont font("Sans Serif"); font.setItalic(true); QLabel label("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n" "tempor incididunt ut labore et dolore magna aliqua. "); label.setFont(font); label.show(); return a.exec(); }
Not really
the font will be set in ui file but it doesn't seem to really set the font name:
//ui_CQuickProbe.h void setupUi(QDialog *CQuickProbe) { label = new QLabel(CQuickProbe); label->setObjectName(QStringLiteral("label")); QFont font; // HERE font.setPointSize(13); font.setItalic(true); label->setFont(font); label->setTextFormat(Qt::PlainText); }
the font in ui designer:
but it will be set to "Sans Serif" after this dialog shown ( I get thefont().family()
).BTW, The project is compiled for embeded linux.