diff options
author | Jonas Karlsson <jonas.karlsson@qt.io> | 2020-08-05 10:47:33 +0200 |
---|---|---|
committer | Jonas Karlsson <jonas.karlsson@qt.io> | 2020-08-28 07:26:54 +0200 |
commit | 3558704ed5c3d2c6dc6d024dfa454997469ca75f (patch) | |
tree | 84fe1b1d8314a389b480b7e720574573c3bd2083 /src/gui/text/unix | |
parent | eb98bed4e76bb0fa6bad8474f2f370334cb70f6c (diff) |
Use OpenType font weights
Task-number: QTBUG-42248
Change-Id: Icdb301b27d6699c2b842c4563fbef9df73c23cbc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/gui/text/unix')
-rw-r--r-- | src/gui/text/unix/qfontconfigdatabase.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/gui/text/unix/qfontconfigdatabase.cpp b/src/gui/text/unix/qfontconfigdatabase.cpp index f54af2e59e..a8e28618f4 100644 --- a/src/gui/text/unix/qfontconfigdatabase.cpp +++ b/src/gui/text/unix/qfontconfigdatabase.cpp @@ -65,8 +65,6 @@ QT_BEGIN_NAMESPACE -static const int maxWeight = 99; - static inline int mapToQtWeightForRange(int fcweight, int fcLower, int fcUpper, int qtLower, int qtUpper) { return qtLower + ((fcweight - fcLower) * (qtUpper - qtLower)) / (fcUpper - fcLower); @@ -75,7 +73,7 @@ static inline int mapToQtWeightForRange(int fcweight, int fcLower, int fcUpper, static inline int weightFromFcWeight(int fcweight) { // Font Config uses weights from 0 to 215 (the highest enum value) while QFont ranges from - // 0 to 99. The spacing between the values for the enums are uneven so a linear mapping from + // 1 to 1000. The spacing between the values for the enums are uneven so a linear mapping from // Font Config values to Qt would give surprising results. So, we do a piecewise linear // mapping. This ensures that where there is a corresponding enum on both sides (for example // FC_WEIGHT_DEMIBOLD and QFont::DemiBold) we map one to the other but other values map @@ -100,8 +98,9 @@ static inline int weightFromFcWeight(int fcweight) if (fcweight <= FC_WEIGHT_BLACK) return mapToQtWeightForRange(fcweight, FC_WEIGHT_ULTRABOLD, FC_WEIGHT_BLACK, QFont::ExtraBold, QFont::Black); if (fcweight <= FC_WEIGHT_ULTRABLACK) - return mapToQtWeightForRange(fcweight, FC_WEIGHT_BLACK, FC_WEIGHT_ULTRABLACK, QFont::Black, maxWeight); - return maxWeight; + return mapToQtWeightForRange(fcweight, FC_WEIGHT_BLACK, FC_WEIGHT_ULTRABLACK, QFont::Black, + QFONT_WEIGHT_MAX); + return QFONT_WEIGHT_MAX; } static inline int stretchFromFcWidth(int fcwidth) |