Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Can check if a word exceeds the paragraph width?

  • Can check if a word exceeds the paragraph width?

    Posted by Andrei Popa on January 28, 2020 at 9:24 am

    I am trying to create a template that uses some paragraph texts.
    If I get the case that some word is too long and has to be broken, I would like to make the font smaller so it fits.

    Does anyone know if I can check if a word exceeds the paragraph width by expressions?

    Andrei
    My Envato portfolio.

    Andrei Popa replied 6 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    January 28, 2020 at 7:50 pm

    The only thing I can think of would be a hack, but it might be useful. You could have a source text expression like this:

    if (time < 0)
    “your_extra_long_word_goes_here”
    else
    value;

    Then you could use sourceRectAtTime() with a negative time to get the width of just that word. Then I’m not sure what you do, but hopefully that’s useful…

    Dan

  • Andrei Popa

    January 29, 2020 at 8:03 am

    I think I was not clear enough, but you gave me an idea anyway.

    I had a boxText paragraph that had a pretty small width. I was afraid that some words the client may use may overextend and be broken in half.

    I ended up creating an invisible text layer that had as value the longest word from the boxText.
    I then created a ratio variable that was botTextWidth/longestWordWidth. And i multiplicated the font size with this ratio if it were smaller than 1.

    Thank for the hint.

    Andrei
    My Envato portfolio.

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