Commit 701900a4 authored by hyatt's avatar hyatt

Add support for glyph offsets to the GlyphBuffer.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20508 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4e73c473
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.
......
......@@ -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);
......
......@@ -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
};
}
......
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