From f71679e97a3850057ff85054d10326c8100c5328 Mon Sep 17 00:00:00 2001 From: Jason Johnston Date: Sat, 9 Nov 2024 22:01:16 -0700 Subject: [PATCH] fix(troika-three-text): Fix error when first character is whitespace #313 --- packages/troika-three-text/src/FontResolver.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/troika-three-text/src/FontResolver.js b/packages/troika-three-text/src/FontResolver.js index e4ecf5a1..6d5741c8 100644 --- a/packages/troika-three-text/src/FontResolver.js +++ b/packages/troika-three-text/src/FontResolver.js @@ -147,13 +147,13 @@ export function createFontResolver(fontParser, unicodeFontResolverClient) { // - this character is whitespace if ( (prevCharResult === RESOLVED && fontResolutions[charResolutions[i - 1]].supportsCodePoint(codePoint)) || - /\s/.test(text[i]) + (i > 0 && /\s/.test(text[i])) ) { charResolutions[i] = charResolutions[i - 1] if (prevCharResult === NEEDS_FALLBACK) { fallbackRanges[fallbackRanges.length - 1][1] = i } - } else { + } else { for (let j = charResolutions[i], jLen = userFonts.length; j <= jLen; j++) { if (j === jLen) { // none of the user fonts matched; needs fallback