ice1000 / jimgui

:sparkling_heart: Pure Java binding for dear-imgui
Apache License 2.0
186 stars 13 forks source link

Support for custom glyph ranges #74

Open seb321 opened 3 years ago

seb321 commented 3 years ago

Per request I'm opening a new issue on this.

Font loading procedures take ranges of glyphs to load. The problem is that the API does not provide a way to instantiate them, so only default options (getGlyphRangesFor*()) are available. This is not sufficient, as this does not include all glyphs one might want to display.

@ice1000 In the comment you said, that

It is, but I haven't yet adapted the API for custom ranges. It's hard in general -- imagine you passes a two-dim array from Java to C++. There are some design choices to be made.

I am new to Dear ImGui, so I have no experience with its API, but glyph ranges does not seem to be used in many places. In c++ the procedures take a flat zero-terminated array of integers. I am not the right person to decide, how you should shape your API, but I do not think that passing two-dimensional array is a way — arrays in Java have dynamic length, so using them does not add any safety in this case. You could still pass an array with incorrect size.

If you want types to be safe, I think a class representing a range would be better. However, more general solution would be to just provide a way to instantiate an array of integers compatible with the c++ code, so it can be passed to it directly. I suspect that it would be simpler to implement and could be used also in other places if needed.

I do not know how Java calls c++ code, but it is supported, so I suspect that passing values to it is not so hard that it is a real problem.

ice1000 commented 3 years ago

Oh, so the C++ API is one-dimensional. It will be unsafe anyway, so I'll assume the users know the contract. I can add the API if it's one dimensional. Thanks for telling me that.