2

After-Effects newbie here.

I have many many text lines all using exactly the same font. How can I best add background color textboxes with a consistent height?

The color background must not change height depending on the text. The top two green textbox colors are what I want. The bottom two red textbox colors, changing height depending on the letters, are what I am getting.

enter image description here

I tried box-blur/shift-channels techniques (example) but the textbox heights are not consistent.

I also tried expression techniques using sourceRectAtTime() on size and/or position of the shape (example) but again the textbox height changes depending on letters used.

I am experimenting with anchors and baseline and suspect there is a solution somewhere there but I am getting very confused and suspect I am reinventing the wheel badly. Surely there must be a widely used solution for this but I cannot find it!

Many thanks, Polly

1 Answer 1

2

Make a text layer called “Text”.

Align the text centrally using the Paragraph controls.

Make a filled rectangular shape layer beneath it.

Add two sliders to the shape layer called "horizontal padding"and "vertical padding".

Apply this expression to the size control in the shape layer:

var s = thisComp.layer("Text");
var w = s.sourceRectAtTime().width;
var h = s.sourceRectAtTime().height;  // note this isn't used
var paddinghorizontal = effect("horizontal padding")("Slider");
var paddingvertical = effect("vertical padding")("Slider");

[w + paddinghorizontal,100 + paddingvertical];

The last line of the code above sets the width and the height of the box, ie [width, height]. The height is set to 100 (an arbitrary value), plus whatever vertical padding you add later.

Write the largest vertical text you will need.

Adjust the position of the shape layer.

Adjust the height of the text layer using the vertical padding Slider control.

Adjust the horizontal padding to make it look good.

screengrab

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.