[Qt] Fix support for generic font families
authorvestbo@webkit.org <vestbo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Dec 2009 13:29:20 +0000 (13:29 +0000)
committervestbo@webkit.org <vestbo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Dec 2009 13:29:20 +0000 (13:29 +0000)
Reviewed by Simon Hausmann.

By not propagating the resolved font family in FontCacheQt and
only concidering the font description we ended up passing the
generic font families to Qt directly. Since most systems don't
have a mapping for these font families we ended up using the
default font in most cases.

* platform/graphics/qt/FontCacheQt.cpp:
* platform/graphics/qt/FontPlatformData.h:
* platform/graphics/qt/FontPlatformDataQt.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51758 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/qt/FontCacheQt.cpp
WebCore/platform/graphics/qt/FontPlatformData.h
WebCore/platform/graphics/qt/FontPlatformDataQt.cpp

index 1de35d6bd6324b4024c41f1b6c0f581b4f0596e6..8f380a8dc4960caa08e176a4be1b982450d8a09a 100644 (file)
@@ -1,3 +1,19 @@
+2009-12-07  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
+
+        Reviewed by Simon Hausmann.
+
+        [Qt] Fix support for generic font families
+
+        By not propagating the resolved font family in FontCacheQt and
+        only concidering the font description we ended up passing the
+        generic font families to Qt directly. Since most systems don't
+        have a mapping for these font families we ended up using the
+        default font in most cases.
+
+        * platform/graphics/qt/FontCacheQt.cpp:
+        * platform/graphics/qt/FontPlatformData.h:
+        * platform/graphics/qt/FontPlatformDataQt.cpp:
+
 2009-12-06  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Maciej Stachowiak.
index 648eed706aa01de45a7c0c6d844799acdccffe48..82fb7096cd695fb5ca3613ad2cf510ec366c2a6c 100644 (file)
@@ -34,6 +34,8 @@
 #include <wtf/ListHashSet.h>
 #include <wtf/StdLibExtras.h>
 
+#include <QFont>
+
 using namespace WTF;
 
 namespace WebCore {
@@ -49,22 +51,22 @@ const SimpleFontData* FontCache::getFontDataForCharacters(const Font&, const UCh
 
 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
 {
-    return new FontPlatformData(font.fontDescription());
+    return 0;
 }
 
 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
 {
-    return new FontPlatformData(fontDescription);
+    const AtomicString fallbackFamily = QFont(fontDescription.family().family()).lastResortFont();
+    return new FontPlatformData(fontDescription, fallbackFamily);
 }
 
 void FontCache::getTraitsInFamily(const AtomicString&, Vector<unsigned>&)
 {
 }
 
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString&)
+FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
 {
-    // FIXME : we must take into account the familly name (second argument)
-    return new FontPlatformData(fontDescription);
+    return new FontPlatformData(fontDescription, familyName);
 }
 
 } // namespace WebCore
index 306ada84dbe5d7aef6f5d9264783917c24ffbb43..4a3f8bc6f9af00e8d0b8fb819a70793a0c66d2fd 100644 (file)
@@ -65,7 +65,7 @@ class FontPlatformData : public FastAllocBase {
 public:
     FontPlatformData(float size, bool bold, bool oblique);
     FontPlatformData(const FontPlatformData &);
-    FontPlatformData(const FontDescription&, int wordSpacing = 0, int letterSpacing = 0);
+    FontPlatformData(const FontDescription&, const AtomicString& familyName, int wordSpacing = 0, int letterSpacing = 0);
     FontPlatformData(const QFont& font)
         : m_data(new FontPlatformDataPrivate(font))
     {}
index a0e2a1d680db4c121e8155985bbf741d543fe9ab..2cc2fc6fdaf083f89afa6512b46efab151089b42 100644 (file)
@@ -46,16 +46,19 @@ FontPlatformData::FontPlatformData(const FontPlatformData &other) : m_data(other
         ++m_data->refCount;
 }
 
-FontPlatformData::FontPlatformData(const FontDescription& description, int wordSpacing, int letterSpacing)
+FontPlatformData::FontPlatformData(const FontDescription& description, const AtomicString& familyName, int wordSpacing, int letterSpacing)
     : m_data(new FontPlatformDataPrivate())
 {
-    QString familyName;
+    QString familyNames(familyName);
+    if (!familyName.isEmpty())
+        familyNames += QLatin1Char(',');
+
     const FontFamily* family = &description.family();
     while (family) {
-        familyName += family->family();
+        familyNames += family->family();
         family = family->next();
         if (family)
-            familyName += QLatin1Char(',');
+            familyNames += QLatin1Char(',');
     }
     QFont& font = m_data->font;
     font.setFamily(familyName);