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.06k stars 542 forks source link

Fix incorrect glyph index in nk_font_bake #531

Closed dulingzhi closed 1 year ago

dulingzhi commented 1 year ago

In stbtt_PackFontRangesGatherRects, it skips packing when glyphs are missing. Resulting in incorrect glyphs when nk_font_bake reading these ranges rects data. Referring to the way IMGUI handles it, we skip the rect data check.

ref #399

load font: image

before: image

after: image

dumblob commented 1 year ago

Thanks for looking into this. Did you test this with various example apps (and ideally also backends/demos)?

Also, could you please also update the source files and version?

dulingzhi commented 1 year ago

source files and version updated. I tried the opengl backends and it works fine. And I'm still trying to compile the example program on windows.

dulingzhi commented 1 year ago
截屏2022-12-24 02 20 13 截屏2022-12-24 02 19 43 截屏2022-12-24 02 19 21 截屏2022-12-24 02 18 33

Works fine in all examples

FrostKiwi commented 1 year ago

OMG Yes. Thx so much for finding the cause! This has been plaguing me from time to time and I resorted to excluding the affected glyphs. Great to have a proper fix for this.

dumblob commented 1 year ago

I think we could land this. Anyone any objections?

dulingzhi commented 1 year ago

🚀

Is it possible to merge this PR? @RobLoach