impr: Allow ImHex to be used without subpixel rendering on Windows if only OpenGL 3 is available

This commit is contained in:
WerWolv
2025-08-09 19:13:45 +02:00
parent e6f46747b6
commit d925c8216d
7 changed files with 62 additions and 14 deletions

View File

@@ -13,18 +13,33 @@ namespace hex::fonts {
class AntialiasPicker : public ContentRegistry::Settings::Widgets::DropDown {
public:
AntialiasPicker() : DropDown(
// Only allow subpixel rendering on Windows and Linux
#if defined(OS_WINDOWS) || defined(OS_LINUX)
std::vector<UnlocalizedString>({"hex.fonts.setting.font.antialias_none", "hex.fonts.setting.font.antialias_grayscale", "hex.fonts.setting.font.antialias_subpixel"}),
std::vector<nlohmann::json>({"none", "grayscale" , "subpixel"}),
nlohmann::json("subpixel")
#else
std::vector<UnlocalizedString>({"hex.fonts.setting.font.antialias_none", "hex.fonts.setting.font.antialias_grayscale"}),
std::vector<nlohmann::json>({"none", "grayscale"}),
nlohmann::json("grayscale")
#endif
){}
AntialiasPicker() : DropDown(create()) { }
private:
static bool isSubpixelRenderingSupported() {
#if defined(OS_WINDOWS) || defined(OS_LINUX)
return ImHexApi::System::getGLVersion() >= SemanticVersion(4,1,0);
#else
return false;
#endif
}
static DropDown create() {
if (isSubpixelRenderingSupported()) {
return DropDown(
std::vector<UnlocalizedString>{ "hex.fonts.setting.font.antialias_none", "hex.fonts.setting.font.antialias_grayscale", "hex.fonts.setting.font.antialias_subpixel" },
{ "none", "grayscale" , "subpixel" },
"subpixel"
);
} else {
return DropDown(
std::vector<UnlocalizedString>{ "hex.fonts.setting.font.antialias_none", "hex.fonts.setting.font.antialias_grayscale" },
{ "none", "grayscale" },
"grayscale"
);
}
}
};
class FontFilePicker : public ContentRegistry::Settings::Widgets::FilePicker {