Add support for glyph offsets to the GlyphBuffer.
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Mar 2007 08:52:54 +0000 (08:52 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Mar 2007 08:52:54 +0000 (08:52 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@20508 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/Font.cpp
WebCore/platform/GlyphBuffer.h

index d7b8984ced5177136e807c4b907817108e7c7c2f..15c8c283e01120032e2c783ce956dc4c5e5c038a 100644 (file)
@@ -1,3 +1,17 @@
+2007-03-27  Dave Hyatt  <hyatt@apple.com>
+
+        Add support for glyph offsets to the GlyphBuffer.
+       
+        Reviewed by olliej
+
+        * platform/Font.cpp:
+        (WebCore::Font::drawGlyphBuffer):
+        * platform/GlyphBuffer.h:
+        (WebCore::GlyphBuffer::clear):
+        (WebCore::GlyphBuffer::swap):
+        (WebCore::GlyphBuffer::offsetAt):
+        (WebCore::GlyphBuffer::add):
+
 2007-03-27  Antti Koivisto  <antti@apple.com>
 
         Keep buildbot happy.
index 616cece76412e652a9f093ea8f7c4f4113ce57e5..62878d3ef789ed666bfbc0b315fb51246c3a202c 100644 (file)
@@ -608,16 +608,19 @@ void Font::drawGlyphBuffer(GraphicsContext* context, const GlyphBuffer& glyphBuf
 {   
     // Draw each contiguous run of glyphs that use the same font data.
     const FontData* fontData = glyphBuffer.fontDataAt(0);
+    FloatSize offset = glyphBuffer.offsetAt(0);
     FloatPoint startPoint(point);
     float nextX = startPoint.x();
     int lastFrom = 0;
     int nextGlyph = 0;
     while (nextGlyph < glyphBuffer.size()) {
         const FontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph);
-        if (nextFontData != fontData) {
+        FloatSize nextOffset = glyphBuffer.offsetAt(nextGlyph);
+        if (nextFontData != fontData || nextOffset != offset) {
             drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
             lastFrom = nextGlyph;
             fontData = nextFontData;
+            offset = nextOffset;
             startPoint.setX(nextX);
         }
         nextX += glyphBuffer.advanceAt(nextGlyph);
index c62c6a71872c0839966ada784ece3e2f8172f1ea..0f542c37d40f941961329d19c77c54adacf0fe3a 100644 (file)
@@ -65,6 +65,7 @@ public:
         m_fontData.clear();
         m_glyphs.clear();
         m_advances.clear();
+        m_offsets.clear();
     }
 
     GlyphBufferGlyph* glyphs(int from) { return m_glyphs.data() + from; }
@@ -87,6 +88,12 @@ public:
         GlyphBufferAdvance s = m_advances[index1];
         m_advances[index1] = m_advances[index2];
         m_advances[index2] = s;
+
+#if PLATFORM(WIN)
+        FloatSize offset = m_offsets[index1];
+        m_offsets[index1] = m_offsets[index2];
+        m_offsets[index2] = offset;
+#endif
     }
 
     Glyph glyphAt(int index) const
@@ -107,29 +114,38 @@ public:
 #endif
     }
 
-    void add(Glyph glyph, const FontData* font, float width)
+    FloatSize offsetAt(int index) const
     {
-        add(glyph, font, FloatSize(width, 0));
+#if PLATFORM(WIN)
+        return m_offsets[index];
+#else
+        return FloatSize();
+#endif
     }
 
-    void add(Glyph glyph, const FontData* font, FloatSize advanceSize)
+    void add(Glyph glyph, const FontData* font, float width, const FloatSize* offset = 0)
     {
         m_fontData.append(font);
 #if PLATFORM(CG)
         m_glyphs.append(glyph);
         CGSize advance;
-        advance.width = advanceSize.width();
-        advance.height = advanceSize.height();
+        advance.width = width;
+        advance.height = 0;
         m_advances.append(advance);
 #elif PLATFORM(CAIRO)
         cairo_glyph_t cairoGlyph;
         cairoGlyph.index = glyph;
-        cairoGlyph.y = 0;
         m_glyphs.append(cairoGlyph);
-        m_advances.append(advanceSize);
+        m_advances.append(FloatSize(width, 0));
 #elif PLATFORM(QT)
         m_glyphs.append(glyph);
-        m_advances.append(advanceSize);
+        m_advances.append(FloatSize(width, 0));
+#endif
+#if PLATFORM(WIN)
+        if (offset)
+            m_offsets.append(*offset);
+        else
+            m_offsets.append(FloatSize());
 #endif
     }
     
@@ -137,6 +153,9 @@ private:
     Vector<const FontData*, 2048> m_fontData;
     Vector<GlyphBufferGlyph, 2048> m_glyphs;
     Vector<GlyphBufferAdvance, 2048> m_advances;
+#if PLATFORM(WIN)
+    Vector<FloatSize, 2048> m_offsets;
+#endif
 };
 
 }