mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
impr: Add warning about using fractional scaling with default font
This commit is contained in:
@@ -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; };
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user