Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
Other
9.08k stars 544 forks source link

Changing the font in front of nk_begin() segaults #299

Open FrostKiwi opened 3 years ago

FrostKiwi commented 3 years ago

Changing the font to anything else than the default one, in front of nk_begin(), segfaults nuklear. Naming a window with glyphs, which require another font, other than the very first baked font, is thus impossible.

I split eastern and western languages into different fonts, because the eastern languages require a bigger font to be legible. Because of this behavior, I cannot name Windows in eastern languages. The workaround requires me to create a "Window naming font", which has to be the very first font created.

FrostKiwi commented 3 years ago

Looking into this, my initial claim is not actually true. The Window needs ASCII Glyphs, even if no ASCII text is used. You can freely define any Font you want, as long as ASCII Characters 20-128 are included. However, there is one more layer to this: If the Window name is not ASCII, it may lose input function, because internally it conflicts with how the name is generated into a hash to address the window. Currently, if want to have a non-ascii Window title with Glyphs far down the Unicode chart, you need to use nk_begin_titled. The visible window title can be anything. The window name needs to be ascii. As long you use nk_begin_titled + the Font has ASCII 20-128 Glyphs and the name is ASCII, it all works, see screen shot. I'll make a PR to fix this... UmCKAGL