summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-10-22 17:14:29 +0200
committerKonstantin Ritt <ritt.ks@gmail.com>2014-12-12 06:59:46 +0100
commit517da68893be9e6d97c7993922c573de9560604d (patch)
tree9da6027604c97023fd6cacc3114c2f2fd43dd26f /src/plugins/platforms/windows/qwindowsfontdatabase.cpp
parent0478bc15bd3b4c616b4860e460600ba8877ee216 (diff)
Add QFont::Weight enum values
And try to make good use of them in order to match the QFont request more closely. Task-number: QTBUG-38482 Change-Id: I768dfa8828e370d77a1c17ecf4796d750b3edd9b Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsfontdatabase.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
index 214273e685..c9851a1c65 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
@@ -618,20 +618,6 @@ QDebug operator<<(QDebug d, const QFontDef &def)
return d;
}
-// convert 0 ~ 1000 integer to QFont::Weight
-static inline QFont::Weight weightFromInteger(long weight)
-{
- if (weight < 400)
- return QFont::Light;
- if (weight < 600)
- return QFont::Normal;
- if (weight < 700)
- return QFont::DemiBold;
- if (weight < 800)
- return QFont::Bold;
- return QFont::Black;
-}
-
static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSet)
{
switch (charSet) {
@@ -865,7 +851,7 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
const int size = scalable ? SMOOTH_SCALABLE : tm->tmHeight;
const QFont::Style style = tm->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
const bool antialias = false;
- const QFont::Weight weight = weightFromInteger(tm->tmWeight);
+ const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(tm->tmWeight);
const QFont::Stretch stretch = QFont::Unstretched;
#ifndef QT_NO_DEBUG_OUTPUT
@@ -1253,7 +1239,7 @@ QFontEngine *QWindowsFontDatabase::fontEngine(const QByteArray &fontData, qreal
else
fontEngine->fontDef.style = QFont::StyleNormal;
- fontEngine->fontDef.weight = weightFromInteger(qFromBigEndian<quint16>(os2Table->weightClass));
+ fontEngine->fontDef.weight = QPlatformFontDatabase::weightFromInteger(qFromBigEndian<quint16>(os2Table->weightClass));
}
}
@@ -1854,7 +1840,7 @@ QFont QWindowsFontDatabase::LOGFONT_to_QFont(const LOGFONT& logFont, int vertica
QFont qFont(QString::fromWCharArray(logFont.lfFaceName));
qFont.setItalic(logFont.lfItalic);
if (logFont.lfWeight != FW_DONTCARE)
- qFont.setWeight(weightFromInteger(logFont.lfWeight));
+ qFont.setWeight(QPlatformFontDatabase::weightFromInteger(logFont.lfWeight));
const qreal logFontHeight = qAbs(logFont.lfHeight);
qFont.setPointSizeF(logFontHeight * 72.0 / qreal(verticalDPI_In));
qFont.setUnderline(logFont.lfUnderline);