Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Source Text formatting using expression

  • Source Text formatting using expression

    Posted by Dennis Cheung on August 18, 2011 at 4:05 pm

    Hi everyone. This is an AE Source Text question.

    I’m looking for a way to have After Effects identify a text layer’s characters and scale the numbers at 60pt (let’s say 3:00) and scale the text at 50pt (pm). Is there a way through expression I can ask AE to ID what kind of characters are in a text layer?

    On the same thought, can AE identify a text layer’s characters fonts? That would be awesome if I can use expression to format characters.

    I’m trying to make this editable for the next person to work in the future.

    Thanks for reading.

    Dan Ebberts replied 12 years, 8 months ago 4 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    August 18, 2011 at 4:20 pm

    An expression could identify which characters are numbers, but it doesn’t really have much control over formatting. You could scale a character based on whether it’s a number or not, but the adjacent characters wouldn’t move to accomodate the size change. You might be able to hack something together using scale and tracking animators with an expression selector, but it wouldn’t be pretty.

    Expressions have no access to font info.

    Dan

  • Dennis Cheung

    August 18, 2011 at 4:24 pm

    Thanks.
    What is the method to ID numbers from text? AE help isn’t very helpful.

  • Kevin Camp

    August 18, 2011 at 4:28 pm

    you can’t do it with expressions, but you might be able to do something similar with text animators (and expressions).

    to try a text animator, just type your text in to text layer (like “3:00PM”), then choose animation>animate text>scale. this will add some new properties to the text layer.

    twirl down ‘animator 1’ and ‘advanced’. in advanced, set units to ‘index’. then in the animator 1 properties add expression for the start and end and paste in these expressions:

    start:

    text.sourceText.length – 2

    end:

    text.sourceText.length

    now set the animator 1 scale property to 83% and the last two characters of the text string should be 85% smaller than the first part of the string.

    now if you typ in another time like 12:00PM it should keep the ‘PM’ smaller than the rest of the text.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Dan Ebberts

    August 18, 2011 at 4:34 pm

    This is one way to do it inside the expression for an expression selector:


    txt = text.sourceText;
    c = txt[textIndex-1];
    if (c >= "0" && c <= "9") 100 else 0

    Dan

  • Dennis Cheung

    August 18, 2011 at 4:45 pm

    This totally works! So simple and elegant!
    Thanks again for coming to my rescue.

  • Jim Zarbaugh

    September 13, 2013 at 12:32 am

    Dan,

    I am a bit of a rookie when it comes to expressions. I was hoping to use it, but I guess I need an example of where to place it. I realize that this expression may be outdated since changes are made all the time, but I couldn’t get this to work no matter where I placed it.

    Any help would really be appreciated.

    Jim

  • Dan Ebberts

    September 13, 2013 at 1:00 am

    You have to add an expression selector, then add the expression to the amount property of the expression selector.

    Dan

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