diff --git a/external/ImGui/include/imgui_memory_editor.h b/external/ImGui/include/imgui_memory_editor.h index 709746860..17ea5653f 100644 --- a/external/ImGui/include/imgui_memory_editor.h +++ b/external/ImGui/include/imgui_memory_editor.h @@ -588,15 +588,15 @@ struct MemoryEditor auto decodedData = DecodeFn(mem_data, addr); auto displayData = decodedData.data; - auto decodedDataLength = displayData.length(); + auto glyphWidth = ImGui::CalcTextSize(displayData.c_str()).x + 1; if (addr == DataEditingAddr) { - draw_list->AddRectFilled(pos, ImVec2(pos.x + s.GlyphWidth * decodedDataLength, pos.y + s.LineHeight), ImGui::GetColorU32(ImGuiCol_FrameBg)); - draw_list->AddRectFilled(pos, ImVec2(pos.x + s.GlyphWidth * decodedDataLength, pos.y + s.LineHeight), ImGui::GetColorU32(ImGuiCol_TextSelectedBg)); + draw_list->AddRectFilled(pos, ImVec2(pos.x + glyphWidth, pos.y + s.LineHeight), ImGui::GetColorU32(ImGuiCol_FrameBg)); + draw_list->AddRectFilled(pos, ImVec2(pos.x + glyphWidth, pos.y + s.LineHeight), ImGui::GetColorU32(ImGuiCol_TextSelectedBg)); } - draw_list->AddText(pos, decodedData.color, displayData.c_str(), displayData.c_str() + decodedDataLength); + draw_list->AddText(pos, decodedData.color, displayData.c_str(), displayData.c_str() + displayData.length()); // Draw highlight bool is_highlight_from_user_range = (addr >= HighlightMin && addr < HighlightMax); @@ -608,13 +608,13 @@ struct MemoryEditor if ((is_highlight_from_user_range + is_highlight_from_user_func + is_highlight_from_preview) > 1) color = (ImAlphaBlendColors(HighlightColor, 0x60C08080) & 0x00FFFFFF) | 0x90000000; - draw_list->AddRectFilled(pos, ImVec2(pos.x + s.GlyphWidth * decodedDataLength, pos.y + s.LineHeight), color); + draw_list->AddRectFilled(pos, ImVec2(pos.x + glyphWidth, pos.y + s.LineHeight), color); } ImGui::PushID(line_i * Cols + n); ImGui::SameLine(); - ImGui::Dummy(ImVec2(s.GlyphWidth * decodedDataLength, s.LineHeight)); + ImGui::Dummy(ImVec2(glyphWidth, s.LineHeight)); ImGui::PopID(); @@ -633,7 +633,7 @@ struct MemoryEditor DataPreviewAddrEnd = addr; } - pos.x += s.GlyphWidth * decodedDataLength; + pos.x += glyphWidth; if (addr <= 1) { n++; diff --git a/source/window.cpp b/source/window.cpp index 20b1fcbe1..49266c029 100644 --- a/source/window.cpp +++ b/source/window.cpp @@ -183,7 +183,19 @@ namespace hex { // Load font data & build atlas std::uint8_t *px; int w, h; - io.Fonts->AddFontFromFileTTF(path.string().c_str(), std::floor(14.0f * this->m_fontScale)); // Needs conversion to char for Windows + + ImVector ranges; + ImFontGlyphRangesBuilder glyphRangesBuilder; + glyphRangesBuilder.AddRanges(io.Fonts->GetGlyphRangesDefault()); + glyphRangesBuilder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); + glyphRangesBuilder.AddRanges(io.Fonts->GetGlyphRangesChineseFull()); + glyphRangesBuilder.AddRanges(io.Fonts->GetGlyphRangesCyrillic()); + glyphRangesBuilder.AddRanges(io.Fonts->GetGlyphRangesKorean()); + glyphRangesBuilder.AddRanges(io.Fonts->GetGlyphRangesThai()); + glyphRangesBuilder.AddRanges(io.Fonts->GetGlyphRangesVietnamese()); + glyphRangesBuilder.BuildRanges(&ranges); + + io.Fonts->AddFontFromFileTTF(path.string().c_str(), std::floor(14.0f * this->m_fontScale), nullptr, ranges.Data); // Needs conversion to char for Windows ImGuiFreeType::BuildFontAtlas(io.Fonts, ImGuiFreeType::Monochrome); io.Fonts->GetTexDataAsRGBA32(&px, &w, &h);