vcl/source/gdi/impglyphitem.cxx |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 5d02daa5198d5bff9234d5db698e934a5e31c95f
Author:     Luboš Luňák <[email protected]>
AuthorDate: Mon May 23 09:29:24 2022 +0200
Commit:     Luboš Luňák <[email protected]>
CommitDate: Mon May 23 10:34:04 2022 +0200

    handle RTL space in non-RTL layout in SalLayoutGlyphsCache
    
    Reproduced with tdf#95217-1 on the crashtesting server.
    
    Change-Id: I44dfa762b624ca24a8bd4ce8df03f8c870d4e7c4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134755
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <[email protected]>

diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index 3711d3298039..a3ab689ff23e 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -164,7 +164,7 @@ SalLayoutGlyphsImpl* 
SalLayoutGlyphsImpl::cloneCharRange(sal_Int32 index, sal_In
         if (!isSafeToBreak(pos, rtl))
             return nullptr;
     }
-    // HACK: If mode is se to be RTL, but the last glyph is a non-RTL space,
+    // HACK: If mode is set to be RTL, but the last glyph is a non-RTL space,
     // then making a subset would give a different result than the actual 
layout,
     // because the weak BiDi mode code in ImplLayoutArgs ctor would interpret
     // the string subset ending with space as the space being RTL, but it would
@@ -174,6 +174,12 @@ SalLayoutGlyphsImpl* 
SalLayoutGlyphsImpl::cloneCharRange(sal_Int32 index, sal_In
     {
         return nullptr;
     }
+    // Similarly, if mode is not RTL but the last glyph is an RTL space.
+    if (!(GetFlags() & SalLayoutFlags::BiDiRtl) && rtl && !copy->empty()
+        && copy->back().IsSpacing())
+    {
+        return nullptr;
+    }
     return copy.release();
 }
 

Reply via email to