tdf#152737: Fix off-by-one errors

Regressions from:

commit 718af94043
Author: Khaled Hosny <khaled@aliftype.com>
Date:   Fri Dec 16 00:10:34 2022 +0200

    tdf#152533: Improve script handling in font preview

and:

commit bfecacb248
Author: Khaled Hosny <khaled@aliftype.com>
Date:   Thu Dec 15 22:51:54 2022 +0200

    tdf#152460: Improve script handling in style previews

Change-Id: I7b12f5accbd65459d724676efb7bec947a7faaa0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144880
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
This commit is contained in:
Khaled Hosny 2022-12-30 18:56:41 +02:00 committed by خالد حسني
parent a838f92bb4
commit 95f0dc2dc7
2 changed files with 6 additions and 2 deletions

View file

@ -250,7 +250,9 @@ void FontPrevWin_Impl::CheckScript()
for (sal_Int32 i = 1; i <= maScriptText.getLength(); i++)
{
auto aNextScript = aEditEngine.GetScriptType({ 0, i, 0, i });
if (aNextScript != aScript || i == maScriptText.getLength())
if (aNextScript != aScript)
maScriptChanges.emplace_back(aScript, i - 1);
else if (i == maScriptText.getLength())
maScriptChanges.emplace_back(aScript, i);
aScript = aNextScript;
}

View file

@ -418,7 +418,9 @@ void CommonStylePreviewRenderer::CheckScript()
for (sal_Int32 i = 1; i <= maScriptText.getLength(); i++)
{
auto aNextScript = aEditEngine.GetScriptType({ 0, i, 0, i });
if (aNextScript != aScript || i == maScriptText.getLength())
if (aNextScript != aScript)
maScriptChanges.emplace_back(aScript, i - 1);
else if (i == maScriptText.getLength())
maScriptChanges.emplace_back(aScript, i);
aScript = aNextScript;
}