Nuklear icon indicating copy to clipboard operation
Nuklear copied to clipboard

Scrollable region in demo has its text rendering cut

Open Xeverous opened this issue 2 months ago • 5 comments

Image Image

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.

Xeverous avatar Oct 17 '25 15:10 Xeverous

Same demo, splitter example

Image

My toolchain: GCC 13.3 + SDL 2.30

Xeverous avatar Oct 17 '25 16:10 Xeverous

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.

Image

PavelSharp avatar Nov 06 '25 16:11 PavelSharp

Great. Is there a way to make this automatic? I do not want to compute row's width manually.

Xeverous avatar Nov 06 '25 18:11 Xeverous

@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.

PavelSharp avatar Nov 06 '25 19:11 PavelSharp

ahh indeed, thanks

Xeverous avatar Nov 07 '25 01:11 Xeverous