summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2013-05-23 09:34:27 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2013-05-23 09:50:46 +0200
commit736adbb4687eaa6b6a7a350a6452df2eceaad960 (patch)
tree349302bc147dd1317261093fc57f887a284d8e29
parent62b74b6c21b0b30bbb5a2053dabff375273b0c8e (diff)
Fix left to right full justification
I was overloading ApplyDXArray() with a HarfBuzz specific implementation because the GenericSalLayout one was screwing right to left kerning, but it seems to have broken left to right full justifications. Since mnXOffset was introduced a bit earlier to fix a similar issue, it can now be used here as well to minimize the possible side effects. Seems to work fine for both left to right and right to left text now, but at least one of my Arabic tests is regressing, so might need some tweaking. Change-Id: I1239b0ec77a4978f981a480400a6d01cda18af79
-rw-r--r--vcl/generic/glyphs/gcach_layout.cxx96
-rw-r--r--vcl/inc/generic/glyphcache.hxx1
-rw-r--r--vcl/source/gdi/sallayout.cxx4
3 files changed, 2 insertions, 99 deletions
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx
index 07f9f76d6324..6ac7fd43e4fa 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -90,102 +90,6 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
}
}
-// apply adjustments to glyph advances, e.g. as a result of justification.
-void ServerFontLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
-{
- if (bUseHarfBuzz)
- {
- if (m_GlyphItems.empty())
- return;
-
- // determine cluster boundaries and x base offset
- const int nCharCount = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
- int* pLogCluster = (int*)alloca(nCharCount * sizeof(int));
- size_t i;
- int n,p;
- long nBasePointX = -1;
- if (mnLayoutFlags & SAL_LAYOUT_FOR_FALLBACK)
- nBasePointX = 0;
- for (p = 0; p < nCharCount; ++p)
- pLogCluster[p] = -1;
-
- for (i = 0; i < m_GlyphItems.size(); ++i)
- {
- n = m_GlyphItems[i].mnCharPos - rArgs.mnMinCharPos;
- if ((n < 0) || (nCharCount <= n))
- continue;
- if (pLogCluster[n] < 0)
- pLogCluster[n] = i;
- if (nBasePointX < 0)
- nBasePointX = m_GlyphItems[i].maLinearPos.X();
- }
- // retarget unresolved pLogCluster[n] to a glyph inside the cluster
- // TODO: better do it while the deleted-glyph markers are still there
- for (n = 0; n < nCharCount; ++n)
- if ((p = pLogCluster[0]) >= 0)
- break;
- if (n >= nCharCount)
- return;
- for (n = 0; n < nCharCount; ++n)
- {
- if (pLogCluster[n] < 0)
- pLogCluster[n] = p;
- else
- p = pLogCluster[n];
- }
-
- // calculate adjusted cluster widths
- sal_Int32* pNewGlyphWidths = (sal_Int32*)alloca(m_GlyphItems.size() * sizeof(sal_Int32));
- for (i = 0; i < m_GlyphItems.size(); ++i)
- pNewGlyphWidths[i] = 0;
-
- bool bRTL;
- for (int nCharPos = p = -1; rArgs.GetNextPos(&nCharPos, &bRTL); )
- {
- n = nCharPos - rArgs.mnMinCharPos;
- if ((n < 0) || (nCharCount <= n)) continue;
-
- if (pLogCluster[n] >= 0)
- p = pLogCluster[n];
- if (p >= 0)
- {
- long nDelta = rArgs.mpDXArray[n];
- if(n > 0)
- nDelta -= rArgs.mpDXArray[n - 1];
- pNewGlyphWidths[p] += nDelta * mnUnitsPerPixel;
- }
- }
-
- // move cluster positions using the adjusted widths
- long nDelta = 0;
- for (i = 0; i < m_GlyphItems.size(); ++i)
- {
- if (m_GlyphItems[i].IsClusterStart())
- {
- // calculate original and adjusted cluster width
- int nOldClusterWidth = m_GlyphItems[i].mnNewWidth;
- int nNewClusterWidth = pNewGlyphWidths[i];
- size_t j;
- for (j = i; ++j < m_GlyphItems.size(); )
- {
- if (m_GlyphItems[j].IsClusterStart())
- break;
- if (!m_GlyphItems[j].IsDiacritic()) // #i99367# ignore diacritics
- nOldClusterWidth += m_GlyphItems[j].mnNewWidth;
- nNewClusterWidth += pNewGlyphWidths[j];
- }
- nDelta += nNewClusterWidth - nOldClusterWidth;
- }
- m_GlyphItems[i].mnNewWidth = pNewGlyphWidths[i];
- m_GlyphItems[i].maLinearPos.X() += nDelta;
- }
- }
- else
- {
- GenericSalLayout::ApplyDXArray(rArgs);
- }
-}
-
// =======================================================================
static bool lcl_CharIsJoiner(sal_Unicode cChar)
diff --git a/vcl/inc/generic/glyphcache.hxx b/vcl/inc/generic/glyphcache.hxx
index e03e03485ee4..a7363f9bfa42 100644
--- a/vcl/inc/generic/glyphcache.hxx
+++ b/vcl/inc/generic/glyphcache.hxx
@@ -322,7 +322,6 @@ public:
ServerFontLayout( ServerFont& );
virtual bool LayoutText( ImplLayoutArgs& );
virtual void AdjustLayout( ImplLayoutArgs& );
- virtual void ApplyDXArray( ImplLayoutArgs& );
virtual void DrawText( SalGraphics& ) const;
ServerFont& GetServerFont() const { return mrServerFont; }
};
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 6955679350ad..e7950906d9eb 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1090,7 +1090,7 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& rArgs )
if( m_GlyphItems[i].IsClusterStart() )
{
// calculate original and adjusted cluster width
- int nOldClusterWidth = m_GlyphItems[i].mnNewWidth;
+ int nOldClusterWidth = m_GlyphItems[i].mnNewWidth - m_GlyphItems[i].mnXOffset;
int nNewClusterWidth = pNewGlyphWidths[i];
size_t j;
for( j = i; ++j < m_GlyphItems.size(); )
@@ -1098,7 +1098,7 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& rArgs )
if( m_GlyphItems[j].IsClusterStart() )
break;
if( !m_GlyphItems[j].IsDiacritic() ) // #i99367# ignore diacritics
- nOldClusterWidth += m_GlyphItems[j].mnNewWidth;
+ nOldClusterWidth += m_GlyphItems[j].mnNewWidth - m_GlyphItems[j].mnXOffset;
nNewClusterWidth += pNewGlyphWidths[j];
}
const int nDiff = nNewClusterWidth - nOldClusterWidth;