Closed bullno1 closed 2 weeks ago
Looks very well written!
Should cf_draw_text accepts NULL as input and treat it as an empty string?
Yes.
Do we need a way to render text from utf32?
Probably not.
What should cf_text_size return? Previously, I changed it to be inclusive of the entire text box.
Sounds correct to me.
Maybe a CF_TextInfo cf_text_info(const char* text, int num_chars) where CF_TextInfo can accommodate different types of info.
This is a good direction. Let the user have more optional info about the text glyphs, and we can just pull it out from the font and hand it back. I don't want to clutter CF with anything too much or too specific. We want to offload more custom or nuanced stuff to the user.
There are a few things that may need further thoughts:
Should
cf_draw_text
acceptsNULL
as input and treat it as an empty string? CF allows initializing a string asNULL
and manipulate it. SoNULL
is equivalent to an empty string.Do we need a way to render text from utf32? The current example keeps 2 concurrent representations: utf8 and utf32. utf32 is for editing since each codepoint is a glyph. utf8 is for rendering since CF expects it but upon rendering, it is decoded into utf32 anyway. That said, I'm not sure how text editors do this. I only need short textboxes so it doesn't really matter that much.
What should
cf_text_size
return? Previously, I changed it to be inclusive of the entire text box. But to render a cursor on a multilline string, that is not enough. For example:Maybe a
CF_TextInfo cf_text_info(const char* text, int num_chars)
whereCF_TextInfo
can accommodate different types of info.Supporting IME composition candidates (think auto complete for IME): https://wiki.libsdl.org/SDL3/SDL_HINT_IME_IMPLEMENTED_UI#remarks. It is apparently a thing but I have no knowledge of this nor do I need it soon.