I'm building a Mogrt using After Effects. I need to be able to drive the size of a paragraph text box dynamically using expressions.
Is that possible? I can't find a parameter related to this.
Video Production Stack Exchange is a question and answer site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation. It only takes a minute to sign up.Sign up to join this community
It's not possible directly from what I understand, but you can make a "faux text box" and alter the scale while inversely altering the text size and leading.
For example, add a paragraph text box and resize it (closely) to 1920x1080. Drag the anchor to the upper left corner. The anchor point will be the point the text box scales from. Then add 3 sliders to the text layer: FontSize, TextBoxWidth, and FontLeading. Set these sliders to arbitrary values to start, maybe 16 for FontSize, 800 for TextBoxWidth, and 1.6 for FontLeading.
Add this as the Source Text expression
textSize = effect("FontSize")("Slider"); targetWidth = effect("TextBoxWidth")("Slider"); textLeading = effect("FontLeading")("Slider"); originalBoxWidth = 1920; boxScale = targetWidth / originalBoxWidth; text.sourceText.style.setFontSize(textSize / boxScale).setLeading(textSize * textLeading / boxScale);
Add this expression to Transform > Scale of the text layer.
targetWidth = effect("TextBoxWidth")("Slider"); originalBoxWidth = 1920; boxScale = targetWidth / originalBoxWidth; value * boxScale;
You'll then be able to adjust the sliders to set the text box width, font size, and leading.
See this video for more details: