Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Accessing a single part of a text layer to create highlights using expressions

  • Accessing a single part of a text layer to create highlights using expressions

    Posted by Ryan Hauser on September 6, 2021 at 5:53 pm

    I’m creating a .Mogrt for someone, and I want to add a highlight functionality. What I mean by this is have the ability to target a certain segment of the text, and apply different text formatting than what is used overall by the text layer. Perhaps the default text is 50pt. white Arial, but the highlighted area needs to be 55pt. Orange bold Arial.

    The way I want to go about it is this:

    1.) Create a slider. This slider defines the text index the highlight will begin on; EG the highlight begins on the 14th character

    2.) Create a second slider. This slider defines the number of characters the highlight will effect continuing from the start position of the first slider.

    As a secondary questions on this sort of operation, let’s say I have a number represented in a text box. Using only a single text layer, is it possible to have everything to the left of a decimal be one color, and everything to the right of the decimal be a different color?

    Ryan Hauser replied 4 years, 8 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 6, 2021 at 10:40 pm

    Unfortunately, all the characters in a text layer get the styling of the first character. You’re pretty much limited to what you can accomplish with animators (fill color, stroke width, etc.). Your second question though, could be done with a fill color animator and an expression selector that has an Amount expression like this:

    txt = text.sourceText.value;

    d = txt.indexOf(".");

    d > -1 && textIndex > d+1 ? 100 : 0

  • Ryan Hauser

    September 7, 2021 at 1:09 am

    Thanks Dan. I’ll look into animators, I hadn’t thought about using those but I bet I can get something working with them. Seriously, you’re a gift to the AE community!

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