Font styles issues in QFontDatabase
-
When I am generating style lists for my font picking widget, I get localised strings,
QStringList familyBuf = dispSettings->fdb.families(QFontDatabase::Latin); for (int i = (familyBuf.length() - 1); i >= 0; i--) if (!dispSettings->fdb.isPrivateFamily(familyBuf.at(i))) if (dispSettings->fdb.isSmoothlyScalable(familyBuf.at(i))) if (QFontInfo(QFont(familyBuf[i])).family() == familyBuf.at(i)) { QString buf = familyBuf.at(i); fontFamilies.append(buf); stylesPack.insert(std::make_pair(buf, dispSettings->fdb.styles(buf)));
but when I am trying to get current style from font via QFontInfo+QFontDatabase, to generate initial GUI state, I suddenly recieve non-localized style string.
currStyle = dispSettings->fdb.styleString(fontInfo);
In Windows 7+ Qt5.7 QFontDatabase generated non-localized font strings, so there was no issues. How do I work around this mismatch in the Qt5.15+?
-
Hi
Is this on win 7 + Qt5.15 ? -
Hi
Ok so its either a bug (regression) or some changes in QFontInfo.
I could not locate any change log for QFontInfo but maybe others have an idea. -
-
It is worse in fact
QFontDatabase::styleString(const QFontInfo &fontInfo) //"Normal"
mismatch
QStringList QFontDatabase::styles(const QString &family) //"Обычный", "Полужирный"
so this class essentially breaks its own logic. Also default font keeps those localized stylestring even after me giving up localization via
QLocale::setDefault(QLocale::English);
std::map<QString, QStringList> stylesPack