Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Changing "baselineshift" value according to the biggest word

  • Changing "baselineshift" value according to the biggest word

  • Gregory Wannwitz

    December 1, 2021 at 4:50 pm


    I have a problem with an expression.

    I would like to write a text with a bigger word, I already applied an expression to center the text.

    So when I make a word bigger I need to change the baseline shift on that specific word in order to maintain a correct alignment.

    I would like to control the baselineshift with a slider on the biggest word.

    But when I enter an expression like :


    With the value connected to a slider, it does not work at all.

    The font size, color and baselineshift reset.

    It is a little hard to explain, so I put an exemple project here.

    When you activate the expression in “source text” you will see instantly what I mean.

    I think that it is not possible, but just in case I ask.

    Thank you in advance.

  • Kevin Camp

    December 2, 2021 at 12:08 am

    I don’t think you will be able to do what you want with a text style expression since style is applied to the entire text layer, not just a word or partial string of text.

    I think to pull this off, you’d want each word on a separate text layer and use sourceRectAtTime() expressions to make them work like a single line of text.

    Would you only ever have 3 words, or would the number of words vary?

  • Andrei Popa

    December 2, 2021 at 10:22 am

    I think you can do that with an animator on position.

    So add an animator for position, set the range “units” to “index” and the “based on” to “characters”. Then set the start to the position of the first letter of the word and the end to the position of the last letter of the word. I made another composition in your project to show you what I mean.

  • Gregory Wannwitz

    December 2, 2021 at 10:43 am

    Hello Kevin

    Thank you for the answer.

    You confirm what I thought, it would be only possible with multiple text layers, but the problem is that there is no fixed number of words.

    So it will be more efficient and quicker to change the baselineshift manually.

  • Gregory Wannwitz

    December 2, 2021 at 4:34 pm

    Hi Andrei

    Thanks for your answer.

    That’s a great idea ! I did not know that it was possible to do that with the index mode.

    In my case it is not usable because when I resize the biggest word the baselineshift need to be modified again, but I keep your method in mind, it can be useful for another project.

  • Andrei Popa

    December 7, 2021 at 11:44 am

    You can create another invisible layer that contains only your big word. Then, on the start and end of the animator you can put

    w = thisComp.layer("big word").text.sourceText.replace(/\r/g,"");


    w = thisComp.layer("big word").text.sourceText.replace(/\r/g,"");

    This will update each time you change the big word

  • Gregory Wannwitz

    May 14, 2022 at 9:25 am

    Hello Andrei

    Thanks for your answer and sorry for the delay of my response, I did not receive the notification of your message !

Viewing 1 - 7 of 7 posts

Log in to reply.

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