imgui-js icon indicating copy to clipboard operation
imgui-js copied to clipboard

use AddFontFromFileTTF with io.Fonts.GetGlyphRangesChineseFull will crash

Open AILHC opened this issue 4 years ago • 6 comments

console Uncaught (in promise) abort(OOM). Build with -s ASSERTIONS=1 for more info.

I used a cropped droidsansfallback.ttf This file contains 2500 commonly used Chinese characters but

I cropped the font file again, and this time it worked when the file contained only 500 commonly used Chinese characters I think it was a memory burst while creating font data. What is the solution? You can clone my git repository :https://gitee.com/AIGAMESTUDIO.AILHC/imgui-js change example/main.js to check

AILHC avatar Mar 11 '20 23:03 AILHC

TTF can be loaded, but you cannot use imgui.inputtext() for Chinese input and imgui.text () for Chinese display

AILHC avatar Mar 12 '20 01:03 AILHC

try enabling ALLOW_MEMORY_GROWTH in the Makefile

https://github.com/flyover/imgui-js/blob/e7b86a2e57f1b8f48f9b4d66940be64f8b9f9fa1/Makefile#L53

you will need to rebuild the imgui binding

$ make clean-bind-imgui; make build-bind-imgui

flyover avatar Mar 12 '20 14:03 flyover

thanks

AILHC avatar Mar 12 '20 23:03 AILHC

I did as you suggested, and can load and display large Chinese TTF.But you still can't type Chinese into the imgui

AILHC avatar Mar 13 '20 02:03 AILHC

Hmm, it doesn't look like there's any way to forward the characters selected from an IME into ImGui without using a text input or text area element. I suppose you could have one display atop the canvas when io.WantTextInput is true then forward the changes to io.AddInputCharactersUTF8.

flyover avatar Mar 14 '20 20:03 flyover

Thank you, I know, this is webgame common problem, I can refer to other game engine or the realization of the third party libraries to do, such as canvasinput:https://github.com/goldfire/CanvasInput, but the demand is not very worried.Thank you very much for your help

AILHC avatar Mar 19 '20 08:03 AILHC