4 Replies Latest reply on Jun 21, 2018 3:19 AM by himanshug12764438

    Changing Text of a textStyleRange changes color of next

    himanshug12764438 Level 1

      color-change.png

      I have a script that loops over textStyleRanges and replaces non-Unicode contents by Unicode.

       

      var stories = app.activeDocument.stories.everyItem().getElements();

       

      for (var i = 0; i < stories.length; i++) {

        var textStyleRanges = stories[i].textStyleRanges.everyItem().getElements();

       

        for (var j = textStyleRanges.length-1; j >= 0; j--) {

          var myText = textStyleRanges[j];

          if (matches(myText.appliedFont.fontFamily)) {

            var converted = convert_to_unicode(myText.contents);

            if (converted != undefined) {

              myText.contents = converted;                

              myText.appliedFont = app.fonts.item("Utsaah");

              myText.composer = "Adobe World-Ready Paragraph Composer";

            }    

          }

        } 

      }

       

      While I am not touching the text colors, they seem to have moved to the next paragraph, in at least two cases shown above. What could be happening?

       

      Thanks,

      Himanshu