An auto-scaling text box is an incredible time-saving tool that isn’t yet built into After Effects, but you can create it yourself with the help of expressions. Although the tutorial below won’t run through exactly what every bit of code is, it will give you the information you need to get the job done — without coding from scratch.
Dynamic text boxes in After Effects, like this auto-scaling box, give your projects visual interest and keep the viewer engaged and enjoying your work. So, let’s jump in to see how to auto scale text boxes in After Effects.
Summary
The power of typography: How a simple text box in After Effects will boost your editing
Before you create your first dynamic text box in After Effects, let’s discuss text boxes and typography. These are surprisingly simple, but very useful tools for editors to make their videos stand out.
Dynamic text boxes in After Effects are containers for the words, letting you add writing to your videos easily. Think of them as sticky notes you can put anywhere on your video. You can use them for titles, subtitles, or even lower thirds to show someone’s name when they’re talking.
One cool thing about text boxes is that you can move them around. Want your title at the top? Easy! Need it at the bottom? No problem! You can even make the text move across the screen or have the box size itself to fit, as you’ll learn today. This helps make your video more lively and interesting, which is important for social media content.
Once you’ve made your text box in After Effects, you need to make it look good. This is where typography styling comes into play. You want your text to work and add creative value, like choosing the right clothes for your words to wear.
With font styling, you can change how your letters look, making them big or small, thick or thin. You can even make fonts blurry. You can choose different fonts to match the mood of your video — some look serious, others look fun. A scary movie, for example, might use spooky letters, while a happy video for kids about puppies might use round, friendly letters.
Colors are part of font styling, too. You can make your words any color you want, but there are some things to consider. Firstly, you should use color to help your dynamic text box in After Effects stand out from the background video. Consider having them match or complement other things in your video for a nice, put-together look.
You can also add cool effects to your text. For example, you can make it glow, give it a shadow, or make it wavy. These effects can give your video a more professional and exciting feel.
Why is all this valuable to editors? Well, it gives you more ways to tell your story. Sometimes, words can say things that pictures can’t — and when those words look good, they help make your whole video better.
Good typography also helps guide viewers. Big, bold text can show important information, while smaller text can provide extra details. By using different styles, you can help viewers understand what’s most important in your video.
In short, font styling and text boxes in After Effects give you a whole extra set of tools in your editing toolbox. They help you add information, set the mood, and make your videos look more professional. And the best part? You can be really creative with them and even use them to animate your text.
How to make an auto-scaling text box in After Effects
Today you’ll learn how to make a dynamic text box in After Effects. This box will auto scale as the text changes, whether between fonts or as new words arrive on the screen. Not only is this handy to help you with sizing the box correctly, it also packs a visual punch. So, let’s get started.
Step 1: Create a text box in After Effects
- Create a new composition at 1920×1080 29.97.
- Create a new Text layer inside this composition and type in whatever you want.
- Go to Layer > New > Shape Layer. Name the new shape layer “Text Box.”
- Add a Rectangle to the Text Box layer and add a Fill.
- Twirl down the properties for the Rectangle path and Alt (Option for Mac) + click on the Stopwatch for the Size property.
Step 2: Create an expression to autoscale the text box
Now we need to add a little coding to our dynamic text box in After Effects. It looks tricky, but you can copy the code below to get the job done. To add this custom code, you’ll use the Expression Editor. Click within the text box from your Timeline panel to activate the Expression Editor.
- Before writing any code in the Expression Editor, quickly define a variable to reference the text layer. Type “s=” and use the pick whip to link to the Text layer, then add a semicolon (;).
- Hit return to start a new line of code, and add in the following:
w=s.sourceRectAtTime().width;
h=s.sourceRectAtTime().height;
[w,h]
Your full expression should look like this:
s=thisComp.layer(“My Text Layer”);
w=s.sourceRectAtTime().width;
h=s.sourceRectAtTime().height;
[w,h]
This code defines 2 new variables and then uses them as the X and Y size values. “sourceRectAtTime()” references the size of the text layer.
Step 3: Reposition the text box
Congratulations — you’ve made a dynamic text box in After Effects that will always be the right size, no matter what it contains. All that’s left is to ensure it’s in the right position.
- Grab the Rectangle near the top left corner. Hold Ctrl (Cmd for Mac) and drag it to the top left corner of the Text layer. Holding Control (Command for Mac) will make it snap.
- Access the Position of the rectangle path (not the layer) and apply the following expression:
s=thisComp.layer(“My Text Layer”);
w=s.sourceRectAtTime().width/2;
h=s.sourceRectAtTime().height/2;
l=s.sourceRectAtTime().left;
t=s.sourceRectAtTime().top;
[w+l,h+t]
You’ll notice this expression is similar to the one you used for the size.
The difference is 2 new variables that look at where the text layer’s top and left boundaries are. These help place the box in the right spot.
Step 4: Add padding between the box and the text
Now the coding is done and you have a box the same size as your text. The problem is that it’s only as big as the text, so there’s no padding. In most cases, you’ll want a little padding for visual appeal as well as to keep things clear on the screen. To create some breathing room for your text box in After Effects, here’s what to do:
- From the Shape layer menu, add offset paths to the text box layer. Adjust the Offset Path amount to add or subtract padding.
- The great thing about this text box being a shape layer is you can also add a Stroke for even more customization. Play around with this until you get something you’re pleased with visually.
For added flexibility, it’s a good idea to parent the text box to the text layer. That way, you can move the text layer wherever you need to in the comp and the text box will follow.
This also means you can adjust the scale and rotation of the text layer, and the text box will adjust with it. Pretty slick, right? You’ve now made your first dynamic text box in After Effects.
You can also try other text effects, like making a typewriter look for your on-screen writing.
It’s worth taking time to learn more about expressions as they can be applied to many situations. Learning to create an auto-scaling text box in After Effects is an excellent place to start. If you’d like to know more about the nitty-gritty of this expression and customize it even further, check out this tutorial by Jake In Motion.
Now you’ve powered up your project with a dynamic text box in After Effects, why not try out some other cool effects? You may like to try making 3D titles from scratch.