DrawTextInRect report truncation position

Currently drawTextInRect and it's various flavors returns width, height, and a flag indicating if the text was truncated. I propose the improvement by which the character index at which the text was truncated be returned in addition to, or in place of the simple flag.

Text requested: "ABCDEFG"
Text displayed: "ABCD"
Values returned, width, height, true, 4

Currently if drawing large amounts to text to areas in which it truncates, various methods need to be employed to work out where to start/stop substrings to display each 'page' or text.

Having the specific character index returned would make this task far more trivial, allowing much easier stepping through the text starting at the index you last truncated at until you reach the end.
Removing the need to precompute break points based on font size and truncation string length.

Whilst I'm unsure how it's implemented under the hood. I can't help but feel that the SDK knows how far through the string it got before it had to truncate, so it feels like a very simple quality of life improvement to reduce complexity of things like dialog systems or large amounts of text.

1 Like

I was thinking the same thing.

I think that's a good idea! I'll file a feature request in our system.

You do have access to the source code for that method in CoreLibs/graphics.lua if you're interested to see how it's implemented. And of course in the meantime feel free to modify that code to add the feature yourself :slight_smile:

1 Like