diff options
author | Pierre Rossi <pierre.rossi@digia.com> | 2014-10-22 17:14:29 +0200 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2014-12-12 06:59:46 +0100 |
commit | 517da68893be9e6d97c7993922c573de9560604d (patch) | |
tree | 9da6027604c97023fd6cacc3114c2f2fd43dd26f /src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp | |
parent | 0478bc15bd3b4c616b4860e460600ba8877ee216 (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/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp')
-rw-r--r-- | src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 686563893f..f129bb40dd 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -76,18 +76,24 @@ static inline int weightFromFcWeight(int fcweight) // FC_WEIGHT_DEMIBOLD and QFont::DemiBold) we map one to the other but other values map // to intermediate Qt weights. - if (fcweight < 0) - return 0; + if (fcweight <= FC_WEIGHT_THIN) + return QFont::Thin; + if (fcweight <= FC_WEIGHT_ULTRALIGHT) + return mapToQtWeightForRange(fcweight, FC_WEIGHT_THIN, FC_WEIGHT_ULTRALIGHT, QFont::Thin, QFont::ExtraLight); if (fcweight <= FC_WEIGHT_LIGHT) - return mapToQtWeightForRange(fcweight, 0, FC_WEIGHT_LIGHT, 0, QFont::Light); + return mapToQtWeightForRange(fcweight, FC_WEIGHT_ULTRALIGHT, FC_WEIGHT_LIGHT, QFont::ExtraLight, QFont::Light); if (fcweight <= FC_WEIGHT_NORMAL) return mapToQtWeightForRange(fcweight, FC_WEIGHT_LIGHT, FC_WEIGHT_NORMAL, QFont::Light, QFont::Normal); + if (fcweight <= FC_WEIGHT_MEDIUM) + return mapToQtWeightForRange(fcweight, FC_WEIGHT_NORMAL, FC_WEIGHT_MEDIUM, QFont::Normal, QFont::Medium); if (fcweight <= FC_WEIGHT_DEMIBOLD) - return mapToQtWeightForRange(fcweight, FC_WEIGHT_NORMAL, FC_WEIGHT_DEMIBOLD, QFont::Normal, QFont::DemiBold); + return mapToQtWeightForRange(fcweight, FC_WEIGHT_MEDIUM, FC_WEIGHT_DEMIBOLD, QFont::Medium, QFont::DemiBold); if (fcweight <= FC_WEIGHT_BOLD) return mapToQtWeightForRange(fcweight, FC_WEIGHT_DEMIBOLD, FC_WEIGHT_BOLD, QFont::DemiBold, QFont::Bold); + if (fcweight <= FC_WEIGHT_ULTRABOLD) + return mapToQtWeightForRange(fcweight, FC_WEIGHT_BOLD, FC_WEIGHT_ULTRABOLD, QFont::Bold, QFont::ExtraBold); if (fcweight <= FC_WEIGHT_BLACK) - return mapToQtWeightForRange(fcweight, FC_WEIGHT_BOLD, FC_WEIGHT_BLACK, QFont::Bold, QFont::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; |