diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-04-27 22:40:43 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-04-28 07:21:46 +0200 |
commit | 7b7d2f4a3e96e771e125c95a7d262b20f6dc9ecc (patch) | |
tree | 2a78e70d439d230eb610e74ad561566948103171 | |
parent | c8a7a6d600c2fb0ebe84c97553b2754936122023 (diff) |
don't cut a glyph subset inside a composed glyph
A glyph may may composed from several characters, when asked to make
a glyph subset for a character range, make sure the end of the range
is not inside this character group.
Change-Id: I41d82b432858a87e103dcb0d2fac6a11f25a32dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133530
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r-- | vcl/source/gdi/impglyphitem.cxx | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx index 5896d5bfeb7c..8ea80293ee08 100644 --- a/vcl/source/gdi/impglyphitem.cxx +++ b/vcl/source/gdi/impglyphitem.cxx @@ -113,7 +113,13 @@ SalLayoutGlyphsImpl* SalLayoutGlyphsImpl::cloneCharRange(sal_Int32 index, sal_In // that's how it's computed in GenericSalLayout::LayoutText(). DevicePoint zeroPoint = pos->linearPos() - DevicePoint(pos->xOffset(), pos->yOffset()); // Add and adjust all glyphs until the given length. - while (pos != end() && pos->charPos() < index + length) + // The check is written as 'charPos + charCount <= index + length' rather than + // 'charPos < index + length' to make sure we include complete glyphs. If a glyph is composed + // from several characters, we should not cut in the middle of those characters, so this + // checks the glyph is entirely in the given character range. If it is not, this will end + // the loop and the later 'pos->charPos() != endPos' check will fail and bail out. + // CppunitTest_sw_layoutwriter's testCombiningCharacterCursorPosition would fail without this. + while (pos != end() && pos->charPos() + pos->charCount() <= index + length) { if (pos->IsRTLGlyph()) return nullptr; // Don't mix RTL and non-RTL runs. |