Article View: adobe.scripting.indesign
Article #8714Re: Line height
From: Dave_Saunders
Date: Wed, 27 Sep 2006 11:28
Date: Wed, 27 Sep 2006 11:28
16 lines
2287 bytes
2287 bytes
Peter's approach actually only gives you the height of the first character of the line. Usually, this is the right answer, but for the completely general case, you'll need to get the maximum value for each character in the line. This is because leading can change on a character to character basis but the leading property returned for a text object is actually the value of the first character in the object (except for the case where the object is just an insertionPoint, in which case you get the leading assigned to it). An alternative approach for determining the height of a line of text is to use the ascent and descent properties of the line of text. Unlike other text properties, ascent and descent reflect the maximum and minimum for the whole text object. So, you could use: var line = app.selection[0].lines[0] var myLineheight = line.ascent + line.descent It all depends what you mean by "line height". Disappointly, but understandably, the ascent and descent values are based on values for the font as a whole (or fonts, if you have more than one in the line) and not for the specific characters used, so 12 point times will give you a descent of 2.616 points, whether or not any the characters in the line actually have descents. This approach, of course, completely ignores leading, so the answer you get only tells you how much height the text consumes. For most fonts, this is actually the pointSize of the text because it is a rare font that has a top-of-caps value that is taller than the ascent. However, this is a easy way to get the height of the largest character in a line of text. Dave
Technical Details
Message-ID:
<3bc1cac9.1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!news.germany.com!news.mb-net.net!open-news-network.org!news.isoc.lu!webcrossingReferences:
<3bc1cac9.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,e01d6896085b06b9 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Dave_Saunders@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!news.germany.com!news.mb-net.net!open-news-network.org!news.isoc.lu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: Line height Message-ID: <3bc1cac9.1@webcrossing.la2eafNXanI> Date: Wed, 27 Sep 2006 04:28:01 -0700 References: <3bc1cac9.-1@webcrossing.la2eafNXanI> Lines: 35 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit