summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2015-01-07 13:51:25 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-01-08 17:05:33 +0100
commit2371d57eff6bf39abc483dcb321324d11b2a15bc (patch)
tree61439bab1e152681cd17ab44fd140fec8f8f4023 /Source
parent1aef709674f43ebdc5b5bd4171fabd579412add4 (diff)
Map CSS font-weights to new QFont enums
Fixes the selection of light font for weight 300, and adds mapping for the rest of the values that was added in Qt 5.5. Change-Id: Ic92e61bc9e452d44328ac05ad5c9a2b15fceb91e Reviewed-by: Pierre Rossi <pierre.rossi@theqtcompany.com>
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp38
1 files changed, 33 insertions, 5 deletions
diff --git a/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
index 8e917402e..efbee5357 100644
--- a/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
@@ -29,26 +29,54 @@
namespace WebCore {
+// See http://www.w3.org/TR/css3-fonts/#font-weight-prop
+#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
static inline QFont::Weight toQFontWeight(FontWeight fontWeight)
{
switch (fontWeight) {
case FontWeight100:
+ return QFont::Thin;
case FontWeight200:
- return QFont::Light; // QFont::Light == Weight of 25
+ return QFont::ExtraLight;
+ case FontWeight300:
+ return QFont::Light;
+ case FontWeight400:
+ return QFont::Normal;
+ case FontWeight500:
+ return QFont::Medium;
case FontWeight600:
- return QFont::DemiBold; // QFont::DemiBold == Weight of 63
+ return QFont::DemiBold;
case FontWeight700:
+ return QFont::Bold;
case FontWeight800:
- return QFont::Bold; // QFont::Bold == Weight of 75
+ return QFont::ExtraBold;
case FontWeight900:
- return QFont::Black; // QFont::Black == Weight of 87
+ return QFont::Black;
+ }
+ Q_UNREACHABLE();
+}
+#else
+static inline QFont::Weight toQFontWeight(FontWeight fontWeight)
+{
+ switch (fontWeight) {
+ case FontWeight100:
+ case FontWeight200:
case FontWeight300:
+ return QFont::Light; // QFont::Light == Weight of 25
case FontWeight400:
case FontWeight500:
- default:
return QFont::Normal; // QFont::Normal == Weight of 50
+ case FontWeight600:
+ return QFont::DemiBold; // QFont::DemiBold == Weight of 63
+ case FontWeight700:
+ return QFont::Bold; // QFont::Bold == Weight of 75
+ case FontWeight800:
+ case FontWeight900:
+ return QFont::Black; // QFont::Black == Weight of 87
}
+ Q_UNREACHABLE();
}
+#endif
static inline bool isEmptyValue(const float size, const bool bold, const bool oblique)
{