cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

length of a string in points APP

SOLVED
Highlighted
Level 8

length of a string in points APP

Hi,

 

How can I get the length of a string in points? (not the number of letters)

 

Florin

1 ACCEPTED SOLUTION

Accepted Solutions

Re: length of a string in points APP

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()).

5 REPLIES

Re: length of a string in points APP

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());

Re: length of a string in points APP

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?

 

mak.png mak2.png

Florin

 

 

 

Re: length of a string in points APP

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.

Re: length of a string in points APP

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

Re: length of a string in points APP

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()).