lottie/text: Support text tracking

Text Tracking value("tr") is parsed and never used.

Calculate text spacing size via the tracking offset.

Issue: #2254
This commit is contained in:
Jinny You 2024-05-09 14:06:15 +09:00 committed by Hermet Park
parent 6bf069fa7a
commit 1e7cf2f5f9
3 changed files with 3 additions and 3 deletions

View file

@ -606,7 +606,7 @@ static void _updateText(LottieGroup* parent, LottieObject** child, float frameNo
p += glyph->len; p += glyph->len;
//advance the cursor position horizontally //advance the cursor position horizontally
cursor.x += glyph->width + spacing; cursor.x += glyph->width + spacing + doc.tracking;
break; break;
} }
} }

View file

@ -183,7 +183,7 @@ void LottieParser::getValue(TextDocument& doc)
else if (KEY_AS("f")) doc.name = getStringCopy(); else if (KEY_AS("f")) doc.name = getStringCopy();
else if (KEY_AS("t")) doc.text = getStringCopy(); else if (KEY_AS("t")) doc.text = getStringCopy();
else if (KEY_AS("j")) doc.justify = getInt(); else if (KEY_AS("j")) doc.justify = getInt();
else if (KEY_AS("tr")) doc.tracking = getInt(); else if (KEY_AS("tr")) doc.tracking = getFloat() * 0.1f;
else if (KEY_AS("lh")) doc.height = getFloat(); else if (KEY_AS("lh")) doc.height = getFloat();
else if (KEY_AS("ls")) doc.shift = getFloat(); else if (KEY_AS("ls")) doc.shift = getFloat();
else if (KEY_AS("fc")) getValue(doc.color); else if (KEY_AS("fc")) getValue(doc.color);

View file

@ -75,8 +75,8 @@ struct TextDocument
} stroke; } stroke;
char* name = nullptr; char* name = nullptr;
float size; float size;
float tracking;
uint8_t justify; uint8_t justify;
uint8_t tracking;
}; };