Hello Guest

Author Topic: Get text height for a tk2dTextMesh that is using wordwrap.  (Read 6242 times)

mamamia

  • Guest
Get text height for a tk2dTextMesh that is using wordwrap.
« on: March 23, 2013, 04:08:57 pm »
Hi,

Is there any way to get the text height of a text mesh using wordwrap? I think numbers of lines for the text mesh would do for me too.

P.D. I have tried with GetMeshDimensionsForString but it seems it is not taking wordwrap into account.

Thanks in advance.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Get text height for a tk2dTextMesh that is using wordwrap.
« Reply #1 on: March 23, 2013, 07:01:46 pm »
You should do
tm.GetMeshDimensions( tm.GetFormattedString( str ) );

The "height" returned is negative as it returns the cursor postion relative to the start position.
Its not ideal, but at least you'll be able to use the information.

I will create a variant that will return the correct mesh size, including clipping due to maxchars in a future version. Its been in the todo for a while now.

mamamia

  • Guest
Re: Get text height for a tk2dTextMesh that is using wordwrap.
« Reply #2 on: March 24, 2013, 08:32:28 pm »
Thanks for the info.

mamamia

  • Guest
Re: Get text height for a tk2dTextMesh that is using wordwrap.
« Reply #3 on: March 24, 2013, 08:47:13 pm »
Hi again,

Excuse me unikron but I have 1.91 p1 installed and this functions doesn't seem to exist :/. Don't really like to update to the betas at this moment. Did you spell them wrongly or I must update to get access to this functions?.

Thanks in advance.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: Get text height for a tk2dTextMesh that is using wordwrap.
« Reply #4 on: November 21, 2013, 02:16:47 pm »
Was this ever added? The only similar method I'm seeing in 2.3 is the GetEstimatedMeshBounds(). Is there a better/more accurate way to get the height of the mesh after the text has been updated? Thanks.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Get text height for a tk2dTextMesh that is using wordwrap.
« Reply #5 on: November 22, 2013, 11:17:00 am »
You can get a very close estimate (almost 100%) by using GetEstimatedMeshBounds, it should format / word wrap as well. Are you having any issues with it?

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: Get text height for a tk2dTextMesh that is using wordwrap.
« Reply #6 on: November 22, 2013, 02:01:58 pm »
No, it's working - just was wondering if there was a different way. Near 100% is fine, though.