Windows: Freetype: Load fonts from the user locations
Since Windows 10 update 1809 it is possible to install fonts as a user so they are only available for use by the user and not on the system. So this location in the registry needs to be checked as well when looking for available fonts. Fixes: QTBUG-73241 Change-Id: I5d808e38b80dde8189fe8c549a6524bd559e30c7 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
797f686ea4
commit
a34077ceac
@ -115,30 +115,33 @@ static FontKeys &fontKeys()
|
|||||||
{
|
{
|
||||||
static FontKeys result;
|
static FontKeys result;
|
||||||
if (result.isEmpty()) {
|
if (result.isEmpty()) {
|
||||||
const QSettings fontRegistry(QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"),
|
const QStringList keys = { QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"),
|
||||||
QSettings::NativeFormat);
|
QStringLiteral("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts") };
|
||||||
const QStringList allKeys = fontRegistry.allKeys();
|
for (const auto key : keys) {
|
||||||
const QString trueType = QStringLiteral("(TrueType)");
|
const QSettings fontRegistry(key, QSettings::NativeFormat);
|
||||||
|
const QStringList allKeys = fontRegistry.allKeys();
|
||||||
|
const QString trueType = QStringLiteral("(TrueType)");
|
||||||
#if QT_CONFIG(regularexpression)
|
#if QT_CONFIG(regularexpression)
|
||||||
const QRegularExpression sizeListMatch(QStringLiteral("\\s(\\d+,)+\\d+"));
|
const QRegularExpression sizeListMatch(QStringLiteral("\\s(\\d+,)+\\d+"));
|
||||||
#else
|
#else
|
||||||
const QRegExp sizeListMatch(QLatin1String("\\s(\\d+,)+\\d+"));
|
const QRegExp sizeListMatch(QLatin1String("\\s(\\d+,)+\\d+"));
|
||||||
#endif
|
#endif
|
||||||
Q_ASSERT(sizeListMatch.isValid());
|
Q_ASSERT(sizeListMatch.isValid());
|
||||||
const int size = allKeys.size();
|
const int size = allKeys.size();
|
||||||
result.reserve(size);
|
result.reserve(result.size() + size);
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
FontKey fontKey;
|
FontKey fontKey;
|
||||||
const QString ®istryFontKey = allKeys.at(i);
|
const QString ®istryFontKey = allKeys.at(i);
|
||||||
fontKey.fileName = fontRegistry.value(registryFontKey).toString();
|
fontKey.fileName = fontRegistry.value(registryFontKey).toString();
|
||||||
QString realKey = registryFontKey;
|
QString realKey = registryFontKey;
|
||||||
realKey.remove(trueType);
|
realKey.remove(trueType);
|
||||||
realKey.remove(sizeListMatch);
|
realKey.remove(sizeListMatch);
|
||||||
const auto fontNames = QStringRef(&realKey).trimmed().split(QLatin1Char('&'));
|
const auto fontNames = QStringRef(&realKey).trimmed().split(QLatin1Char('&'));
|
||||||
fontKey.fontNames.reserve(fontNames.size());
|
fontKey.fontNames.reserve(fontNames.size());
|
||||||
for (const QStringRef &fontName : fontNames)
|
for (const QStringRef &fontName : fontNames)
|
||||||
fontKey.fontNames.append(fontName.trimmed().toString());
|
fontKey.fontNames.append(fontName.trimmed().toString());
|
||||||
result.append(fontKey);
|
result.append(fontKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user