# \[FMX\] Measuring real pixel length of string

**URL:** <https://forum.kirupa.com/t/fmx-measuring-real-pixel-length-of-string/117693>\
**Category:** Uncategorized\
**Created:** [July 29, 2004, 2:14pm UTC](https://forum.kirupa.com/t/fmx-measuring-real-pixel-length-of-string/117693 "2004-07-29T14:14:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![borispc](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@borispc](https://forum.kirupa.com/u/borispc)\
**Post date:** [July 29, 2004, 2:14pm UTC](https://forum.kirupa.com/t/fmx-measuring-real-pixel-length-of-string/117693/1 "2004-07-29T14:14:51Z")

</div>

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?

thanks!!!  
🥚

---

<div class="post-metadata">

**Author:** ![McGiver](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@McGiver](https://forum.kirupa.com/u/McGiver)\
**Post date:** [July 29, 2004, 2:19pm UTC](https://forum.kirupa.com/t/fmx-measuring-real-pixel-length-of-string/117693/2 "2004-07-29T14:19:47Z")

</div>

I would use something like:

```auto
mytext="hallo at all"
_root.createTextField("mytextfield",10,10,10,100,100)
_root.mytextfield.text=mytext
_root.mytextfield.autoSize=true
trace(_root.mytextfield._width+" : "+_root.mytextfield._height)

```

---

<div class="post-metadata">

**Author:** ![kode](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@kode](https://forum.kirupa.com/u/kode)\
**Post date:** [July 29, 2004, 4:48pm UTC](https://forum.kirupa.com/t/fmx-measuring-real-pixel-length-of-string/117693/3 "2004-07-29T16:48:51Z")

</div>

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. 🙂
