Added support for displaying non-ASCII characters in decoder view
This requires the user to provide a font that supports these characters as well (for example unifont). The default ImGui font does not have them.
This commit is contained in:
parent
b4c2f7d371
commit
1eb6f781b3
14
external/ImGui/include/imgui_memory_editor.h
vendored
14
external/ImGui/include/imgui_memory_editor.h
vendored
@ -588,15 +588,15 @@ struct MemoryEditor
|
|||||||
auto decodedData = DecodeFn(mem_data, addr);
|
auto decodedData = DecodeFn(mem_data, addr);
|
||||||
|
|
||||||
auto displayData = decodedData.data;
|
auto displayData = decodedData.data;
|
||||||
auto decodedDataLength = displayData.length();
|
auto glyphWidth = ImGui::CalcTextSize(displayData.c_str()).x + 1;
|
||||||
|
|
||||||
if (addr == DataEditingAddr)
|
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 + glyphWidth, 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_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
|
// Draw highlight
|
||||||
bool is_highlight_from_user_range = (addr >= HighlightMin && addr < HighlightMax);
|
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)
|
if ((is_highlight_from_user_range + is_highlight_from_user_func + is_highlight_from_preview) > 1)
|
||||||
color = (ImAlphaBlendColors(HighlightColor, 0x60C08080) & 0x00FFFFFF) | 0x90000000;
|
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::PushID(line_i * Cols + n);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Dummy(ImVec2(s.GlyphWidth * decodedDataLength, s.LineHeight));
|
ImGui::Dummy(ImVec2(glyphWidth, s.LineHeight));
|
||||||
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
|
|
||||||
@ -633,7 +633,7 @@ struct MemoryEditor
|
|||||||
DataPreviewAddrEnd = addr;
|
DataPreviewAddrEnd = addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos.x += s.GlyphWidth * decodedDataLength;
|
pos.x += glyphWidth;
|
||||||
|
|
||||||
if (addr <= 1) {
|
if (addr <= 1) {
|
||||||
n++;
|
n++;
|
||||||
|
@ -183,7 +183,19 @@ namespace hex {
|
|||||||
// Load font data & build atlas
|
// Load font data & build atlas
|
||||||
std::uint8_t *px;
|
std::uint8_t *px;
|
||||||
int w, h;
|
int w, h;
|
||||||
io.Fonts->AddFontFromFileTTF(path.string().c_str(), std::floor(14.0f * this->m_fontScale)); // Needs conversion to char for Windows
|
|
||||||
|
ImVector<ImWchar> 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);
|
ImGuiFreeType::BuildFontAtlas(io.Fonts, ImGuiFreeType::Monochrome);
|
||||||
io.Fonts->GetTexDataAsRGBA32(&px, &w, &h);
|
io.Fonts->GetTexDataAsRGBA32(&px, &w, &h);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user