Script to Change font size and baseline randomly
So, I want to change the font size and baseline of each character in the selection randomly.
The baseline part works the way I want it to but for the line:
textRef.textRange.characters[i].characterAttributes.size=newSize;
I keep getting an "Invalid Text Range" error. Here's the script:
//--------------------------
//Reference the document.
var docRef = activeDocument;
//Reference the first selection in the document.
var textRef = docRef.selection[0];
//Get the number of characters in the selected object.
var charCount=textRef.textRange.characters.length;
//Set a variable to serve as alternate positive and negative value.
var shiftSign=1;
//Let the user determine the baseline shift range and varying point size.
var shiftRange = prompt("Enter the distance, in points, by which you want the Baseline Shift to vary.", 1);
var minSize = prompt("Enter the minimum point size:", "12");
var maxSize = prompt("Enter the maximum point size:", "24");
//For each character...
for(i=0; i<charCount; i++){
//...flop the positive/negative...
shiftSign*=-1;
//...reference the range multiplied by a random number between 0 and 1...
var curShift=Math.abs(Math.random()*shiftRange);
var newSize=Math.random()*(maxSize - minSize)+minSize;
//...shift the current character by that amount.
textRef.textRange.characters[i].characterAttributes.baselineShift=curShift*shiftSign;
//...shift the current character size by that amount
textRef.textRange.characters[i].characterAttributes.size=newSize;
}
//-------------------------
Thanks for any insight!!
