[ExtendScript]Change font color, size of certain word in text layer

我怕爱的太早我们不能终老 提交于 2021-01-27 10:55:10

问题


I want replace font color and weight and size of certain word in text layer.
For example:

I want <b>THIS</b> look different
 and <b>this</b> as well.

My plan was replacing every characters' color between <b> and </b> then "<b>" and "</b>" to be removed.

First of all, I'd like to know that changing colors and size of certain words in a text layer would even be feasible.

Another thing is, even if I somehow manage to change font color in a text layer and then remove <b> and </b>, font colors change back to what it was before. To the color of first character of the layer.

function Replace132Step1(){
    var desctxt  = app.activeDocument.artLayers.getByName ("Description");
    var reg = new RegExp("(<b>.*<\/?b>)");
    var boldColor1 = new SolidColor();
    boldColor1.rgb.hexValue= 'EE3E2E';
    //I got stuck from here. .replace doesn't seem like to work.

}

function Replace132Step2(){
    var desctxt  = app.activeDocument.artLayers.getByName ("Description");
    desctxt.textItem.contents = desctxt.textItem.contents.replace("<b>", "");
    desctxt.textItem.contents = desctxt.textItem.contents.replace("</b>", "");    
}

来源:https://stackoverflow.com/questions/36934335/extendscriptchange-font-color-size-of-certain-word-in-text-layer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!