[FMX] Measuring real pixel length of string

Hi everyone!

I’d like to know a way to measure the real length of a text string in pixels. The problem is that every character has a different width.
The length property informs us of how many characters does the string have…but how do we measure the pixels (x space) in a precise way?


I would use something like:

mytext="hallo at all"
trace(_root.mytextfield._width+" : "+_root.mytextfield._height)

You could also use the [font=courier new]TextField.textWidth[/font] and [font=courier new]TextField.textHeight[/font] properties. These properties will return the actual width/height of the text, unlike the [font=courier new]TextField._width[/font] and [font=courier new]TextField._height[/font] properties that will return the width/height of the text field. :slight_smile: