impr: Add warning about using fractional scaling with default font

This commit is contained in:
WerWolv
2024-05-18 20:32:57 +02:00
parent 125d6a3e2a
commit f0e135530a
5 changed files with 13 additions and 10 deletions

View File

@@ -229,9 +229,8 @@ namespace hex::plugin::builtin {
std::strncpy(defaultConfig.Name, fontName, sizeof(defaultConfig.Name) - 1);
if (fontFile.empty()) {
fontSize = std::floor(ImHexApi::Fonts::getFontSize() / ImHexApi::Fonts::DefaultFontSize) * ImHexApi::Fonts::DefaultFontSize;
defaultConfig.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Monochrome | ImGuiFreeTypeBuilderFlags_MonoHinting;
defaultConfig.SizePixels = fontSize;
defaultConfig.SizePixels = std::floor(ImHexApi::Fonts::getFontSize() / ImHexApi::Fonts::DefaultFontSize) * ImHexApi::Fonts::DefaultFontSize;
defaultFont = fonts->AddFontDefault(&defaultConfig);
} else {
defaultFont = fonts->AddFontFromFileTTF(wolv::util::toUTF8String(fontFile).c_str(), 0, &defaultConfig, defaultGlyphRanges.Data);
@@ -284,6 +283,8 @@ namespace hex::plugin::builtin {
if (font.defaultSize.has_value())
size = font.defaultSize.value() * std::floor(ImHexApi::Fonts::getFontSize() / ImHexApi::Fonts::DefaultFontSize);
size = std::max(1.0F, std::floor(size / ImHexApi::Fonts::DefaultFontSize)) * ImHexApi::Fonts::DefaultFontSize;
cfg.SizePixels = size;
ON_SCOPE_EXIT { cfg.MergeMode = true; };

View File

@@ -173,11 +173,14 @@ namespace hex::plugin::builtin {
return "x%.1f";
}();
if (ImGui::SliderFloat(name.data(), &m_value, 0, 10, format.c_str(), ImGuiSliderFlags_AlwaysClamp)) {
return true;
bool changed = ImGui::SliderFloat(name.data(), &m_value, 0, 10, format.c_str(), ImGuiSliderFlags_AlwaysClamp);
if (ImHexApi::Fonts::getCustomFontPath().empty() && (u32(m_value * 10) % 10) != 0) {
ImGui::SameLine();
ImGuiExt::HelpHover("hex.builtin.setting.interface.scaling.fractional_warning"_lang, ICON_VS_WARNING, ImGuiExt::GetCustomColorU32(ImGuiCustomCol_ToolbarRed));
}
return false;
return changed;
}
void load(const nlohmann::json &data) override {