[Libreoffice-commits] core.git: vcl/source
Khaled Hosny
khaledhosny at eglug.org
Mon Mar 12 22:05:40 UTC 2018
vcl/source/outdev/text.cxx | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
New commits:
commit 489c7088b4a99720d1a2839ed52b3becd7aac342
Author: Khaled Hosny <khaledhosny at eglug.org>
Date: Mon Mar 12 17:41:36 2018 +0200
tdf#116322: Don’t hard-code RTL character ranges
Calc’s ScOutputData::LayoutStrings() has an optimization that skips edit
engine for what it seems to consider simple enough text (single script,
no bidi controls, etc) and it ends up calling this code in OutputDevice
that hard-codes RTL character ranges and skips bidi algorithm if none is
found. Since the list of RTL characters is not fixed and new version of
Unicode can added new RTL characters, help the next boor soul that will
spend another day debugging this in the future by removing the
hard-coded RTL ranges and instead check for some known LTR ranges.
Change-Id: I6eb8fd3d1342a5539d607bf54e9c2de31f5a32b4
Reviewed-on: https://gerrit.libreoffice.org/51118
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index ef7f4c249642..f51dbabc558c 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1190,15 +1190,20 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr,
nLayoutFlags |= SalLayoutFlags::BiDiStrong;
else if( !(mnTextLayoutMode & ComplexTextLayoutFlags::BiDiRtl) )
{
- // disable Bidi if no RTL hint and no RTL codes used
- const sal_Unicode* pStr = rStr.getStr() + nMinIndex;
- const sal_Unicode* pEnd = rStr.getStr() + nEndIndex;
- for( ; pStr < pEnd; ++pStr )
- if( ((*pStr >= 0x0580) && (*pStr < 0x0800)) // middle eastern scripts
- || ((*pStr >= 0xFB18) && (*pStr < 0xFE00)) // hebrew + arabic A presentation forms
- || ((*pStr >= 0xFE70) && (*pStr < 0xFEFF)) ) // arabic presentation forms B
+ // Disable Bidi if no RTL hint and only known LTR codes used.
+ bool bAllLtr = true;
+ for (sal_Int32 i = nMinIndex; i < nEndIndex; i++)
+ {
+ // [0x0000, 0x052F] are Latin, Greek and Cyrillic.
+ // [0x0370, 0x03FF] has a few holes as if Unicode 10.0.0, but
+ // hopefully no RTL character will be encoded there.
+ if (rStr[i] > 0x052F)
+ {
+ bAllLtr = false;
break;
- if( pStr >= pEnd )
+ }
+ }
+ if (bAllLtr)
nLayoutFlags |= SalLayoutFlags::BiDiStrong;
}
More information about the Libreoffice-commits
mailing list