[Qt] Support kerning in fast path font rendering
authorallan.jensen@digia.com <allan.jensen@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Mar 2013 16:00:47 +0000 (16:00 +0000)
committerallan.jensen@digia.com <allan.jensen@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Mar 2013 16:00:47 +0000 (16:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106013

Reviewed by Jocelyn Turcotte.

To support kerning in the fast font path we need to implement SimpleFontData::applyTransforms.

This patch changes the types used by the fast path GlyphBuffer to match those used by Qt,
and implements SimpleFontData::applyTransforms using QRawFont::advancesForGlyphIndexes.

* platform/graphics/GlyphBuffer.h:
(GlyphBufferAdvance):
(WebCore::GlyphBufferAdvance::GlyphBufferAdvance):
(WebCore::GlyphBufferAdvance::setWidth):
(WebCore::GlyphBufferAdvance::width):
(WebCore::GlyphBufferAdvance::height):
(WebCore::GlyphBuffer::add):
* platform/graphics/SimpleFontData.h:
(WebCore::SimpleFontData::applyTransforms):
* platform/graphics/WidthIterator.h:
(WebCore::WidthIterator::supportsTypesettingFeatures):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GlyphBuffer.h
Source/WebCore/platform/graphics/SimpleFontData.h
Source/WebCore/platform/graphics/WidthIterator.h

index 456a76816b829e599efa555e26a7884060427089..c69b45f3076ea768a1b076843c6b1b86c1f6c58e 100644 (file)
@@ -1,3 +1,27 @@
+2013-03-19  Allan Sandfeld Jensen  <allan.jensen@digia.com>
+
+        [Qt] Support kerning in fast path font rendering
+        https://bugs.webkit.org/show_bug.cgi?id=106013
+
+        Reviewed by Jocelyn Turcotte.
+
+        To support kerning in the fast font path we need to implement SimpleFontData::applyTransforms.
+
+        This patch changes the types used by the fast path GlyphBuffer to match those used by Qt,
+        and implements SimpleFontData::applyTransforms using QRawFont::advancesForGlyphIndexes.
+
+        * platform/graphics/GlyphBuffer.h:
+        (GlyphBufferAdvance):
+        (WebCore::GlyphBufferAdvance::GlyphBufferAdvance):
+        (WebCore::GlyphBufferAdvance::setWidth):
+        (WebCore::GlyphBufferAdvance::width):
+        (WebCore::GlyphBufferAdvance::height):
+        (WebCore::GlyphBuffer::add):
+        * platform/graphics/SimpleFontData.h:
+        (WebCore::SimpleFontData::applyTransforms):
+        * platform/graphics/WidthIterator.h:
+        (WebCore::WidthIterator::supportsTypesettingFeatures):
+
 2013-03-19  Sergey Ryazanov  <serya@chromium.org>
 
         Web Inspector: split Console into two entities, a web-facing bound object and page console.
index 5feafb1402c56d6389213dbb2a6dd97dcf9b74f1..3aec08e65e0bf91d52016f5590eea35b3837a2d3 100644 (file)
@@ -56,6 +56,8 @@ class SimpleFontData;
 typedef cairo_glyph_t GlyphBufferGlyph;
 #elif OS(WINCE)
 typedef wchar_t GlyphBufferGlyph;
+#elif PLATFORM(QT)
+typedef quint32 GlyphBufferGlyph;
 #else
 typedef Glyph GlyphBufferGlyph;
 #endif
@@ -89,6 +91,18 @@ public:
 private:
     float advance;
 };
+#elif PLATFORM(QT)
+struct GlyphBufferAdvance : public QPointF {
+public:
+    GlyphBufferAdvance(const QPointF& advance)
+        : QPointF(advance)
+    {
+    }
+
+    void setWidth(qreal width) { QPointF::setX(width); }
+    qreal width() const { return QPointF::x(); }
+    qreal height() const { return QPointF::y(); }
+};
 #else
 typedef FloatSize GlyphBufferAdvance;
 #endif
@@ -156,6 +170,8 @@ public:
         m_advances.append(advance);
 #elif OS(WINCE)
         m_advances.append(width);
+#elif PLATFORM(QT)
+        m_advances.append(QPointF(width, 0));
 #else
         m_advances.append(FloatSize(width, 0));
 #endif
index 381024471010e799b7597c51fdc34c0b24a7e70a..e9ed48f485d4a2c68e28aa88d07d30adcd975c52 100644 (file)
@@ -203,15 +203,18 @@ public:
 
     bool applyTransforms(GlyphBufferGlyph* glyphs, GlyphBufferAdvance* advances, size_t glyphCount, TypesettingFeatures typesettingFeatures) const
     {
-#if !PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED <= 1080
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 1080
+        wkCTFontTransformOptions options = (typesettingFeatures & Kerning ? wkCTFontTransformApplyPositioning : 0) | (typesettingFeatures & Ligatures ? wkCTFontTransformApplyShaping : 0);
+        return wkCTFontTransformGlyphs(m_platformData.ctFont(), glyphs, reinterpret_cast<CGSize*>(advances), glyphCount, options);
+#elif PLATFORM(QT) && QT_VERSION >= 0x050100
+        QRawFont::LayoutFlags flags = (typesettingFeatures & Kerning) ? QRawFont::KernedAdvances : QRawFont::SeparateAdvances;
+        return m_platformData.rawFont().advancesForGlyphIndexes(glyphs, advances, glyphCount, flags);
+#else
         UNUSED_PARAM(glyphs);
         UNUSED_PARAM(advances);
         UNUSED_PARAM(glyphCount);
         UNUSED_PARAM(typesettingFeatures);
         return false;
-#else
-    wkCTFontTransformOptions options = (typesettingFeatures & Kerning ? wkCTFontTransformApplyPositioning : 0) | (typesettingFeatures & Ligatures ? wkCTFontTransformApplyShaping : 0);
-    return wkCTFontTransformGlyphs(m_platformData.ctFont(), glyphs, reinterpret_cast<CGSize*>(advances), glyphCount, options);
 #endif
     }
 
index 1996a09783ec44313a3e29bbf832f0bdd5c72b2a..8e4e069978ffc7ce23598d4348166ff756a9b0fb 100644 (file)
@@ -61,13 +61,15 @@ public:
 
     static bool supportsTypesettingFeatures(const Font& font)
     {
-#if !PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED <= 1080
-        return !font.typesettingFeatures();
-#else
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 1080
         if (!font.isPrinterFont())
             return !font.typesettingFeatures();
 
         return !(font.typesettingFeatures() & ~(Kerning | Ligatures));
+#elif PLATFORM(QT) && QT_VERSION >= 0x050100
+        return !(font.typesettingFeatures() & ~Kerning) && !font.isSmallCaps();
+#else
+        return !font.typesettingFeatures();
 #endif
     }