-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
Prevent unwanted font face changes #4882
Conversation
I think it's worth explaining in more detail the logic of what is happening there. The font contains several faces: Lines 131 to 135 in 97f0641
it can be seen that the main face is at the end of the vector. How does it become main? A range is added to it (when a glyph is added, a range is created for it if it does not fall into an existing one, and in the beginning we don't have any ranges at all) Line 202 in 97f0641
In the next function, the font texture is created, apparently Lines 347 to 386 in 97f0641
It iterates over all faces of the font, in turn (note that the main face comes last) Line 352 in 97f0641
but it ignores faces without ranges, and in the beginning we have a range only for the main face. Line 359 in 97f0641
А default range is added to each iterated face Line 363 in 97f0641
that's what this range is pioneer/contrib/imgui/imgui_draw.cpp Lines 2225 to 2234 in 97f0641
If after rendering, the dear ImGui lacks a glyph, this function is called (I omitted the details, there are a lot of calls, as I understand it) Lines 161 to 184 in 97f0641
It checks all faces of the font for the presence of a given glyph, and also sets the flag that fonts need to be rebuilt Lines 176 to 181 in 97f0641
Аnd now we have a range not only in the main face, but also in some other. When baking, it will go before the main face, and now the default range will be added to it. When it comes to the main face, the range will already be occupied. Therefore, I simply rearranged the main face to the top of the list, and the default range will always be taken from it, and everything that cannot be found in it will be taken from other faces. |
@Gliese852 can I ask you to please transcribe that excellent write-up to function comments? The overall architecture is something I've had to reverse-engineer myself when doing imgui upgrades, and I'd really really appreciate having this overview as function comments so future maintainers (and future me!) don't have to recreate it. |
When a character appears in the text, that is not in the default font face, it is looked up in the spare faces of the font. Moreover, the default range also began to be baked from the spare face. I made that only characters that are not in the default face are baked from the spare face. Also renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder because: contrib/imgui/imgui.h:2181: typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+
@Web-eWorks Done, tried to adapt this information, because in this topic it is written how it works now, and in the comments in the code, I wrote how it will work after the patch. |
Before PR -> After PR


When a character appears in the text, that is not in the default font face, it is looked up in the spare faces of the font. Moreover, the default range also began to be baked from the spare face. I made that only characters that are not in the default face are baked from the spare face.
To visually see what is this all about, start a new game and click on Toliman in the sector map. In it's description there is an "α" (alpha) symbol, this leads to a complete change of the font face. This PR fixes this issue.
Fixes #4807