• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Changing Text of a textStyleRange changes color of next

Explorer ,
May 31, 2018 May 31, 2018

Copy link to clipboard

Copied

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.textStyleRanges.everyItem().getElements();

 

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

    var myText = textStyleRanges;

    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

TOPICS
Scripting

Views

440

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2018 Jun 01, 2018

Copy link to clipboard

Copied

Hi Himanshu,

I'm not clear at all why this happens.

Only one suggestion:

Duplicate a given range to a new text frame, do the conversion there.

Give every duplicate its own text frame.

Do not touch the original in that loop.

Assemble all converted text after you made all the conversions.

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 21, 2018 Jun 21, 2018

Copy link to clipboard

Copied

LATEST

Hi Uwe,

Thanks for your reply. While I haven't tried what you suggested, here is a screenshot of the exported idml file, which shows that some ParagraphStyles are lost and their characterStyles merged with previous. Does this help?

id-scaled-down.png

Thanks,

Himanshu

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2018 Jun 01, 2018

Copy link to clipboard

Copied

HI,

Could you share a sample document using a file sharing service, so that we can take a look at the before and after to see if we can spot the problem?

Regards

Malcolm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2018 Jun 12, 2018

Copy link to clipboard

Copied

Thanks for offering to check this. Here is the link: ID-Scripting-Forum - Google Drive

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines