1 Reply Latest reply on Sep 25, 2017 9:31 PM by Ten A

    illustrator javascript for "Identify the overset text in all text frames and reduce the font size" below are the script are identify the overset on selected text frame

    s_ashok Level 1

      i want to identify the overset text in all text frames and reduce the font size for all overset text frames.

       

      But the script only run on selected text frame.

       

      #target illustrator

      test();

      function test(){

      var doc = app.activeDocument;

      var sel = doc.selection[0];

      var contents = sel.contents;

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

      contents = contents.replace(sel.lines[i].contents, "");

      }

      //alert(contents);

          reduceSizeOfOversetText(app.selection[0]); 

      };

       

      function reduceSizeOfOversetText(t) { 

              var d; 

              while ( 

                  d = t.duplicate(), 

                  d.name = 'temp', 

                  d.convertAreaObjectToPointObject(), 

                  d = t.parent.textFrames['temp'], 

                  d.contents.replace(/[\x03\r]/g, '') !== t.contents.replace(/[\x03\r]/g, '') 

              )

              { 

                  d.remove();

               //   alert(t.textRange.characterAttributes.size)

                      if ((t.textRange.characterAttributes.size)<5.5)

                  {

                  alert("Text has been overflown  with point size of 5 points, please check the overflow text and fix as per SOP")

                

                 

                 return;

                   // return false;

                 //break;

                 // exit()

                      }

                  t.textRange.characterAttributes.size -= 1;            

              } 

             d.remove();

             } 

       

       

      kindly help on this.

      Thanks in advance

      Regards

      Ashok