Ambiguous Documentation for gre.get_string_size()

I am using version 6.2.0 of Crank, and I'm trying to calculate the string width of a multi-line field based on the current language.  The IDE documentation doesn't include the length/string_length parameter that is included in the help documentation.  I believe that parameter is expected, since I mostly get -1 for the width without it.  However, the widths that are returned with multi-line input and wrapping enabled are longer than the widths I calculate (or expect) when measuring each line individually.  Can someone please guide me on how to measure the width of a multi-line input accurately?  Below are the details on what I tried.

My original text is stored in CSV, and it uses hard returns rather than \n newline chars.

local wrap_data = { [ "wrapping" ] = true }
str_size = gre.get_string_size( font_name, 42, text, 0, 300, wrap_data )

With text of "Session Summary" with a line break instead of space, the above code returns a width of 306.  If I remove the zero, the returned value is -1 or 0, so I assume that the IDE-integrated documentation is wrong. Interestingly, all of the returned values were over 300 (every language), which I set for what I thought was the width limit before wrapping.

When I measure each line separately, they are returned as 151 and 183, using the following code.  With this type of measurement, only one language is over 300, and it returned a 363 (and 185), as compared to 308 with the multi-line measurement above.

str_size = gre.get_string_size( font_name, 42, text )
0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post