vcl/source/gdi/CommonSalLayout.cxx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
New commits: commit ffd404384ec7f2c41451783f999a636f4e581441 Author: Khaled Hosny <kha...@aliftype.com> AuthorDate: Fri Sep 2 11:10:27 2022 +0200 Commit: خالد حسني <kha...@aliftype.com> CommitDate: Fri Sep 2 12:46:48 2022 +0200 More graceful fix for cid#513473 Though I don’t think it is possible to have a zero grapheme cluster count, lets be more graceful and assume it is not a ligature and take the other branch. Also a grapheme cluster of one is not a ligature for our purpose, so check for that even. Change-Id: Ie52af1127a05f55cdfc858d47e128fa0f783f710 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139254 Tested-by: Jenkins Reviewed-by: خالد حسني <kha...@aliftype.com> diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 70bfb07aea8a..db5575fb8c82 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -653,29 +653,30 @@ void GenericSalLayout::GetCharWidths(std::vector<DeviceCoordinate>& rCharWidths, { if (aGlyphItem.charPos() >= mnEndCharPos) continue; + + unsigned int nGraphemeCount = 0; if (aGlyphItem.charCount() > 1 && aGlyphItem.newWidth() != 0 && !rStr.isEmpty()) { // We are calculating DX array for cursor positions and this is a - // ligature, we want to distribute the glyph width over the - // ligature components. + // ligature, find out how many grapheme clusters are in it. if (!xBreak.is()) xBreak = mxBreak.is() ? mxBreak : vcl::unohelper::CreateBreakIterator(); + // Count grapheme clusters in the ligature. sal_Int32 nDone; sal_Int32 nPos = aGlyphItem.charPos(); - unsigned int nGraphemeCount = 0; - - // Count grapheme clusters in the ligatures. while (nPos < aGlyphItem.charPos() + aGlyphItem.charCount()) { nPos = xBreak->nextCharacters(rStr, nPos, aLocale, css::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); nGraphemeCount++; } + } - if (!nGraphemeCount) - continue; - + if (nGraphemeCount > 1) + { + // More than one grapheme cluster, we want to distribute the glyph + // width over them. std::vector<DeviceCoordinate> aWidths(nGraphemeCount); // Check if the glyph has ligature caret positions. @@ -722,7 +723,8 @@ void GenericSalLayout::GetCharWidths(std::vector<DeviceCoordinate>& rCharWidths, } // Set the width of each grapheme cluster. - nPos = aGlyphItem.charPos(); + sal_Int32 nDone; + sal_Int32 nPos = aGlyphItem.charPos(); for (auto nWidth : aWidths) { rCharWidths[nPos - mnMinCharPos] += nWidth;