2D Toolkit Forum

2D Toolkit => Support => Topic started by: DemiGoth on May 23, 2015, 03:26:34 pm

Title: TextMesh size in pixels
Post by: DemiGoth on May 23, 2015, 03:26:34 pm
I'm looking for a way to calculate the size in pixels of a TextMesh. I know that fonts like Courier have a fixed width, but others like Times New Roman don't. It's for those fonts that I need to know the length in pixels of the text written...
Title: Re: TextMesh size in pixels
Post by: DemiGoth on May 24, 2015, 08:01:50 am
Nvm, got it figured out -> GetEstimatedMeshBoundsForString(string str). And from the looks of it, it's quite accurate as well. Now it's time to get building the ticker I want to make ;-)
Title: Re: TextMesh size in pixels
Post by: unikronsoftware on May 24, 2015, 12:09:23 pm
Yup thats it. Its not 100% accurate as the name suggests but its very very close :)
Title: Re: TextMesh size in pixels
Post by: DemiGoth on May 27, 2015, 10:47:37 am
Yup thats it. Its not 100% accurate as the name suggests but its very very close :)
Close enough for me. Just add an extra 10px and it should be fine (I hope  ;) )