Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: GarageGothic on Wed 02/08/2006 00:03:58

Title: BUG: GetTextWidth for multiple"%" symbols
Post by: GarageGothic on Wed 02/08/2006 00:03:58
I'm aware that the symbol "%" is used to mask itself for use in Strings, so that "%%" displays as "%". However, when using GetTextWidth on a string containing "%%" the function calculates the width of both symbols even though only one is displayed. This is rather inconvenient when parsing user-input and having to limit to a certain (displayed) length.
Title: Re: POSSIBLE BUG: GetTextWidth for multiple"%" symbols
Post by: monkey0506 on Wed 02/08/2006 00:09:19
Really...this is quite interesting. I think I may have encountered this before...without...realizing what was happening. Glad to hear the bug got reported though.
Title: Re: POSSIBLE BUG: GetTextWidth for multiple"%" symbols
Post by: SSH on Wed 02/08/2006 08:55:03
But how is gettextwidth to know whether you will print the string one way or another?


String x="abc%%d";
Display("%s", x); // One way: prints two %
Display(x); // Another, prints one %

Title: Re: POSSIBLE BUG: GetTextWidth for multiple"%" symbols
Post by: Alynn on Wed 02/08/2006 09:25:46
Would / (or is it \ my brain is foggy) % do what you want? I know it works for quotation marks
Title: Re: POSSIBLE BUG: GetTextWidth for multiple"%" symbols
Post by: SSH on Wed 02/08/2006 10:18:37
I presume you're displaying this with a GUI label, but do GUI labels need the %% anyway? Don't they just display the text verbatim?
Title: Re: POSSIBLE BUG: GetTextWidth for multiple"%" symbols
Post by: GarageGothic on Wed 02/08/2006 11:03:42
I print it using RawDraw. To be honest, I don't really give a shit about it myself - I just deactivated the functionality for Shift+5 so the player can't enter it. But I figured it was an error in the way GetTextWidth worked. I wasn't aware about the Display("%s", x)/Display(x) difference, so possibly this is "as designed".
Title: Re: POSSIBLE BUG: GetTextWidth for multiple"%" symbols
Post by: Pumaman on Wed 02/08/2006 18:25:50
It's a difficult one. I guess really, GetTextWidth should correspond to the width that you'll get with RawPrint/DisplaySpeech/Display, all of which do the %% thing .. so you're probably right, it's a bug.
Title: Re: BUG: GetTextWidth for multiple"%" symbols
Post by: strazer on Sat 19/08/2006 17:06:39
Also, the GetTextWidth function doesn't recognize the [ line break character, so
12345
and
12345[123
don't return the same width.