# How do I calculate the width of a string in pixels?

**URL:** <https://discourse.processing.org/t/how-do-i-calculate-the-width-of-a-string-in-pixels/27762>\
**Category:** Coding Questions\
**Created:** [February 12, 2021, 3:44pm UTC](https://discourse.processing.org/t/how-do-i-calculate-the-width-of-a-string-in-pixels/27762 "2021-02-12T15:44:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xbix](https://avatars.discourse-cdn.com/v4/letter/x/ec9cab/32.png) [@xbix](https://discourse.processing.org/u/xbix)\
**Post date:** [February 12, 2021, 3:44pm UTC](https://discourse.processing.org/t/how-do-i-calculate-the-width-of-a-string-in-pixels/27762/1 "2021-02-12T15:44:20Z")

</div>

How to calculate the width of a `String` in pixels in Processing? For e.g., I have a string that says “Processing”. What is its length in pixels, also considering its font family and size?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [February 12, 2021, 4:14pm UTC](https://discourse.processing.org/t/how-do-i-calculate-the-width-of-a-string-in-pixels/27762/2 "2021-02-12T16:14:44Z")

</div>

[https://processing.org/reference/textWidth\_.html](https://processing.org/reference/textWidth_.html)
