From 3457b03af5220886b4fd0534a1d44bdc5f837851 Mon Sep 17 00:00:00 2001 From: Jason Johnston Date: Tue, 9 Apr 2024 09:43:55 -0600 Subject: [PATCH] fix(troika-three-text): Fix anchorY bottom-baseline. Closes #309 --- packages/troika-three-text/src/Typesetter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/troika-three-text/src/Typesetter.js b/packages/troika-three-text/src/Typesetter.js index a5c1389d..8f3e608f 100644 --- a/packages/troika-three-text/src/Typesetter.js +++ b/packages/troika-three-text/src/Typesetter.js @@ -247,7 +247,7 @@ export function createTypesetter(resolveFonts, bidi) { baseline: -halfLeading - ascender * fontSizeMult, // baseline offset from top of line height // cap: -halfLeading - capHeight * fontSizeMult, // cap from top of line height // ex: -halfLeading - xHeight * fontSizeMult, // ex from top of line height - caretTop: (ascender + descender) / 2 * fontSizeMult + caretHeight / 2, + caretTop, caretBottom: caretTop - caretHeight } metricsByFont.set(fontObj, fontData) @@ -390,7 +390,7 @@ export function createTypesetter(resolveFonts, bidi) { anchorY === 'top-ex' ? -lines[0].ex : anchorY === 'middle' ? totalHeight / 2 : anchorY === 'bottom' ? totalHeight : - anchorY === 'bottom-baseline' ? lines[lines.length - 1].baseline : + anchorY === 'bottom-baseline' ? -lines[lines.length - 1].baseline : parsePercent(anchorY) * totalHeight } }