Helper tool to diagnose between text encoding issues and font loading issues. Pass your UTF-8 string and verify that there are correct.
| 21029 | |
| 21030 | // Helper tool to diagnose between text encoding issues and font loading issues. Pass your UTF-8 string and verify that there are correct. |
| 21031 | void ImGui::DebugTextEncoding(const char* str) |
| 21032 | { |
| 21033 | Text("Text: \"%s\"", str); |
| 21034 | if (!BeginTable("##DebugTextEncoding", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable)) |
| 21035 | return; |
| 21036 | TableSetupColumn("Offset"); |
| 21037 | TableSetupColumn("UTF-8"); |
| 21038 | TableSetupColumn("Glyph"); |
| 21039 | TableSetupColumn("Codepoint"); |
| 21040 | TableHeadersRow(); |
| 21041 | for (const char* p = str; *p != 0; ) |
| 21042 | { |
| 21043 | unsigned int c; |
| 21044 | const int c_utf8_len = ImTextCharFromUtf8(&c, p, NULL); |
| 21045 | TableNextColumn(); |
| 21046 | Text("%d", (int)(p - str)); |
| 21047 | TableNextColumn(); |
| 21048 | for (int byte_index = 0; byte_index < c_utf8_len; byte_index++) |
| 21049 | { |
| 21050 | if (byte_index > 0) |
| 21051 | SameLine(); |
| 21052 | Text("0x%02X", (int)(unsigned char)p[byte_index]); |
| 21053 | } |
| 21054 | TableNextColumn(); |
| 21055 | if (GetFont()->FindGlyphNoFallback((ImWchar)c)) |
| 21056 | TextUnformatted(p, p + c_utf8_len); |
| 21057 | else |
| 21058 | TextUnformatted((c == IM_UNICODE_CODEPOINT_INVALID) ? "[invalid]" : "[missing]"); |
| 21059 | TableNextColumn(); |
| 21060 | Text("U+%04X", (int)c); |
| 21061 | p += c_utf8_len; |
| 21062 | } |
| 21063 | EndTable(); |
| 21064 | } |
| 21065 | |
| 21066 | static void DebugFlashStyleColorStop() |
| 21067 | { |
nothing calls this directly
no test coverage detected