[Libreoffice-commits] core.git: vcl/generic vcl/inc vcl/source
Khaled Hosny
khaledhosny at eglug.org
Thu May 23 00:51:15 PDT 2013
vcl/generic/glyphs/gcach_layout.cxx | 96 ------------------------------------
vcl/inc/generic/glyphcache.hxx | 1
vcl/source/gdi/sallayout.cxx | 4 -
3 files changed, 2 insertions(+), 99 deletions(-)
New commits:
commit 736adbb4687eaa6b6a7a350a6452df2eceaad960
Author: Khaled Hosny <khaledhosny at eglug.org>
Date: Thu May 23 09:34:27 2013 +0200
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
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx
index 07f9f76..6ac7fd4 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 e03e034..a7363f9 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 6955679..e795090 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;
More information about the Libreoffice-commits
mailing list