3 Replies Latest reply on Mar 13, 2017 8:32 AM by boqmpod

    Simple Font size script

    Maggern78 Level 1

      Hi!

       

      I need a script that resizes the text in an textframe to e.g. 12 points without changing the paragraph style.

       

      OR

       

      A script that lets me use a Function key, e.g. F1-F12 to set a new paragraph style.

       

      I've tried different solutions from the forum, but I can't get it working and I don't really know javascript yet.

       

      Can anyone help please?

        • 1. Re: Simple Font size script
          tpk1982 Level 4

          Hi ..try this for resizing text size.. got in this forum and modified little

           

          var the_document = app.documents.item(0);
          var the_selection = app.selection[0];
          
          var the_dialog = app.dialogs.add({name:"Resize selected text"});
          with(the_dialog.dialogColumns.add()){
              with(dialogRows.add()){
                  staticTexts.add({staticLabel:"Resize the selected text by"});
                  var increase_by = measurementEditboxes.add({editUnits:MeasurementUnits.POINTS, editValue:0});
              }
          }
          the_dialog.show();
          
          counter = 0;
          do {
              var current_character = the_selection.characters.item(counter);
             
              current_character.pointSize = increase_by.editValue;
              counter++;
          } while (counter < the_selection.characters.length);
          
          alert("Done!");
          

           

           

           

          If you want to run this script by shortcut key, assign this in keyboard shortcut menu under Edit menu

           

          Screen Shot 2016-06-29 at 10.50.18 AM.png

           

          Thanks,

          Karthi

          • 2. Re: Simple Font size script
            Maggern78 Level 1

            Thank you so much, it works! The solution was longer than I expected. Great work!

             

            I trimmed down the script to avoid the dialog boxes, and the set the font to 12 points

             

            Code:

            ---

             

            var the_document = app.documents.item(0);

            var the_selection = app.selection[0];

             

            counter = 0;

            do {

                var current_character = the_selection.characters.item(counter);

              

                current_character.pointSize = 12;

                counter++;

            } while (counter < the_selection.characters.length);

            • 3. Re: Simple Font size script
              boqmpod

              Ciao, sto cercando qualcosa di simile: è possibile modificare questo script in modo che aumenti la dimensione E l'interlinea di 0.5 pt ogni volta che viene lanciato?

              Ora sto usando le scelte rapide da tastiera ma per aumentare la dimensione E l'interlinea devo dare due comandi diversi, ed è scomodo (ho aperto un thread di recente dove spiego la situazione: Come aumentare e diminuire dimensione/interlinea contemporaneamente senza interlinea automatico)

               

              Purtroppo non conosco javascript, spero possiate aiutarmi se non è troppo disturbo.

              Grazie!