Revival of an old thread to help others. I was having the same exact issue, finding a text objects length in layout coordinates. Using a transition to dynamically set something similar to
text.width = text.msg_width was cutting off characters, and would get smaller and smaller with each transition until only 1 letter of the message was visible.
The following resolved the cutting down size issue, but would consistently be noticbly larger than the text width. I tried multiplying it by a factor since I was using a monospace font, but results were inconsistent.
text.len()*text.char_size.tofloat();
Then I figured it out. Results were accurate when the margin is set to zero. If you require a margin, perhaps you could set a default value of -1, store the calculated margin value in a different variable, change the margin back to 0, and then add the stored margin value twice to your message width.? Otherwise, perhaps create another text object, hide it, and find it’s margin size?
text.margin = 0;
text.width = msg_width;
Hopefully this is helpful to others struggling like I was.
https://github.com/mickelson/attract/issues/180Edit: NOPE. It still doesn’t work and I need to go to bed. It only has correct width for the start layout. Each transition after shortens it. Maybe I try the copy method I suggested another time. I need sleep.