Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions aligning a layer under the last line of a multi line text

  • aligning a layer under the last line of a multi line text

  • Adam Greenberg

    January 25, 2022 at 5:20 pm

    Hi all, I have come close with a previous expression I have used but there is something missing. I believe the expression is looking at the height of the multiline text, but the flaw is if I type an accented letter ( example: the letter É, ¨¨Ç or a simple comma ) this changes the overall height and therefore the layer I would like aligned underneath gets moved down a few pixels more. I would like to avoid this.

    my main layer is called ”text” ( which build downwards )

    and the layer I would like to have appear a fixed number of pixels under the last line is called ”name”

    here is my expression on the anchor point of the ”name” layer

    sourceSize = thisComp.layer(“text”).sourceRectAtTime(time, false);

    T =;

    L = sourceSize.left;

    W = sourceSize.width;

    H = sourceSize.height;


    Thanks for any advice.


  • Filip Vandueren

    January 27, 2022 at 11:52 am

    The way I usually fix things like this (ie. I want the sourceRect to not change based on the absence or presence of ascenders and descenders in the font) is to add a pipe symbol to the start or end of the sourceText (value+”|”), and make them invisible with a textanimator setting the last character’s opacity to 0.

    Or alternatively: use a text-animator to set every Character Value to 124 (the Ascii code of “|”).

    Then, only enable the animator’s range before time=0, by giving its range selector’s -> Advanced-> Amount property this expression: “time<0 ? 100 : 0;”

    Now you can check sourceRectAtTime(-1) to know how tall the layer would be if all its characters were pipes 🙂

  • Adam Greenberg

    January 27, 2022 at 2:11 pm

    thx. this is a very clever work around, although im not sure i fully understand option 2

  • Filip Vandueren

    January 28, 2022 at 8:00 am

    In a nutshell:

    • we want to know what the sourceRect height of our text -layer is if every character would have an ascender and a descender.
    • We can use a text-animator “character value” that changes the value of every letter to 124 = a pipe symbol “|”
    • Now the sourceRect gives the height we want, but our text has disappeared, we only see pipes.
    • since sourceRectAtTime() is time based, we can keep the text-readable in our comp, as long as there is a known moment in time, one we don’t need in our render, that the characters get changed into pipes. For example, our comp is 10 seconds long, at second 11 we change the characters into ||||.
    • One better trick to do that is to do it in negative time: layers can and do exist before the starting time of a composition. And even though their startingTime is at 0 or later, text-layers still have a “source”, even when the layer is not active. Bonus: we don’t have to worry that we bump into the illegible text when we make the comp longer.
    • The textanimator that changes the characters just needs to be “on” before the start of the comp (off-screen so to speak). You could make 2 hold keyframes for range amount at frame 0 and 1, then shift them left manually by 1 frame. Or use the expression for “amount” I showed you.

  • Louise Nylund

    February 9, 2022 at 1:27 pm

    I have the same issue as Adam. I tried the animator with character value = 124 before the comp starts and it works well with English characters I think but when I use something like the Swedish “Å” in my font the “|” is not as high as that letter. Do you know if there is a way to take care of the highest possible ascenders and the lowest descenders at the same time?

  • Tomas Bumbulevičius

    February 10, 2022 at 9:22 am

    I found out the best workaround for this is as follows:

    1. Adding lower and higher ascenders to the text source at the end.
    2. Applying text animator which subtracts those characters by setting a range to be text.source.length – X

    This automatically creates all lines equal size and tricks sourcerect, AS LONG as you have one text / line. If its more – you have guessed it – its a pain to do 🙂

Viewing 1 - 6 of 6 posts

Log in to reply.

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