mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 15:57:03 -05:00
fix: Crashes when font failed to be loaded
This commit is contained in:
@@ -24,6 +24,7 @@ namespace hex::fonts::loader {
|
||||
ImFontConfig config;
|
||||
config.MergeMode = false;
|
||||
config.SizePixels = settings.getFontSize();
|
||||
config.Flags |= ImFontFlags_NoLoadError;
|
||||
|
||||
std::memcpy(config.Name, name.get().c_str(), std::min(name.get().size(), sizeof(config.Name) - 1));
|
||||
|
||||
|
||||
@@ -25,21 +25,24 @@ namespace hex::fonts {
|
||||
return true;
|
||||
}
|
||||
|
||||
ImFontConfig config = {};
|
||||
config.FontDataOwnedByAtlas = true;
|
||||
config.Flags |= ImFontFlags_NoLoadError;
|
||||
|
||||
auto atlas = ImGui::GetIO().Fonts;
|
||||
|
||||
auto it = s_previewFonts.find(fontPath);
|
||||
if (it == s_previewFonts.end()) {
|
||||
ImFont *font = nullptr;
|
||||
if (fontPath == PixelPerfectFontName) {
|
||||
font = atlas->AddFontDefault();
|
||||
font = atlas->AddFontDefault(&config);
|
||||
} else if (fontPath == SmoothFontName || fontPath.empty()) {
|
||||
static auto jetbrainsFont = romfs::get("fonts/JetBrainsMono.ttf");
|
||||
ImFontConfig config = {};
|
||||
config.FontDataOwnedByAtlas = false;
|
||||
|
||||
font = atlas->AddFontFromMemoryTTF(const_cast<u8 *>(jetbrainsFont.data<u8>()), jetbrainsFont.size(), 0.0F, &config);
|
||||
} else {
|
||||
font = atlas->AddFontFromFileTTF(wolv::util::toUTF8String(fontPath).c_str());
|
||||
font = atlas->AddFontFromFileTTF(wolv::util::toUTF8String(fontPath).c_str(), 0.0F, &config);
|
||||
}
|
||||
|
||||
it = s_previewFonts.emplace(fontPath, font).first;
|
||||
|
||||
Reference in New Issue
Block a user