return absolute leading

Tagged: ,

Viewing 6 reply threads
  • Author
    Posts
    • #92264
      Raphael Freeman
      Participant

      I am writing my very first script (wish my luck) and I’m trying to return the leading of text that I have selected. The problem is that the leading happens to be set to Auto and I want it to return the absolute leading.

      This is what I typed:

      app.selection[0].leading;

      and it gave me AUTO instead of 15. (The leading happens to be 12/Auto but in the character panel it says (15pt)

      Is there a way to return 15?

    • #92265
      Loic Aigon
      Member

      Hello,

      Leading can either be a numeric value or an enumeration ( Leading.AUTO ) which you got.

      So you may want to check if leading is set that wey and if so compute the leading based on font size and autoLeading value:

      [pre]
      var sel = app.selection[0];
      var leading = sel.leading;
      leading==Leading.AUTO && leading = sel.pointSize*sel.autoLeading/100;
      alert (“leading is worth:”+leading );
      [/pre]

      FWIW

      Loic
      http://www.ozalto.com

    • #92267
      Raphael Freeman
      Participant

      Thank you very much. I will try that.

    • #92424
      Raphael Freeman
      Participant

      So I have progressed (thanks to the starting clue) with my little script and I have managed to set the baseline grid and offset with a script (yey).

      I’m trying to enhance the script to make it a little more useful and I’m getting stuck on the moving of a frame.

      For the script to work, I have to select some text. When I do that and run the script, it successfully does what I set out for it to do. (The variable mySel is defined earlier correctly)

      var myFrameGB = mySel.parentTextFrames[0].geometricBounds;
      alert(myFrameGB[0]);

      So this bit works and returns the top edge of the text frame. but I want it not to be 67.87363pt but rather 25 so I tried this line:

      myFrameTopGB[0] = 25;

      However nothing happens. What have I done wrong?

    • #92425
      Raphael Freeman
      Participant

      sorry, I made a mistake in my code above!

      I should have written

      myFrameGB[0] = 25;

      not that it works now, but now at least there is no syntax error.

    • #92428
      Loic Aigon
      Member

      [QUOTE]However nothing happens. What have I done wrong?[/QUOTE]

      It’s not that you do something wrong but you are misleading yourself. When you write
      myFrameGB[0] = 25;
      you are just adding 25 to the value stored in the array myFrameGB at index 0.

      If you want to affect object geometry, you need to either reset the whole array like
      myFrameGB[0]=25;
      myObjet.geometricBounds = myFrameGB;

      Or use specific functions such as mov, transform or resize. See docs for further details.

    • #92431
      Raphael Freeman
      Participant

      Thank you. It works now!

Viewing 6 reply threads
  • You must be logged in to reply to this topic.
>
Notice: We use cookies on our websites to give you a great online experience. If you keep browsing, we'll assume you're ok with this. For more information, see our privacy policy. By closing this banner, you agree to the use of cookies.I AGREENo