return absolute leading

Tagged: ,

This topic contains 6 replies, has 2 voices, and was last updated by  Raphael Freeman 1 year, 2 months ago.

  • Author
  • #92264

    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:


    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


    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:

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



  • #92267

    Thank you very much. I will try that.

  • #92424

    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;

    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

    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

    [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
    myObjet.geometricBounds = myFrameGB;

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

  • #92431

    Thank you. It works now!

You must be logged in to reply to this topic.