Modified: trunk/Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp (123990 => 123991)
--- trunk/Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp 2012-07-30 00:44:08 UTC (rev 123990)
+++ trunk/Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp 2012-07-30 01:46:58 UTC (rev 123991)
@@ -185,6 +185,7 @@
#if USE(HARFBUZZ_NG)
GlyphBuffer glyphBuffer;
HarfBuzzShaper shaper(this, run);
+ shaper.setDrawRange(from, to);
if (!shaper.shape(&glyphBuffer))
return;
FloatPoint adjustedPoint = shaper.adjustStartPoint(point);
Modified: trunk/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp (123990 => 123991)
--- trunk/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp 2012-07-30 00:44:08 UTC (rev 123990)
+++ trunk/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp 2012-07-30 01:46:58 UTC (rev 123991)
@@ -167,6 +167,8 @@
HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run)
: HarfBuzzShaperBase(font, run)
+ , m_fromIndex(0)
+ , m_toIndex(m_run.length())
{
m_normalizedBuffer = adoptArrayPtr(new UChar[m_run.length() + 1]);
m_normalizedBufferLength = m_run.length();
@@ -179,6 +181,19 @@
{
}
+void HarfBuzzShaper::setDrawRange(int from, int to)
+{
+ ASSERT(from >= 0);
+ ASSERT(to <= m_run.length());
+ m_fromIndex = from;
+ m_toIndex = to;
+}
+
+bool HarfBuzzShaper::shouldDrawCharacterAt(int index)
+{
+ return m_fromIndex <= index && index < m_toIndex;
+}
+
void HarfBuzzShaper::setFontFeatures()
{
FontFeatureSettings* settings = m_font->fontDescription().featureSettings();
@@ -254,6 +269,9 @@
bool HarfBuzzShaper::shapeHarfBuzzRuns(GlyphBuffer* glyphBuffer)
{
HarfBuzzScopedPtr<hb_buffer_t> harfbuzzBuffer(hb_buffer_create(), hb_buffer_destroy);
+ float pendingGlyphAdvanceX = 0;
+ float pendingGlyphAdvanceY = 0;
+
hb_buffer_set_unicode_funcs(harfbuzzBuffer.get(), hb_icu_get_unicode_funcs());
if (m_run.directionalOverride())
hb_buffer_set_direction(harfbuzzBuffer.get(), m_run.rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR);
@@ -279,7 +297,7 @@
hb_shape(harfbuzzFont.get(), harfbuzzBuffer.get(), m_features.isEmpty() ? 0 : m_features.data(), m_features.size());
currentRun->applyShapeResult(harfbuzzBuffer.get());
- setGlyphPositionsForHarfBuzzRun(currentRun, i, harfbuzzBuffer.get(), glyphBuffer);
+ setGlyphPositionsForHarfBuzzRun(currentRun, i, harfbuzzBuffer.get(), glyphBuffer, pendingGlyphAdvanceX, pendingGlyphAdvanceY);
hb_buffer_reset(harfbuzzBuffer.get());
if (m_run.directionalOverride())
@@ -288,7 +306,7 @@
return true;
}
-void HarfBuzzShaper::setGlyphPositionsForHarfBuzzRun(HarfBuzzRun* currentRun, unsigned runIndexInVisualOrder, hb_buffer_t* harfbuzzBuffer, GlyphBuffer* glyphBuffer)
+void HarfBuzzShaper::setGlyphPositionsForHarfBuzzRun(HarfBuzzRun* currentRun, unsigned runIndexInVisualOrder, hb_buffer_t* harfbuzzBuffer, GlyphBuffer* glyphBuffer, float& pendingGlyphAdvanceX, float& pendingGlyphAdvanceY)
{
const SimpleFontData* currentFontData = currentRun->fontData();
hb_glyph_info_t* glyphInfos = hb_buffer_get_glyph_infos(harfbuzzBuffer, 0);
@@ -317,7 +335,7 @@
if (currentFontData->isZeroWidthSpaceGlyph(glyph)) {
currentRun->setGlyphAndAdvance(i, glyph, 0);
- if (glyphBuffer)
+ if (glyphBuffer && shouldDrawCharacterAt(currentCharacterIndex))
glyphBuffer->add(glyph, currentFontData, createGlyphBufferAdvance(0, 0));
continue;
}
@@ -330,7 +348,16 @@
m_startOffset.set(offsetX, offsetY);
float glyphAdvanceX = advance + nextOffsetX - offsetX;
float glyphAdvanceY = nextOffsetY - offsetY;
- glyphBuffer->add(glyph, currentFontData, createGlyphBufferAdvance(glyphAdvanceX, glyphAdvanceY));
+ if (shouldDrawCharacterAt(currentCharacterIndex)) {
+ glyphAdvanceX += pendingGlyphAdvanceX;
+ glyphAdvanceY += pendingGlyphAdvanceY;
+ pendingGlyphAdvanceX = 0;
+ pendingGlyphAdvanceY = 0;
+ glyphBuffer->add(glyph, currentFontData, createGlyphBufferAdvance(glyphAdvanceX, glyphAdvanceY));
+ } else {
+ pendingGlyphAdvanceX += glyphAdvanceX;
+ pendingGlyphAdvanceY += glyphAdvanceY;
+ }
}
totalAdvance += advance;
Modified: trunk/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h (123990 => 123991)
--- trunk/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h 2012-07-30 00:44:08 UTC (rev 123990)
+++ trunk/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h 2012-07-30 01:46:58 UTC (rev 123991)
@@ -51,6 +51,7 @@
HarfBuzzShaper(const Font*, const TextRun&);
virtual ~HarfBuzzShaper();
+ void setDrawRange(int from, int to);
bool shape(GlyphBuffer* = 0);
FloatPoint adjustStartPoint(const FloatPoint&);
float totalWidth() { return m_totalWidth; }
@@ -96,11 +97,12 @@
float m_width;
};
+ bool shouldDrawCharacterAt(int index);
void setFontFeatures();
bool collectHarfBuzzRuns();
bool shapeHarfBuzzRuns(GlyphBuffer*);
- void setGlyphPositionsForHarfBuzzRun(HarfBuzzRun*, unsigned runIndexInVisualOrder, hb_buffer_t*, GlyphBuffer*);
+ void setGlyphPositionsForHarfBuzzRun(HarfBuzzRun*, unsigned runIndexInVisualOrder, hb_buffer_t*, GlyphBuffer*, float& pendingGlyphAdvanceX, float& pendingGlyphAdvanceY);
GlyphBufferAdvance createGlyphBufferAdvance(float, float);
@@ -109,6 +111,9 @@
FloatPoint m_startOffset;
+ int m_fromIndex;
+ int m_toIndex;
+
float m_totalWidth;
};
Modified: trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp (123990 => 123991)
--- trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp 2012-07-30 00:44:08 UTC (rev 123990)
+++ trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp 2012-07-30 01:46:58 UTC (rev 123991)
@@ -105,6 +105,7 @@
if (preferHarfBuzz(this)) {
GlyphBuffer glyphBuffer;
HarfBuzzShaper shaper(this, run);
+ shaper.setDrawRange(from, to);
if (shaper.shape(&glyphBuffer)) {
drawGlyphBuffer(context, run, glyphBuffer, point);
return;