Skip to main content
tpk1982
Legend
February 16, 2017
Answered

Highlight other language texts

  • February 16, 2017
  • 1 reply
  • 1760 views

HI,

I have document which contains Chinese and English languages. For both we have separate fonts to be used. I am trying to find if any Chinese language texts applied with English language font or not. If anything present i need to apply some specific color.

app.findGrepPreferences = null; 

app.findGrepPreferences.findWhat = '[a-zA-Z0-9]'; 

app.findGrepPreferences.appliedFont="ITC Avant Garde Gothic Std";

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

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

    if(found.contents){

        myarray.push(found.contents);

        app.changeGrepPreferences.fillColor  = "Chinese";

        found.changeGrep();

    }

}

alert(myarray)

How I can found the other languages like how i found english character in my find and replace above coding.

Thanks,

K

This topic has been closed for replies.
Correct answer TᴀW

HI Taw,

Thanks, but i am afraid if i missed any list of character. I thought if we can do the GREP search except we listed in my original coding!

Like instead his if(found.contents){

can use like    if(!found.contents){


Well, yes, sure, you can do that too. Instead of:

app.findGrepPreferences.findWhat = '[a-zA-Z0-9]'

Just use

app.findGrepPreferences.findWhat = '[^a-zA-Z0-9]'

If you're sure that's what you want.

1 reply

tpk1982
tpk1982Author
Legend
February 17, 2017

Hello Experts,

May i get any suggestions?

tpk1982
tpk1982Author
Legend
February 20, 2017

Hello Experts,

Still not fount any results from my end, May i get any suggestions?

TᴀW
Legend
February 20, 2017

You'll need to put together a list of all possible Chinese characters. You can search for ranges of characters in GREP using their Unicode values. So in the script above, something like this will find the basics:

  1. app.findGrepPreferences.findWhat = '[\\x{4E00}-\\x{9FFF}]';   

But to be more thorough, you will have to decide exactly which Chinese characters/special characters/punctuation you're looking for. It looks like a big discussion. See here for example: cjk - What's the complete range for Chinese characters in Unicode? - Stack Overflow

Ariel

Visit www.id-extras.com for powerful InDesign scripts that save hours of work — automation, batch tools, and workflow boosters for serious designers.