1

I'm working a script to make ALL the texts of a document with some specifics. Glad to say it's already functioning but not completely because it's just working on some of the textframes and not all of them.

The intention is to make the changes on every texts on the active document (point, area, frames, etc) and unfortunately, even when it works on some text frame, not all characters are affected because some special ones like - or + don't get the properties of the other normal characters.

Made some research and do believe I should be working with parentStory maybe? But I didn't figure out how to implement.

Here is my code:

    var document = app.activeDocument;  
    var allTexts = document.textFrames[0];  

    for (i=0; i<allTexts.words.length; i++) {  
        allTexts.words[i].characterAttributes.autoLeading = true;
        allTexts.words[i].characterAttributes.tracking = 250;
        allTexts.words[i].characterAttributes.kerningMethod = AutoKernType.AUTO;
        allTexts.words[i].characterAttributes.underline = false;
        allTexts.words[i].characterAttributes.strikeThrough = false;
        allTexts.words[i].characterAttributes.capitalization = FontCapsOption.NORMALCAPS;
        allTexts.words[i].characterAttributes.language = LanguageType.UKENGLISH;
        allTexts.words[i].characterAttributes.horizontalScale = 100;
        allTexts.words[i].characterAttributes.verticalScale = 100;
        allTexts.words[i].characterAttributes.baselineShift = 0;
        allTexts.words[i].characterAttributes.rotation = 0;             
        allTexts.words[i].characterAttributes.baselinePosition = FontBaselineOption.NORMALBASELINE;
        allTexts.words[i].characterAttributes.baselineDirection = BaselineDirectionType.Standard;
        allTexts.words[i].characterAttributes.alternateGlyphs = AlternateGlyphsForm.DEFAULTFORM;
        allTexts.words[i].characterAttributes.antialias = TextAntialias.SHARP;
 }
1

Do not go through every word of a text frame, instead apply the characterAttributes properties on the text frame's textRange object. Like this:

allTexts.textRange.characterAttributes.tracking = 250

Of course, your variable named allTexts is just a single text frame, so your loop would be revised like this:

var thisTextFrame;
for(var i = 0; i < app.activeDocument.textFrames.length; i++){
    thisTextFrame = app.activeDocument.textFrames[i]
    thisTextFrame.textRange.characterAttributes.tracking = 250;
    // ... 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.