2017-04-25 100 views
0

我可以更改文本顏色,但格式也正在改變!我的一半文本是粗體,另一半是斜體。但最後所有的文字都變成了粗體。如何更改文本的顏色而不會丟失格式

var proj = app.project; 
var theComposition = app.project.activeItem; 
var theTextLayer = theComposition.layers[1]; 

var textProp1 = theTextLayer.property("Text").property("Source Text"); 
var textProp2 = theTextLayer.property("Source Text").value; 
textProp2.fillColor = [1,1,1]; 
textProp1.setValue(textProp2); 

回答

1

當您設置TextDocumenttextProp1.setValue(textProp2);它設置的所有TextDocument屬性。 Adob​​e不支持通過Extendscript(e.x .: fillColor,fontSize,fontFamily等)的每個文本圖層的多種格式,因此該圖層會獲得第一個字母的屬性,在您的案例中爲粗體。

我可以建議你將填充效果添加到圖層並更改效果中的值。 下面是該代碼:

var fillEffect = theTextLayer.property('ADBE Effect Parade').addProperty('ADBE Fill'); 
fillEffect.property('Color').setValue([1,1,1]); 
+0

Thx Ziki。我不喜歡這種接近,但...我看到我沒有其他的方式... Thnx! ExtendScript是如此沒有生產力。:( –

+0

我也討厭這個,但是據我在Adobe論壇中的帖子瞭解,他們不會改進它,因爲Extenedscript社區不夠大,無法做出一些改進。 – Ziki