-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep track of missing glyphs #1010
Comments
Runtime check is probably only good enough if done very efficiently in a way that doesn't harm the performance of the CalcTextSize function. However that feature would pretty much be overlapping with the more desirable atlas update requirement. If you let a frame elapse before rendering then those glyphs will be missing for one frame, so in theory the data needs to be computed immediately. |
I'm currently using this for a font merged from multiple TTFs, so I don't think imgui could update things correctly internally :-/ you are correct that glyphs are missing for a frame, but that's better than having to load all of CJK in multiple fonts and sizes, which I'd have to do right now :-/ |
FindGlyph() is probably the best place to put it in term of performances, unfortunately CalcTextSize() doesn't uses it (it rather uses the densely packaged IndexXAdvance[] array), so that would also create an issue for one frame where both the Calc and Draw functions would use the fallback width. It's actually a fairly bearable side-effect, and it avoid a lots of the trouble of getting it right, so it might be a great fit in term of the project philosophy. Maybe it is the best solution and those who want to avoid artefact that request glyphs to be loaded ahead. I'll have to think about it. For now but it should be a reasonably easy patch to maintain locally if you are only adding to FindGlyph() - function is trivial and not likely to change. Can you post of the gist of your changes here? (not as a formal PR, just a loose patch/dump of code) for reference. |
https://github.com/ecraven/imgui/tree/missing-glyphs |
Hi @ecraven . I've integrated your patch into my local copy of ImGui but am having issues. It keeps putting the glyphs back into the MissingGlyphs vector even after they are merged into the existing font. Expected Result: Actual Output: The below keeps looping endlessly - ImFont::FindGlyph(20116)/adding 20116 to MissingGlyphsVector |
I have it solved, @ecraven |
It's a really good news.! I may look into making an official version of something like that before implementing the full thing. |
I have it solved, @ecraven
For anyone else that has the same issue using this patch, I'd like to
confirm that the issue was solved by calling ResetMissingGlyphs()
AFTER calling GetTexDataAsRGBA32(..).
Calling GetTexDataAsRGBA32 to recreate the font texture seems to add
the missing glyphs back into the MissingGlyphs vector (I think this
isn't easy to avoid as the process of regenerating the textures must
make a lot of calls to FindGlyph). Anyway the solution was dead
simple. Works great now
Sorry, this is a detail I neglected to mention, I actually changed
FindGlyph locally to take a second parameter (bool registerMissing =
false), to make it only register missing glyphs on "external" calls to
FindGlyph, not internal imgui bookkeeping ones.
I'll try to start an actual PR over the next week.
|
Hi all, I was about to make a similar feature request, but then found this existing issue. The idea/motivation for my request was very similar. But I had a different implementation in mind:
This callback approach might be less intrusive (smaller diff compared to current code). And less overhead for the majority of the users who don't need this. Thanks for considering this. |
Closing this as the work on |
I've patched imgui locally to keep track of which glyphs are missing in a font, and provide that info to the library user, so that the font can be re-created with an appropriate glyph_range.
I'd love for this to get into mainline imgui. Should I hide things behind an #ifdef, so people can disable it at compile-time, or is a runtime check good enough, for providing an actual pull request for you all to look at?
The text was updated successfully, but these errors were encountered: