kiwi icon indicating copy to clipboard operation
kiwi copied to clipboard

Wrapped Text is forced to be left aligned

Open Emersont1 opened this issue 5 years ago • 4 comments

Code:

auto title_l = KW_CreateLabel(gui, frame,"Text Wrapping in Scrollbox\n(Horizontal Bar Disabled)", &r);
//KW_LabelEnableWrap(title_l);
KW_SetLabelAlignment(title_l, KW_LABEL_ALIGN_RIGHT, 0, KW_LABEL_ALIGN_MIDDLE, 0);

No wrapping, but centered

image

when I uncomment the LabelEnableWrap( line:

image

The same occurs when it is set to right aligned

I'm logging this, if i have time after the checkboxes and radio buttons I'm working on, I'll work on a drop in replacement for the SDL_TTF rendering function, but this may take time

Emersont1 avatar May 09 '20 19:05 Emersont1

What are you planning on replacing SDL_TTF with? Replacing SDL_ttf is in my plans as well, right now I'm working on a font cooking library, it's just not public yet, that I plan to use for KiWi 1.0 and other projects.

mobius3 avatar May 09 '20 21:05 mobius3

I'm thinking using something like freetype, and iirc the ICU library has functionality for wrapping text

Edit: STB has a TrueType loading library too, that might be relatively easy to work with

Emersont1 avatar May 09 '20 21:05 Emersont1

Yeah, this new library of mine is a wrapper around stb_truetype (which wasn't a lot easy to work with, to be honest). It already correctly produces the glyph atlas but I'm still dealing with some kerning issues. I hope to publish it by this week but replacing KiWi's text rendering with it (or any other library) might be a little daunting. I'm not hoping to do it for the master branch but rather to the development branch (which is going to be 1.0), since there will be more liberty to redefine the API as needed.

As for the issue at hand, I'm not sure of what to do - maybe fixing SDL's wrapping is a better idea, for the time being. Until then or until kiwi text rendering is replace, I think documenting at as a library caveat is proper, unless you absolutely need center/aligned wrapped text.

mobius3 avatar May 09 '20 22:05 mobius3

at present, i don't, but there probably will be issues when it comes to LTR languages (like Arabic, hebrew) so it ought to be fixed eventually. I think it just needs documenting for now

Emersont1 avatar May 10 '20 08:05 Emersont1