Hi,
How can I get the length of a string in points? (not the number of letters)
Florin
Solved! Go to Solution.
You're meant to run this during formatting so it picks up the current formatting properties. I haven't tested what it does outside of formatting context, it will pickup some defaults, but you can use PIs in the text string I believe (or wrap it in a styleSave(), styleChange(), and styleRestore()).
Here are a couple of options to measure a string:
APP code: <?show $^(#"Testing")>
JS code: var l = fLength(); l.text = 'Testing'; application.alert(l.makeAbsolute());
Hi Gareth,
for application.alert(l.makeAbsolute()); statement I get a message of "69.5666mm" and for
application.alert("length : " + l.makeAbsolute()); statement I get a message of "695666" only.
Do you know why? and in what unit is the second message? micrometers?
Florin
The second way you're forcing to a string value, the first is returning an fLength. The second value is in APP's base measurement units known as "decimicrons". You can use these units everywhere in APP by using the "dm" unit suffix.
One last question. Is this solution taking in consideration the font size and family which have been set prior measuring the string?
Thank you!
Florin
You're meant to run this during formatting so it picks up the current formatting properties. I haven't tested what it does outside of formatting context, it will pickup some defaults, but you can use PIs in the text string I believe (or wrap it in a styleSave(), styleChange(), and styleRestore()).