From fb4ad7d2391ffc6f7988070aeb854b0b8213e9ec Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 29 Jan 2024 16:29:23 +0900 Subject: [PATCH] lottie: corrected text height alignment issues. enhanced support for a wider range of text use cases. --- src/loaders/lottie/tvgLottieBuilder.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/loaders/lottie/tvgLottieBuilder.cpp b/src/loaders/lottie/tvgLottieBuilder.cpp index 4d777d94..4efbc2ef 100644 --- a/src/loaders/lottie/tvgLottieBuilder.cpp +++ b/src/loaders/lottie/tvgLottieBuilder.cpp @@ -496,11 +496,13 @@ static void _updateText(LottieGroup* parent, LottieObject** child, float frameNo } //text layout position - Point layout = {doc.bbox.pos.x, (doc.bbox.pos.y * 0.5f) - doc.shift}; + auto ascent = text->font->ascent * scale; + if (ascent > doc.bbox.size.y) ascent = doc.bbox.size.y; + Point layout = {doc.bbox.pos.x, doc.bbox.pos.y + ascent - doc.shift}; //adjust the layout - if (doc.justify == 1) layout.x -= (cursor.x * scale); //right aligned - else if (doc.justify == 2) layout.x -= (cursor.x * 0.5f * scale); //center aligned + if (doc.justify == 1) layout.x += doc.bbox.size.x - (cursor.x * scale); //right aligned + else if (doc.justify == 2) layout.x += (doc.bbox.size.x * 0.5f) - (cursor.x * 0.5f * scale); //center aligned scene->translate(layout.x, layout.y); scene->scale(scale);