-
Limiting a text editing script to a range of characters
Hello there I created this script with great help from Dan Ebberts some months ago. It changes the font style of a selected text layer in regular intervals. It’s a very useful script but I need it to apply the style change without messing with font size. I use this script to emphasize the price of a product in a promo. The idea is to keep the currency symbol smaller than the numbers while still applying the effect to all the characters, including the “$” symbol. I think I read somewhere trying to affect a range of characters in a text layer is not possible with Extendscript. Is this true? Would it be better having the “$” symbol in a separate layer? I still could use a variation that leaves de “$” untouched for the whole thing while on the same text layer. If someone can direct me on how to isolate the first space in the index for such an effect. Thanks!!
{app.beginUndoGroup("Jump Text");
var jumpText = app.project.activeItem.selectedLayers[0];
var fonts = ["DINNextLTPro-Regular","DINNextLTPro-Italic","DINNextLTPro-Bold"];
var jumpTextProp = jumpText.property("Source Text");
var jumpTextDocument = jumpTextProp.value;var t = jumpText.inPoint;
var idx = 0; while (t < jumpText.outPoint){
jumpTextDocument.font = fonts[idx];
jumpTextProp.setValueAtTime(t,jumpTextDocument);
t += .25; idx = (idx+1)%fonts.length;
}
app.endUndoGroup();}