summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontdatabase.cpp
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-10-21 17:11:58 +0200
committerPierre Rossi <pierre.rossi@gmail.com>2014-10-24 23:19:11 +0200
commit0c482869fb342d7a7ed44d8101e84aec9f981549 (patch)
tree973a605eb7959425a68a8b15f23f42129141b3d2 /src/gui/text/qfontdatabase.cpp
parent0f3323ce0194b271024d423bec861d51dc55063f (diff)
Add support for more font weights internally
We should have more font weights in QFont::Weight to allow for finer grained control. For the time being, we can simply use intermediate weights to better support the different font weights falling in between the ones defined in QFont::Weight. Also amend the documentation to clarify the fact that QFont supports and can return weights falling outside the predefined values, which is already the case (e.g. when using fontconfig). Done-with: Gabriel de Dietrich Change-Id: I693cdd48b8b77e7ed550cdf991227bcb819d8e7b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src/gui/text/qfontdatabase.cpp')
-rw-r--r--src/gui/text/qfontdatabase.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 06d6ec125e..1322a088e0 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -85,10 +85,11 @@ static int getFontWeight(const QString &weightString)
QString s = weightString.toLower();
// Test in decreasing order of commonness
- if (s == QLatin1String("medium") ||
- s == QLatin1String("normal")
+ if (s == QLatin1String("normal")
|| s.compare(QCoreApplication::translate("QFontDatabase", "Normal"), Qt::CaseInsensitive) == 0)
return QFont::Normal;
+ if (s == QLatin1String("medium"))
+ return qt_mediumFontWeight;
if (s == QLatin1String("bold")
|| s.compare(QCoreApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive) == 0)
return QFont::Bold;
@@ -100,6 +101,10 @@ static int getFontWeight(const QString &weightString)
return QFont::Black;
if (s == QLatin1String("light"))
return QFont::Light;
+ if (s == QLatin1String("thin"))
+ return qt_thinFontWeight;
+ if (s == QLatin1String("extralight"))
+ return qt_extralightFontWeight;
if (s.contains(QLatin1String("bold"))
|| s.contains(QCoreApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive)) {