summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qplatformfontdatabase.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/gui/text/qplatformfontdatabase.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/gui/text/qplatformfontdatabase.cpp')
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index d10cc8fed0..8f47933e6d 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -599,6 +599,34 @@ QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits(q
}
/*!
+ Helper function that returns the Qt font weight matching a given opentype integer value.
+
+ \since 5.5
+*/
+
+// convert 0 ~ 1000 integer to QFont::Weight
+QFont::Weight QPlatformFontDatabase::weightFromInteger(int weight)
+{
+ if (weight < 150)
+ return QFont::Thin;
+ if (weight < 250)
+ return QFont::ExtraLight;
+ if (weight < 350)
+ return QFont::Light;
+ if (weight < 450)
+ return QFont::Normal;
+ if (weight < 550)
+ return QFont::Medium;
+ if (weight < 650)
+ return QFont::DemiBold;
+ if (weight < 750)
+ return QFont::Bold;
+ if (weight < 850)
+ return QFont::ExtraBold;
+ return QFont::Black;
+}
+
+/*!
Helper function that register the \a alias for the \a familyName.
\since 5.2