Scrollable region in demo has its text rendering cut
I checked, there is no typo in the code. For some reason it cuts n when rendering the label and even more (almost 2 letters) when scrolling horizontally.
Same demo, splitter example
My toolchain: GCC 13.3 + SDL 2.30
Good evening, @Xeverous! Thank you for reporting the issue.
I did some testing and would like to share the results.
In overview.c, on the Simple tab, the demo uses a fixed layout:
https://github.com/Immediate-Mode-UI/Nuklear/blob/fcd64f85e54b9d35eee13347748d70fa4d2e134e/demo/common/overview.c#L1091
However, 150px is not enough for the text "0x00: scrollable region". We can calculate the correct width manually:
const char* str = "0x00: scrollable region";
struct nk_user_font* font = ctx->style.font;
float w = font->width(font->userdata, font->height, str, nk_strlen(str));
With the default ProggyClean font, this returns 161px. So replacing 150 with 161 fixes the clipping.
The same applies to the Splitter tab. The correct text width is about 343px, so changing:
https://github.com/Immediate-Mode-UI/Nuklear/blob/fcd64f85e54b9d35eee13347748d70fa4d2e134e/demo/common/overview.c#L1181
to nk_layout_row_static(ctx, 20, 343, 1) fixes that case as well.
Conclusion. Nuklear is rendering text correctly, the issue comes from the layout widths used in the demo. I guess we should consider submitting a PR to update this.
Great. Is there a way to make this automatic? I do not want to compute row's width manually.
@Xeverous
The demo (overview.c) uses a fixed layout for some widgets, which is why the text is getting cut. In this specific case, the only solution is to adjust the width manually and we should update the demo in a future PR to reflect that.
If you’re asking for your own project, it might be easier to use nk_layout_row_dynamic instead of nk_layout_row_static, since the dynamic layout will automatically expand to the available width. That way, you won't need to calculate text width manually.
ahh indeed, thanks