Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to combine two styles in text layer by expression?

Tagged: 

  • How to combine two styles in text layer by expression?

    Posted by Jonatan Magrao on December 14, 2020 at 5:09 pm

    Hello everybody.

    I’m trying to combine two styles by expression from a text layer. My idea is to create a emphasis in a word inside a text. For that, o created this code and worked very well.

     

    var t = text.sourceText; // main text

    var w = thisComp.layer(“developer”).text.sourceText; //changed word

    function uCase(x,y){

    y1 = y;

    y2 = y.toUpperCase();

    return x.replace(y1,y2)

    }

    uCase(t,w)

    
    

    Basically, this code help me to change the selected word by the same one in upper case. It help, but i would like to change the color and the font too, but i can’t figure out how to do this. I think the more closest code i’ve reached was this below

     

    t = text.sourceText;//main text

    w = t.replace(/developer/gi,”CEO”);//word change

    textStyle = createStyle().

    setFillColor(hexToRgb(“ff0000”)).

    setFont(“Arial-Bold”);

    wordStyle = createStyle().

    setFillColor(hexToRgb(“ffff00”)).

    setFont(“Bebas Neue Pro”);

    textStyle.setText(t) + wordStyle.setText(w)

    
    

    I know probably it’s not only that, is lacking some more code line in there and that the last line is not correct, but it must have some way to do that.

    I’ve looked this discussion here

    https://creativecow.net/forums/thread/is-it-possible-to-combine-two-properties-from-text/

    but even with this, i wasnt’t able to make it work.

    someone, please?

     

    Is it possible to combine two properties from textSource into new text layer?

    Yoan Boisjoli replied 1 year, 1 month ago 6 Members · 8 Replies
  • 8 Replies
  • Jonatan Magrao

    December 18, 2020 at 2:29 pm

    Someone, please? It would be great to receive some advice.

  • Dan Ebberts

    December 18, 2020 at 9:23 pm

    There’s no way I know of for an expression to apply multiple styles to different parts of a single text layer. Everything gets the same style as the first character.

  • Jonatan Magrao

    December 21, 2020 at 7:40 pm

    Oh, I see. I must try combine some layers with differents source texts instead. Thanks Dan ^^

  • Spencer Rand

    October 27, 2022 at 10:25 am

    Did you guys get this working? I have been trying to build out a lower-third with two different font styles. I’m combining the source text to drive the underlying shape but I can’t get the style aspect to work.

    L1 = thisComp.layer(“Main Title”).text.sourceText;

    L1.getStyleAt(0,0).setText(L1);

    L2 = thisComp.layer(“Secondary Title”).text.sourceText;

    L2.getStyleAt(0,0).setText(L2);

    L1 + “\r” + L2

  • Filip Vandueren

    October 27, 2022 at 2:42 pm

    It’s still not possible to set more than 1 style via expressions.

  • Paul Ducco

    October 28, 2022 at 12:05 am

    Seems a little confusing though eh, as you can do so manually in the editor.

    What is there were specific characters included as identifiers i.e, all text between @ and the next ‘space’ character get styled a different way?

  • Filip Vandueren

    October 28, 2022 at 5:54 am

    Then we use text animators to fake a different style, for example faux bold by setting the stroke width, faux italic by skewing the characters, or coloring.

    But it is faking a different style, you can’t use that method to change the font for example.

  • Yoan Boisjoli

    April 25, 2023 at 8:54 pm

    I’ve made a feature request here. If you think this would be useful, I invite you to vote for it.

    https://community.adobe.com/t5/after-effects-ideas/multiple-text-styles-via-expressions-on-a-single-text-layer/idi-p/13751614#M2027

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