From ebff14d825151f3be1ec71c614e930bf747fab07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 27 Aug 2024 22:33:47 -0700 Subject: [PATCH] Fixed error rendering Burmese text Fixed an uncaught exception determining line break opportunities in Burmese text where a word is split down the middle at a word boundary. --- src/symbol/shaping.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/symbol/shaping.ts b/src/symbol/shaping.ts index 379f158e2f..48b131c989 100644 --- a/src/symbol/shaping.ts +++ b/src/symbol/shaping.ts @@ -392,6 +392,7 @@ function getGlyphAdvance( spacing: number, layoutTextSize: number ): number { + if (!section) console.log('getGlyphAdvance', grapheme, section); if (!section.imageName) { const positions = glyphMap[section.fontStack]; const glyph = positions && positions[grapheme]; @@ -533,8 +534,10 @@ export function determineLineBreaks( let graphemeIndex = 0; for (const {index: wordIndex, segment: word} of wordSegmenter.segment(logicalInput.text)) { const graphemes = splitByGraphemeCluster(word); + let section; for (const grapheme of graphemes) { - const section = logicalInput.getSection(graphemeIndex); + // Grapheme cluster could be split across a word boundary. Fall back to the last known section. + section = logicalInput.getSection(graphemeIndex) || section; if (!!grapheme.trim()) { currentX += getGlyphAdvance(grapheme, section, glyphMap, imagePositions, spacing, layoutTextSize); }