vcl/source/gdi/impglyphitem.cxx |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit bf8d1290a4de26f06d429148a92cbdb7a63eecf5
Author:     Khaled Hosny <kha...@libreoffice.org>
AuthorDate: Tue May 30 09:48:40 2023 +0300
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Tue May 30 10:54:01 2023 +0200

    tdf#155542: Fix crashtesting assert
    
    When cloning an RTL glyph range, we might end up cutting in the middle
    of a cluster e.g. between a base character and a combining mark since
    both with have the same charPos() after:
    
    commit 09c076c3f29c28497f162d3a5b7baab040725d56
    Author: Khaled Hosny <kha...@aliftype.com>
    Date:   Wed Oct 5 21:00:46 2022 +0200
    
        tdf#151350: Fix extraneous gaps before marks
    
    (which changed how HarfBuzz sets up clusters back to the default where
    marks form clusters with their bases, before that a mark formed its own
    cluster).
    
    This leads to the cloned glyph range to include the glyph for the
    combining marks, while it is not included in the text string.
    
    Change-Id: I83031e0e0ffc7c5932101649a9cc2bf953a6347d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152380
    Tested-by: Jenkins
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index fed2ee0f3fe7..315bdf4f58bb 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -137,9 +137,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 RTL make sure we're not cutting in the middle of a multi-character 
glyph,
+    // or in the middle of a cluster
     // (for non-RTL charPos is always the start of a multi-character glyph).
-    if (rtl && pos->charPos() + pos->charCount() > beginPos + 1)
+    if (rtl && (pos->charPos() + pos->charCount() > beginPos + 1 || 
pos->IsInCluster()))
         return nullptr;
     if (!isSafeToBreak(pos, rtl))
         return nullptr;

Reply via email to