How to combine two styles in text layer by expression?
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
y1 = y;
y2 = y.toUpperCase();
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().
wordStyle = createStyle().
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
but even with this, i wasnt’t able to make it work.