Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Crimson Wizard on Sat 10/01/2009 16:15:20

Title: AGS 3.1.1: (Possibly) Mistake in calculating text height
Post by: Crimson Wizard on Sat 10/01/2009 16:15:20
I guess there's a slight mistake in how GetTextHeight calculates number of lines needed for a text.

For example, if you write this:
Quote
int width = GetTextWidth(Text, Font);
int height = GetTextHeight(Text, Font, width); // here we use actual width of text as a width limit

- in this case value calculated will be equal to height of 2 lines, while there obviously should be 1 line.

If you make width limit 1 pixel larger it gives correct result:
Quote
int height = GetTextHeight(Text, Font, width + 1);


Also, I suggest to implement another function (unless it is already implemented and I am just not aware of it) that returns simply Font Height, that is if you wish to know a height of single line of text.
Title: Re: AGS 3.1.1: (Possibly) Mistake in calculating text height
Post by: Pumaman on Sun 11/01/2009 17:50:47
This looks like the same problem as this thread:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=35731.0

The main problem now is that fixing it could break existing games that are relying on the current behaviour.  The workaround is to add a few pixels to the width, as you've tried and as suggested in the other thread.