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

Cant search russian text

Guest
Jul 03, 2014 Jul 03, 2014

Copy link to clipboard

Copied

Hello, how can I get a script that searches a word to work with russian text? It ignores any content and searchs only in english and digits.

TOPICS
Scripting

Views

726

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

Explorer , Jul 10, 2014 Jul 10, 2014

Well, now I see. I tried to modify your script:

var idoc = app.activeDocument;

var itext = idoc.textFrames;

// the russian word

var rus_text = "пример";

// the size of the russian word

var rus_text_size = 19;

//

// for every text frame do..

for (var k=0; k<itext.length; k++)

{

    // contents of the current TF

    var contents_k = itext.contents;

    // characters pointer

    var i = 0;

    // for every character in the current TF

    while( true )

    {

        // the start characters pointer for the russian

...

Votes

Translate

Translate
Adobe
Explorer ,
Jul 03, 2014 Jul 03, 2014

Copy link to clipboard

Copied

Hello! Could you give a bit more information about the software that you use: version of Illustrator at least. You know, I use the function find/change for Russian text in Illustrator very often and it works okay.

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
Guest
Jul 10, 2014 Jul 10, 2014

Copy link to clipboard

Copied

Hello, Sergey. I use AI CS5. Thats not the point.

Replacing a text works fine with russian layout, but those scripts uses strings and I need to get access to every word in a frame to change the size of some words I choose.

My script works wrong because of wrong counting of words. Thats strange. I thought that script uses any character between 2 spaces as a Word. For russian layout its not so, for enlgish it counts them fine.

You can test it with this script, test it with russian and english texts:

// Counts all words in current document and stores total in numWords

if ( app.documents.length > 0 ) {

numWords = 0;

for ( i = 0; i < app.activeDocument.textFrames.length; i++) {

numWords += app.activeDocument.textFrames.words.length;

}

}

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
Guest
Jul 10, 2014 Jul 10, 2014

Copy link to clipboard

Copied

And here's my script that works not so fine yet because of wrong counting words:

var idoc = app.activeDocument; 

var itext = idoc.textFrames; 

// for every text frame do..

for (k=0; k<itext.length; k=k+1) 

{

// for every word in a text frame do..

     for (i=0; i<itext.words.length; i=i+1) 

     { 

// here we are searching the word "пример" to find in text frame

           if (itext.words.string == "пример")

          {

// change the size of founded word to 19

              itext.words.size = 19;     

          } 

     }

}

You can use this russian text for testing in AI:

Вы будете уведомлены, пример когда ваша учётная запись будет активирована.

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
Guru ,
Jul 10, 2014 Jul 10, 2014

Copy link to clipboard

Copied

I see your problem. Can you explain a little further what you are doing…? Is it just all instances of this one word… or have you a list of words to alter…?

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
Guest
Jul 10, 2014 Jul 10, 2014

Copy link to clipboard

Copied

Mark, I just wanted to replace specific words in text to bold.

I figured out everything except this redicilious counting russian words algorythm in AI.

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 ,
Jul 10, 2014 Jul 10, 2014

Copy link to clipboard

Copied

Well, now I see. I tried to modify your script:

var idoc = app.activeDocument;

var itext = idoc.textFrames;

// the russian word

var rus_text = "пример";

// the size of the russian word

var rus_text_size = 19;

//

// for every text frame do..

for (var k=0; k<itext.length; k++)

{

    // contents of the current TF

    var contents_k = itext.contents;

    // characters pointer

    var i = 0;

    // for every character in the current TF

    while( true )

    {

        // the start characters pointer for the russian word

        var c_start = contents_k.indexOf( rus_text, i );

        // next text frame if there are no russian words in the current one

        if( c_start == -1 ) break;// next "for k..."

        // the end characters pointer for the russian word

        i = c_start + rus_text.length;

        // processing of russian characters

        for( var j = c_start; j < i; j++ )

        {

            itext.characters.size = rus_text_size;

        };// for j

    };// while

};// for k

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
Guest
Jul 10, 2014 Jul 10, 2014

Copy link to clipboard

Copied

Sergey, thanks a lot ! U did it.

Im not that good in scripting. Adobe's references really sucks. As I can see, you used some tricks with characters and "indexof". I used "words" and it didnt work well.

I just cleaned the "@" sign in your script and added bold font for replacement in case someone will need it.

// This script search for a word u specify and make it bold. Just change the font u want.

var idoc = app.activeDocument;

var itext = idoc.textFrames;

// the russian word to find

var rus_text = "Пример";

// the size of the russian word - turned of in this script

var rus_text_size = 19;

//

// for every text frame do..

for (var k=0; k<itext.length; k++)

{

    // contents of the current TF

    var contents_k = itext.contents;

    // characters pointer

    var i = 0;

    // for every character in the current TF

    while( true )

    {

        // the start characters pointer for the russian word

        var c_start = contents_k.indexOf( rus_text, i );

        // next text frame if there are no russian words in the current one

        if( c_start == -1 ) break;// next "for k..."

        // the end characters pointer for the russian word

        i = c_start + rus_text.length;

        // processing of russian characters

        for( var j = c_start; j < i; j++ )

        {

            itext.characters.textFont = textFonts.getByName("MyriadPro-Bold");

            //changing text size is turned off here.           

            //itext.characters.size = rus_text_size;

        };// for j

    };// while

};// for k

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 ,
Jul 10, 2014 Jul 10, 2014

Copy link to clipboard

Copied

Yeah, I have noticed that wrong symbol @ too I am not good at using this forum interface

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
Guru ,
Jul 10, 2014 Jul 10, 2014

Copy link to clipboard

Copied

#target illustrator

main();

//

function main() {

  if ( app.documents.length == 0 ) { return; }

  if ( app.activeDocument.selection.length != 1 ) { return; }

  if ( app.activeDocument.selection[0].typename == 'TextFrame' ) {

  app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

  var exp = RegExp( 'пример|будет', 'ig' ); // Multi word expression…

  var i = j = list = sel = txt = null;

  sel = app.activeDocument.selection[0];

  txt = sel.textRange.contents;

  list = grepMatchOffsets( txt, exp );

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

  for ( j = list[0]; j < list[1]; j++ ) {

  // This is great fun..!!! CAN ONLY BE DONE IN SCRIPT…

  sel.textRange.characters[ j ].select( true );

  // ONLY works inside of one text frame… But COOL…

  sel.textRange.characters[ j ].size = 18;

  };

  };

  app.redraw();

  app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS;

  };

};

//

function grepMatchOffsets( text, exp ) {

  var match = null, offSets = Array();

  while ( match = exp.exec( text ) ) {

  offSets.push( Array( match.index, match.index + match[0].length ) );

  };

  return offSets;

};

You may find this fun to use… Not only can you change text using RegExp but you can select and change in the GUI…

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
Guest
Jul 11, 2014 Jul 11, 2014

Copy link to clipboard

Copied

Mark, thats great, it works too. 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
Guru ,
Jul 11, 2014 Jul 11, 2014

Copy link to clipboard

Copied

LATEST

This is probably my favourite text formatting utility… You can see I had the RegExp select 2 words in this example…

With a little RegExp learning you can fly through some text formatting operations… Codes, Numbers, Prices and so on.

Line 16 does all the work for you…

You can't hold down shift and select type like this in the GUI although I wish you could…

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