2D Toolkit Forum

2D Toolkit => Support => Topic started by: mamamia on March 23, 2013, 04:08:57 pm

Title: Get text height for a tk2dTextMesh that is using wordwrap.
Post by: mamamia 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.
Title: Re: Get text height for a tk2dTextMesh that is using wordwrap.
Post by: unikronsoftware 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.
Title: Re: Get text height for a tk2dTextMesh that is using wordwrap.
Post by: mamamia on March 24, 2013, 08:32:28 pm
Thanks for the info.
Title: Re: Get text height for a tk2dTextMesh that is using wordwrap.
Post by: mamamia 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.
Title: Re: Get text height for a tk2dTextMesh that is using wordwrap.
Post by: fsadeq 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.
Title: Re: Get text height for a tk2dTextMesh that is using wordwrap.
Post by: unikronsoftware 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?
Title: Re: Get text height for a tk2dTextMesh that is using wordwrap.
Post by: fsadeq 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.