View all expressions
Transformation

Auto-Scaling Text Layer with Width Constraints

Automatically scales a text layer to ensure its width stays within a specified limit. The text adjusts its size dynamically to fit within the bounds, providing a responsive design solution.

Contributed by:


textWidth = sourceRectAtTime(time, false).width;
defaultLimit = thisComp.width;
customLimit = effect("Width Limit")("Slider");
widthLimit = (customLimit > 0) ? customLimit : defaultLimit;
if (textWidth > 0) {
scaleFactor = (widthLimit / textWidth) * 100;
clampedScale = clamp(scaleFactor, 0, 100);
[clampedScale, clampedScale];}
else {
value;}

Auto-Scaling Text Layer with Width Constraints

Practical use case

Perfect for auto-scaling subtitles, banners, or text that needs to adapt to varying character counts without exceeding a defined width, ensuring consistency in responsive layouts.

Check out similar expressions

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

a mesh of elegant lines transparent image