From 737854f3c5131d3a64803edc0802dbbc07aa4405 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 1 Jun 2023 12:23:05 +0300 Subject: tdf#153440: Fix font fallback for surrogate pairs in RTL text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When checking for a font that supports the surrogate pair, code was appending code units one by one to string buffer and in RTL case this was happening in reverse order leading to invalid text and consequently failing to find any font that supports it. We now iterate over runs not individual positions, so the text of each individual run maintains its correct order regardless of the direction. Change-Id: Icf2e2aed56512bf907dc6b3c36f387a9e3ad497a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152481 Tested-by: Jenkins Reviewed-by: خالد حسني --- vcl/source/outdev/font.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 6e8db56e06a3..3bfbb8f6d8ce 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1040,11 +1040,11 @@ std::unique_ptr OutputDevice::ImplGlyphFallbackLayout( std::unique_pt rLayoutArgs.mnFlags |= SalLayoutFlags::ForFallback; // get list of code units that need glyph fallback - int nCharPos = -1; - bool bRTL = false; + bool bRTL; + int nMinRunPos, nEndRunPos; OUStringBuffer aMissingCodeBuf(512); - while (rLayoutArgs.GetNextPos( &nCharPos, &bRTL)) - aMissingCodeBuf.append(rLayoutArgs.mrStr[nCharPos]); + while (rLayoutArgs.GetNextRun(&nMinRunPos, &nEndRunPos, &bRTL)) + aMissingCodeBuf.append(rLayoutArgs.mrStr.subView(nMinRunPos, nEndRunPos - nMinRunPos)); rLayoutArgs.ResetPos(); OUString aMissingCodes = aMissingCodeBuf.makeStringAndClear(); -- cgit