3 Replies Latest reply on Jun 22, 2017 10:15 PM by Silly-V

    Shifting baseline script?

    lMarcrest Level 1

      Good afternoon folks. I'm interested in an Illustrator script which would find all occurrences of the open bracket "(", determine its size, amend its baseline shift to a percentage of its determined size; repeat for its associated closed bracket ")"; loop to the next occurrence. I've checked the Scripting Guides and both 'Baseline' and 'Size' are CharacterAttributes which are amendable. But I don't have the skills necessary to find the font size and incorporate the math needed to calculate the percentage into the javascript. I'm not even sure if that's possible?


      Cheers, I hope you're all having a fantastic day : )



        • 1. Re: Shifting baseline script?
          Silly-V Adobe Community Professional

          Oh but you do sell yourself short!


          Well, I don't know about the math you are thinking of, but what I did is visually change my baseline and then set the hard-coded value of (-1) to do my changes.


          #target illustrator

          function test(){

            var doc = app.activeDocument;

            var t = doc.textFrames[0], thisChar, thisSize, thisBaseline;



            for(var i=0; i<t.characters.length; i++){

              thisChar = t.characters[i];

              if(thisChar.contents == "(" || thisChar.contents == ")"){

                thisSize =  thisChar.characterAttributes.size;

                thisBaseline = thisChar.characterAttributes.baselineShift;

                thisChar.characterAttributes.baselineShift = -1;






          2017-06-22 16_07_41-Untitled-1_ @ 401% (CMYK_GPU Preview).png


          2017-06-22 16_09_40-Untitled-1_ @ 401% (CMYK_GPU Preview).png

          1 person found this helpful
          • 2. Re: Shifting baseline script?
            lMarcrest Level 1

            @silly-v thank you for your speedy response. You're words about selling myself short are too kind.


            I do appreciate what you have scripted and what you have provided as a visual. Thank you. This script is intended for use in a variety of situations and I was vague in my original post regarding the percentage. I have done some testing on the visual effects of shifting the baseline within a range of type sizes which are most likely to be implemented. I have found through this testing that a baseline shift of -8.3% or (-10%) is optimal.


            I'm querying the baselineShift value of -1 in your script. What does it represent 1 pt, 1 mm, 1",  or is -1 representative of the value set within Preferences/Type/Baseline Shift within Illustrator? If different operators have this preference set differently it could present a problem during roll-out. If we could incorporate the math it would assuredly be more useful for implementation across multiple machines.


            Thank you Silly-V, the world of scripting is a better place with you in it ; )

            • 3. Re: Shifting baseline script?
              Silly-V Adobe Community Professional

              Oh thank you so much - but I have a long road ahead of me.

              The place to look for value's types are in the Object Model Viewer of the ESTK - use the Help menu or Cmd+/ on mac and f1 on the pc.

              Open it up, find the CharacterAttributes and see its properties among which you will find:


              Data Type: number

              Adobe Illustrator 21 Type Library

              The amount of shift (in points) of the text baseline.