View all expressions
Conditional

Font Size Based on Character Count

Shrinks font size automatically as the number of characters increases, preventing overflow or layout issues.

Contributed by:


startSize = 60;
// Starting font size
step = 10;
// Decrease size per threshold
minFontSize = 30;
// Prevent font from getting too small
charThreshold = 90;
// Shrink once per this many characters
charCount = text.sourceText.length;
stepsToShrink = Math.floor(charCount / charThreshold);
newSize = Math.max(minFontSize, startSize - (stepsToShrink * step));
text.sourceText.style.setFontSize(newSize);

Font Size Based on Character Count

Practical use case

Perfect for templates where the text input can vary in length, such as dynamic names, titles, or personalized data fields.

Check out similar expressions

Data-driven video workflows for After Effects are easier with Plainly.

a mesh of elegant lines transparent image