summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Hosken <martin_hosken@sil.org>2017-11-14 15:20:31 +0700
committerMartin Hosken <martin_hosken@sil.org>2017-11-14 19:01:29 +0100
commitc45b23377bb2fe44c26f1287ff38495344e4ca50 (patch)
tree26bae8e2b65dc0b9caff893b639afafb9e5d9c97
parent935f76d0edeb0025dee39f95e1f0bc1a840e316e (diff)
Only do kashida insertion with fonts that have non-zero width kashidas
Change-Id: I54f51432531072a8ec3cde832003369b23cb6eaf Reviewed-on: https://gerrit.libreoffice.org/44704 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Martin Hosken <martin_hosken@sil.org>
-rw-r--r--sw/source/core/text/itradj.cxx11
-rw-r--r--sw/source/core/text/portxt.cxx3
-rw-r--r--sw/source/core/txtnode/fntcache.cxx9
3 files changed, 12 insertions, 11 deletions
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index f82a3f6d1df2..29ee5e81a438 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -112,6 +112,9 @@ void SwTextAdjuster::FormatBlock( )
static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf, SwTextIter& rItr,
sal_Int32& rKashidas, sal_Int32& nGluePortion )
{
+ if ( rInf.GetOut()->GetMinKashida() <= 0 )
+ return false;
+
// i60594 validate Kashida justification
sal_Int32 nIdx = rItr.GetStart();
sal_Int32 nEnd = rItr.GetEnd();
@@ -148,12 +151,6 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf,
sal_Int32 nKashidasInAttr = rSI.KashidaJustify ( nullptr, nullptr, nIdx, nNext - nIdx );
if (nKashidasInAttr > 0)
{
- // Kashida glyph looks suspicious, skip Kashida justification
- if ( rInf.GetOut()->GetMinKashida() <= 0 )
- {
- return false;
- }
-
sal_Int32 nKashidasDropped = 0;
if ( !SwScriptInfo::IsArabicText( rInf.GetText(), nIdx, nNext - nIdx ) )
{
@@ -211,7 +208,7 @@ static bool lcl_CheckKashidaWidth ( SwScriptInfo& rSI, SwTextSizeInfo& rInf, SwT
sal_Int32 nKashidasInAttr = rSI.KashidaJustify ( nullptr, nullptr, nIdx, nNext - nIdx );
long nFontMinKashida = rInf.GetOut()->GetMinKashida();
- if ( nFontMinKashida && nKashidasInAttr > 0 && SwScriptInfo::IsArabicText( rInf.GetText(), nIdx, nNext - nIdx ) )
+ if ( nKashidasInAttr > 0 && SwScriptInfo::IsArabicText( rInf.GetText(), nIdx, nNext - nIdx ) )
{
sal_Int32 nKashidasDropped = 0;
while ( rKashidas && nGluePortion && nKashidasInAttr > 0 &&
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index d541607b64a0..7ffc17e970fb 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -112,7 +112,8 @@ static sal_Int32 lcl_AddSpace( const SwTextSizeInfo &rInf, const OUString* pStr,
// Kashida Justification: Insert Kashidas
if ( nEnd > nPos && pSI && COMPLEX == nScript )
{
- if ( SwScriptInfo::IsArabicText( *pStr, nPos, nEnd - nPos ) && pSI->CountKashida() )
+ if ( SwScriptInfo::IsArabicText( *pStr, nPos, nEnd - nPos ) && rInf.GetOut()->GetMinKashida()
+ && pSI->CountKashida() )
{
const sal_Int32 nKashRes = pSI->KashidaJustify( nullptr, nullptr, nPos, nEnd - nPos );
// i60591: need to check result of KashidaJustify
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index 6bca3c4c8a52..c7ab996bf40b 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -1248,7 +1248,8 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
// Kashida Justification
if ( SwFontScript::CTL == nActual && nSpaceAdd )
{
- if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() ) )
+ if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() )
+ && rInf.GetOut().GetMinKashida() )
{
if ( pSI && pSI->CountKashida() &&
pSI->KashidaJustify( pKernArray.get(), nullptr, rInf.GetIdx(),
@@ -1452,7 +1453,8 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
// Kashida Justification
if ( SwFontScript::CTL == nActual && nSpaceAdd )
{
- if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() ) )
+ if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() )
+ && rInf.GetOut().GetMinKashida() )
{
if ( pSI && pSI->CountKashida() &&
pSI->KashidaJustify( pKernArray.get(), pScrArray.get(), rInf.GetIdx(),
@@ -2045,7 +2047,8 @@ sal_Int32 SwFntObj::GetCursorOfst( SwDrawTextInfo &rInf )
// Kashida Justification
if ( SwFontScript::CTL == nActual && rInf.GetSpace() )
{
- if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() ) )
+ if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() )
+ && rInf.GetOut().GetMinKashida() )
{
if ( pSI && pSI->CountKashida() &&
pSI->KashidaJustify( pKernArray.get(), nullptr, rInf.GetIdx(), rInf.GetLen(),