lottie: corrected text height alignment issues.

enhanced support for a wider range of text use cases.
This commit is contained in:
Hermet Park 2024-01-29 16:29:23 +09:00 committed by Hermet Park
parent 5d02b3ac42
commit fb4ad7d239

View file

@ -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);