Commit 4e8d0248 authored by treat@webkit.org's avatar treat@webkit.org

2009-07-27 Mike Fenton <mike.fenton@torchmobile.com>

        Reviewed by Adam Treat.

        Add mapping FontWeight to QFont::Weight values as requested via FIXME.
        https://bugs.webkit.org/show_bug.cgi?id=27663

        * platform/graphics/qt/FontCacheQt.cpp:
        (WebCore::FontPlatformDataCacheKey::FontPlatformDataCacheKey):
        * platform/graphics/qt/FontPlatformData.h:
        (WebCore::FontPlatformData::toQFontWeight):
        * platform/graphics/qt/FontPlatformDataQt.cpp:
        (WebCore::FontPlatformData::FontPlatformData):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@46428 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 86045d26
2009-07-27 Mike Fenton <mike.fenton@torchmobile.com>
Reviewed by Adam Treat.
Add mapping FontWeight to QFont::Weight values as requested via FIXME.
https://bugs.webkit.org/show_bug.cgi?id=27663
* platform/graphics/qt/FontCacheQt.cpp:
(WebCore::FontPlatformDataCacheKey::FontPlatformDataCacheKey):
* platform/graphics/qt/FontPlatformData.h:
(WebCore::FontPlatformData::toQFontWeight):
* platform/graphics/qt/FontPlatformDataQt.cpp:
(WebCore::FontPlatformData::FontPlatformData):
2009-07-27 Jakub Wieczorek <faw217@gmail.com>
Reviewed by Adam Treat.
......
......@@ -65,7 +65,7 @@ public:
, m_hash(0)
{
// FIXME: Map all FontWeight values to QFont weights in FontPlatformData's ctor and follow it here
if (description.weight() >= FontWeight600)
if (FontPlatformData::toQFontWeight(description.weight()) > QFont::Normal)
m_bold = true;
const FontFamily* family = &description.family();
......
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2008 Holger Hans Peter Freyther
Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -40,6 +41,27 @@ public:
FontPlatformData(const FontDescription&, int wordSpacing = 0, int letterSpacing = 0);
FontPlatformData(const QFont&, bool bold);
static inline QFont::Weight toQFontWeight(FontWeight fontWeight)
{
switch (fontWeight) {
case FontWeight100:
case FontWeight200:
return QFont::Light; // QFont::Light == Weight of 25
case FontWeight600:
return QFont::DemiBold; // QFont::DemiBold == Weight of 63
case FontWeight700:
case FontWeight800:
return QFont::Bold; // QFont::Bold == Weight of 75
case FontWeight900:
return QFont::Black; // QFont::Black == Weight of 87
case FontWeight300:
case FontWeight400:
case FontWeight500:
default:
return QFont::Normal; // QFont::Normal == Weight of 50
}
}
QFont font() const { return m_font; }
float size() const { return m_size; }
QString family() const { return m_font.family(); }
......
/*
Copyright (C) 2008 Holger Hans Peter Freyther
Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -42,12 +43,9 @@ FontPlatformData::FontPlatformData(const FontDescription& description, int wordS
m_font.setFamily(familyName);
m_font.setPixelSize(qRound(description.computedSize()));
m_font.setItalic(description.italic());
// FIXME: Map all FontWeight values to QFont weights.
if (description.weight() >= FontWeight600) {
m_font.setWeight(QFont::Bold);
m_bold = true;
} else
m_font.setWeight(QFont::Normal);
m_font.setWeight(toQFontWeight(description.weight()));
m_bold = m_font.bold();
bool smallCaps = description.smallCaps();
m_font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment