ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

If text layer has specific letter

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Adam Haas
If text layer has specific letter
on Nov 15, 2017 at 9:19:21 pm

I'm making lower thirds scripting as much as I can so it flexes and stretches depending on what text is in there.

My issue right now is if I use a font that has a descender which goes below the bast line, or an ascender that goes above the cap height.

To get the box my text is in perfect, I measure the text width and heights, add a padding value and then set my shape to that. Works great until I use a capital Q which goes below the baseline.

So my question is: how can I measure the height of text from baseline to cap height? or how can I create an offset variable based on if specific letters are contained within the target text?

Return to posts index

DeMarc Johnson
Re: If text layer has specific letter
on Nov 20, 2017 at 7:12:34 pm

You can use the sourceRectAtTime() method with a shape layer to the letters to line up your lower thirds.
Align your shape layer so that upper left corner is align with the upper left corner of the text layer.

In your shape layer's size property put in:

var txt = thisComp.layer("text");
var x = txt.sourceRectAtTime(time, true).width;
var y = txt.sourceRectAtTime(time, true).height;
[x, y]

The shape position layer ****INSIDE YOUR SHAPE PATH / UNDERNEATH THE SIZE PROPERTY**** add this expression
content("Rectangle 1").content("Rectangle Path 1").size / 2;

For Expression Tutorials:

Return to posts index

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