Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions If text layer has specific letter

  • If text layer has specific letter

    Posted by Adam Haas on November 15, 2017 at 9:19 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?

    Demarc Johnson replied 8 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Demarc Johnson

    November 20, 2017 at 7:12 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:
    https://www.youtube.com/channel/UCe77szX2n1WSKsGs-2gmbDw

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy