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

New commits:
commit 825102492a04752c4cebf6c84e2c8639de983e9b
Author:     Luboš Luňák <[email protected]>
AuthorDate: Thu Apr 28 12:00:00 2022 +0200
Commit:     Luboš Luňák <[email protected]>
CommitDate: Thu Apr 28 14:34:00 2022 +0200

    don't cut a glyph subset inside a composed glyph #2
    
    This is basically the same like 7b7d2f4a3e96e771e125c95a7d262b20f6dc9ecc,
    triggered by CppunitTest_sw_uiwriter3's testTdf104649 on Mac.
    
    Change-Id: Ibb3c33dd6924e8f0c8856185fc7fb7aeaaf72177
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133545
    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 93f70a853a74..bffa490065c6 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -123,6 +123,10 @@ SalLayoutGlyphsImpl* 
SalLayoutGlyphsImpl::cloneCharRange(sal_Int32 index, sal_In
     // Require a start at the exact position given, otherwise bail out.
     if (pos->charPos() != beginPos)
         return nullptr;
+    // For RTL make sure we're not cutting in the middle of a multi-character 
glyph
+    // (for non-RTL charPos is always the start of a multi-character glyph).
+    if (rtl && pos->charPos() + pos->charCount() > beginPos + 1)
+        return nullptr;
     // Don't create a subset if it's not safe to break at the beginning or end 
of the sequence
     // (https://harfbuzz.github.io/harfbuzz-hb-buffer.html#hb-glyph-flags-t).
     if (pos->IsUnsafeToBreak() || (pos->IsInCluster() && 
!pos->IsClusterStart()))
@@ -149,7 +153,7 @@ SalLayoutGlyphsImpl* 
SalLayoutGlyphsImpl::cloneCharRange(sal_Int32 index, sal_In
     }
     if (pos != end())
     {
-        // Fail if the next character is at the expected past-end position. 
For RTL check
+        // Fail if the next character is not at the expected past-end 
position. For RTL check
         // that we're not cutting in the middle of a multi-character glyph.
         if (rtl ? pos->charPos() + pos->charCount() != endPos + 1 : 
pos->charPos() != endPos)
             return nullptr;

Reply via email to