From 1eae64bb0cdef3b6048299fcd194c1a16cf252b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 23 Aug 2024 05:18:34 -0700 Subject: [PATCH] Fixed section index after bidi processing --- src/symbol/shaping.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/symbol/shaping.ts b/src/symbol/shaping.ts index eb802b9dcdd..772d3923ad0 100644 --- a/src/symbol/shaping.ts +++ b/src/symbol/shaping.ts @@ -310,8 +310,12 @@ function shapeText( const taggedLine = new TaggedString(); // Restore zero-width joiners from temporary strip markers. taggedLine.text = line[0].replace(/\uF8FF/g, '\u200D'); - taggedLine.sectionIndex = line[1]; taggedLine.sections = logicalInput.sections; + let elapsedChars = ''; + for (const char of splitByGraphemeCluster(line[0])) { + taggedLine.sectionIndex.push(line[1][elapsedChars.length]); + elapsedChars += char; + } lines.push(taggedLine); } } else {