Calculate the length of a string, text or label in pixels

Is there an established reliable way to calculate how long a element of text will be in Pixels?

I’m currently using the likes of GUI.Label() and while it accepts a rectangle to define the label boundary I’ve not see a way of calculating the size of a piece of text.

Many of the GUI functions have the option of using a GUIStyle parameter. GUIStyle has a method called CalcSize that gives you the rectangle that an element will occupy if rendered with that style.

That worked for me, thanks!