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

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!

https://processing.org/reference/textWidth_.html

2 Likes