-
Notifications
You must be signed in to change notification settings - Fork 310
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
Font.FindGlyph and font.Glyphs return wrong data #206
Comments
Without really knowing too much about how these low-level font details work, it's hard to say if this is expected. Are you able to get the same or similar code working with the native library directly? |
If you just want to sanity check the results from FindGlyph you could just have a test case like |
This is a problem with the sizes of the first two entries in ImFontGlyph. https://github.com/ocornut/imgui/blob/3867c6c5f0eace22ce2c59ac299bae285bb84ec4/imgui.h Lists 'codepoint' and 'visible' as unsigned ints, but the compiled library seems to have 2 byte ints (?) so we need to have unsigned shorts here. Changing in ImFontGlyph.gen.cs (or structs_and_enums.json I guess)
makes the problem go away |
struct ImFontGlyph
{
unsigned int Codepoint : 31;
unsigned int Visible : 1;
float AdvanceX;
float X0, Y0, X1, Y1;
float U0, V0, U1, V1;
}; Codepoint and Visible are bitfields, both are in the same 32bit int, Codepoint fills the first 31 bits and Visible the last 1 bit. How C# manages bitfields? |
Ahhh, that makes sense now - I didn't recognise the bitfield syntax. |
Yeah, bitfields are not handled at all right now. C# has no concept of a bitfield, so this will require a lot of custom handling to make these parts work. Luckily, they are very few and far between (although it seems the Tables API has added a few new instances). |
Font ProggySmall.ttf everything renders and works correctly.
However if you print the contents of each glyph from ImGui.GetFont() you get uvs that dont make sense, AdvanceX that doesnt make sense etc. I tried to find the issue to the best of my knowledge, set structs to sequential in hopes that there is some layout mismatch, converted chars to utf8, the result is always the same - wrong data is provided.
I am not sure what is going on there.
here is the case where i found out the problem
The text was updated successfully, but these errors were encountered: