Hello Guest

Author Topic: TextMesh size in pixels  (Read 4693 times)

DemiGoth

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 45
    • View Profile
TextMesh size in pixels
« 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...

DemiGoth

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: TextMesh size in pixels
« Reply #1 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 ;-)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: TextMesh size in pixels
« Reply #2 on: May 24, 2015, 12:09:23 pm »
Yup thats it. Its not 100% accurate as the name suggests but its very very close :)

DemiGoth

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: TextMesh size in pixels
« Reply #3 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  ;) )