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

Find and Replace font with color

Guide ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

HI All,

I have a document, which I need to have the english words in a specific font. Otherwise I need to mark with any color. I tried with my script as show below, but it apply wrongly to all words except english character.

If you provide the solution for my coding or any other method, that would be helpful

var flag=0;

findmymagentatext();

function findmymagentatext()

{

var w = new Window ("dialog", "BEATS");

w.p1= w.add("panel", undefined, undefined, {borderStyle:"FONT"});  

w.p1.add('statictext',undefined,"SELECT DESIRED COLOR");

w.p1.g = w.p1.add('group'); 

w.p1.g.orientation = 'column'

w.p1.g.alignChildren = "center";

var swatches=app.documents[0].swatches.everyItem().name;

var preset_list = w.p1.g.add ("dropdownlist", undefined, swatches);

w.orientation = "column";

w.add ("button", undefined, "OK");

w.add ("button", undefined, "Cancel");

var myResult = w.show()

if(myResult == 1){

    if((preset_list.selection==null)){return;} 

        mychanges();

       if(flag==0) {alert("No error found");}

}

    else if (myResult== 2){

      exit(0);

    }

function mychanges(){

var mycolor=preset_list.selection.text;

var myarray=[];

app.findGrepPreferences = null;     app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = '[a-zA-Z0-9.,?:;!]'; 

found = app.documents[0].findGrep(); 

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

            if((found.appliedFont.name!=="ITC Avant Garde Gothic Std\tBook") || (found.appliedFont.name!=="ITC Avant Garde Gothic Std\tDemi") || (found.appliedFont.name!=="ITC Avant Garde Gothic Std\tMedium")){

                app.changeGrepPreferences.fillColor = mycolor;

                found.changeGrep();

                flag=1;

            }

    }

    if(flag==1){

         alert("Some Text area applied by wrong font, so it applied with color: "+mycolor);

         return flag;

    }

}

}

Advance Thanks,

K

TOPICS
Scripting

Views

715

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

correct answers 1 Correct answer

Engaged , Mar 28, 2017 Mar 28, 2017

Hi tpk,

Use && instead of ||

Thanks,

Prabu

Votes

Translate

Translate
Engaged ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

Hi tpk,

Use && instead of ||

Thanks,

Prabu

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.

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
Guide ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

No Ananth, I need to change any of this three fonts styles.. && wont work for this.. thanks

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 ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

Ananth is right. Write out the Truth values for your conditions, and you'll see.

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
Guide ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

Sure let me check and let you know

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
Guide ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

LATEST

Hi Jongware.. yes it is working..

But want to know how the && condition works.. it will work with all the three conditions get true, isnt it?

@prabhu: I will give you the correct answer

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