Skip to content

Commit

Permalink
Fixed error rendering Burmese text
Browse files Browse the repository at this point in the history
Fixed an uncaught exception determining line break opportunities in Burmese text where a word is split down the middle at a word boundary.
  • Loading branch information
1ec5 committed Aug 28, 2024
1 parent 29de7cc commit ebff14d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/symbol/shaping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit ebff14d

Please sign in to comment.