-
How to combine two styles in text layer by expression?
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?