summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-06-03 14:32:30 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-17 21:55:20 +0000
commit469b13916983aff4625657eecbb7d2399cac901d (patch)
treec6b798748960217095477b66111f283bf464a789 /src/plugins/platforms/windows/qwindowsfontdatabase.cpp
parentd1a4c4f3c9565629b0a634729fcf8ce1ebf0d958 (diff)
Register fonts with their given style name
Instead of guessing which styles we have available (always bold/italic) register the ones we actually find. Change-Id: I57380d0417411456a3037f8769440e7b43517e0e Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsfontdatabase.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
index 5e75cbf37e..6f236aa588 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
@@ -944,7 +944,7 @@ error:
return i18n_name;
}
-static bool addFontToDatabase(const QString &familyName, uchar charSet,
+static bool addFontToDatabase(const QString &familyName, const QString &styleName, uchar charSet,
const TEXTMETRIC *textmetric,
const FONTSIGNATURE *signature,
int type,
@@ -1012,16 +1012,16 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
writingSystems.setSupported(ws);
}
- QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, weight,
+ QPlatformFontDatabase::registerFont(familyName, styleName, foundryName, weight,
style, stretch, antialias, scalable, size, fixed, writingSystems, 0);
// add fonts windows can generate for us:
- if (weight <= QFont::DemiBold)
+ if (weight <= QFont::DemiBold && styleName.isEmpty())
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold,
style, stretch, antialias, scalable, size, fixed, writingSystems, 0);
- if (style != QFont::StyleItalic)
+ if (style != QFont::StyleItalic && styleName.isEmpty())
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, weight,
QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, 0);
- if (weight <= QFont::DemiBold && style != QFont::StyleItalic)
+ if (weight <= QFont::DemiBold && style != QFont::StyleItalic && styleName.isEmpty())
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold,
QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, 0);
@@ -1036,6 +1036,7 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t
{
const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
+ const QString styleName = QString::fromWCharArray(f->elfStyle);
const uchar charSet = f->elfLogFont.lfCharSet;
const bool registerAlias = bool(lParam);
@@ -1045,7 +1046,7 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t
const FONTSIGNATURE *signature = Q_NULLPTR;
if (type & TRUETYPE_FONTTYPE)
signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(textmetric)->ntmFontSig;
- addFontToDatabase(familyName, charSet, textmetric, signature, type, registerAlias);
+ addFontToDatabase(familyName, styleName, charSet, textmetric, signature, type, registerAlias);
// keep on enumerating
return 1;
@@ -1456,6 +1457,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
// Memory fonts won't show up in enumeration, so do add them the hard way.
for (int j = 0; j < families.count(); ++j) {
const QString familyName = families.at(j).name;
+ const QString styleName = families.at(j).style;
familyNames << familyName;
HDC hdc = GetDC(0);
LOGFONT lf;
@@ -1468,7 +1470,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
TEXTMETRIC textMetrics;
GetTextMetrics(hdc, &textMetrics);
- addFontToDatabase(familyName, lf.lfCharSet, &textMetrics, &signatures.at(j),
+ addFontToDatabase(familyName, styleName, lf.lfCharSet, &textMetrics, &signatures.at(j),
TRUETYPE_FONTTYPE, true);
SelectObject(hdc, oldobj);