From 9063d99ff5ee43cc1239fc1dbb5d9897bdda1c9b Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Sun, 2 Oct 2022 22:45:24 +0200 Subject: tdf#137528: Fix skipping Kashida in fonts with bogus ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There was a typo in the check, and we also want to fallback to using blanks if no Kashidas were found, so check for Kashida positions first. Change-Id: I64cc3bf5c76ecc01764073bb5a2302520157fad8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140896 Tested-by: Jenkins Reviewed-by: خالد حسني --- editeng/source/editeng/impedit3.cxx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index cf30aada8448..6efc74d95cfe 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -2190,14 +2190,19 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, // Search blanks or Kashidas... std::vector aPositions; + + // Kashidas ? + ImpFindKashidas( pNode, nFirstChar, nLastChar, aPositions ); + auto nKashidas = aPositions.size(); + sal_uInt16 nLastScript = i18n::ScriptType::LATIN; for ( sal_Int32 nChar = nFirstChar; nChar <= nLastChar; nChar++ ) { EditPaM aPaM( pNode, nChar+1 ); LanguageType eLang = GetLanguage(aPaM).nLang; sal_uInt16 nScript = GetI18NScriptType(aPaM); - if ( MsLangId::getPrimaryLanguage( eLang) == LANGUAGE_ARABIC_PRIMARY_ONLY ) - // Arabic script is handled later. + // Arabic script is handled above, but if no Kashida positions are found, use blanks. + if (MsLangId::getPrimaryLanguage(eLang) == LANGUAGE_ARABIC_PRIMARY_ONLY && nKashidas) continue; if ( pNode->GetChar(nChar) == ' ' ) @@ -2223,13 +2228,6 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, nLastScript = nScript; } - // Save the number of blanks, we will use it below when marking Kashida - // positions. - auto nBlankSize = aPositions.size(); - - // Kashidas ? - ImpFindKashidas( pNode, nFirstChar, nLastChar, aPositions ); - if ( aPositions.empty() ) return; @@ -2268,10 +2266,10 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, // Mark Kashida positions, so that VCL knows where to insert Kashida and // where to only expand the width. - if (aPositions.size() > nBlankSize) + if (nKashidas) { pLine->GetKashidaArray().resize(pLine->GetCharPosArray().size(), false); - for (auto i = nBlankSize; i < aPositions.size(); i++) + for (size_t i = 0; i < nKashidas; i++) { auto nChar = aPositions[i]; if ( nChar < nLastChar ) @@ -2316,7 +2314,7 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, std::vector& rArray ) { // Kashida glyph looks suspicious, skip Kashida justification - if (GetRefDevice()->GetMinKashida() < 0) + if (GetRefDevice()->GetMinKashida() <= 0) return; std::vector aKashidaArray; -- cgit