SDL_ttf icon indicating copy to clipboard operation
SDL_ttf copied to clipboard

Feature request: Add variants of existing rendering functions that take a string length

Open miss-programgamer opened this issue 1 year ago • 1 comments

The title says it all, adding functions that take a length instead of assuming strings are null-terminated would be really nice for a variety of use cases, from allowing easier interop with other languages to making styling different parts of a string possible without allocating a bunch of sub-strings for each part. This could be achieved by adding Len to the end of the relevant functions, so the string length variant of TTF_RenderUTF8_Blended would be TTF_RenderUTF8_BlendedLen, and so on.

Edit: the scope of this request should actually include every function that takes a piece of text as input, not just the rendering functions, but maybe that goes without saying.

miss-programgamer avatar Mar 30 '23 17:03 miss-programgamer

I also endorse this. Came here trying to find a way of measuring a text that is not NUL-terminated. Having to create sub-strings from a larger text is really not good for performance.

It would go well with std::string_view that is now available in C++.

skalleAnka avatar Apr 10 '23 17:04 skalleAnka