ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Size of text to be size of comp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Andrew Ross
Size of text to be size of comp
on Feb 6, 2020 at 10:40:35 am
Last Edited By Andrew Ross on Feb 6, 2020 at 12:46:10 pm

Hi there

I have lots of text captions to render off as still frames and then an editor is going to be using them to overlay in an edit

I want to make the process as streamlined as possible, so I am using the to make the naming process easier but i was wondering if there is any way using an expression in the scale property, to make the text as large as it can be in the composition, no matter what the text is changed to, keeping it's proportions in order for the editor to have the largest text possible to reposition and rescale as needed.

So the process i want is as follows: Create a new comp, call the new comp for example GRAPHIC ONE. The expression would make the text as big as it can be in the composition whilst maintaining proportions and without any cropping. Next I would duplicate GRAPHIC ONE comp in the project panel and rename it, for example, to YES. The expression would then automatically scale the YES text to fill the frame as much as it can without cropping and so on. This way, all i need to do is rename the comps in the project panel and then render rather than having to go in to each comp to resize the layer.

I've stumbled across similar posts and some that i think could work with a bit of adaption but my scripting skills aren't anywhere near what they need to be at, in order to adapt an existing expression in to something that works for me.

Thanks in advance

Return to posts index

Tomas Bumbulevičius
Re: Size of text to be size of comp
on Feb 7, 2020 at 6:28:32 am

Hey Andrew,

do the following steps:

1. Apply expression to anchor point on the text layer:

sourceSize = thisLayer.sourceRectAtTime(time, false);
T =;
L = sourceSize.left;
W = sourceSize.width;
H = sourceSize.height;
([L+ W/2,T+H/2])

2. To make sure text is always in center, add this for position expression:

H = thisComp.height;
W = thisComp.width;
[W/2, H/2]

3. Apply expression for scaling:

layerW = thisLayer.sourceRectAtTime(time).width;
compW = thisComp.width;
maxW = compW;
s = maxW / layerW * 100;

Assuming you have in text's source, it will work regardless of text size. This works well enough from 3characters length. If shorter, it will exceed top boundaries and would require extra few lines into consideration. Good luck!

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview

Return to posts index

Andrew Ross
Re: Size of text to be size of comp
on Feb 10, 2020 at 12:00:20 pm

Tomas my friend you are a complete genius thank you.

There will be no need to go below three letters so what you have supplied above works absolutely fantastically.

Thank you so much : )

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 All Rights Reserved