3 Replies Latest reply on Oct 8, 2015 2:42 PM by Qwertyfly...

    Make a text selection in text frame.

    Silly-V Adobe Community Professional

      The objective is to replicate setting kerning between 2 individual characters, which is done in the UI by inserting the caret between 2 characters in a text frame and then using the now-accessible kerning input in the characters panel.

      Using scripting, though, an empty selection is not well-liked and at least one character has to be "highlighted" so that script-applied kerning can be applied to the space before that character.

      But how is it possible to make a selection through javascript? This is more of a curious experimentation at this point.

        • 1. Re: Make a text selection in text frame.
          Qwertyfly... Level 4

          is this kinda what your trying to do??

           

          var a = app.activeDocument.selection[0];
          var aa = a.characters;
          for(var i=0; i<aa.length;i++){
              if(aa[i].contents == ";"){
                  aa[i].kerning = 200;
              }
          }
          
          • 2. Re: Make a text selection in text frame.
            Silly-V Adobe Community Professional

            Hey! I'm not sure about the contents of semicolon, but you did help a lot with the .characters property and illustrating how that also has .kerning in it! I was confused due to their absence in the OMV data browser during debugging.

             

             

            I was indeed trying to do this:
            var s = doc.selection; // this is supposed to be a caret between 2 characters.

            s.parent.textRange.characters[s.characterOffset - 1].kerning = newKerning;

             

            So it looks like it's working now, thanks!

            • 3. Re: Make a text selection in text frame.
              Qwertyfly... Level 4

              The semicolon was just an example, it just gave me a place to adjust the kerning.

               

              this is a more real world example of what I was meaning

               

              var a = app.activeDocument.selection[0];
              var aa = a.characters;
              for(var i=0; i<aa.length;i++){
                  alert(aa[i].contents);
                  if(aa[i].contents == "A" && aa[i+1].contents == "V"){
                      aa[i+1].kerning = -100;
                  }
              }