mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
impr: Make fonts look less blurry with Wayland fractional scaling
This commit is contained in:
@@ -680,10 +680,20 @@ namespace hex {
|
||||
if (!sessionType.has_value() || sessionType == "x11")
|
||||
return 1.0F;
|
||||
else {
|
||||
float xScale = 0, yScale = 0;
|
||||
glfwGetMonitorContentScale(glfwGetPrimaryMonitor(), &xScale, &yScale);
|
||||
static float scaleFactor = -1;
|
||||
if (scaleFactor <= 0) {
|
||||
int windowW, windowH;
|
||||
int displayW, displayH;
|
||||
glfwGetWindowSize(getMainWindowHandle(), &windowW, &windowH);
|
||||
glfwGetFramebufferSize(getMainWindowHandle(), &displayW, &displayH);
|
||||
|
||||
return std::midpoint(xScale, yScale);
|
||||
float xScale = (windowW > 0) ? float(displayW) / windowW : 1.0f;
|
||||
float yScale = (windowH > 0) ? float(displayH) / windowH : 1.0f;
|
||||
|
||||
scaleFactor = std::midpoint(xScale, yScale);
|
||||
}
|
||||
|
||||
return scaleFactor;
|
||||
}
|
||||
#elif defined(OS_WEB)
|
||||
return MAIN_THREAD_EM_ASM_INT({ return window.devicePixelRatio; });
|
||||
|
||||
@@ -1301,6 +1301,7 @@ namespace hex {
|
||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable | ImGuiConfigFlags_NavEnableKeyboard;
|
||||
io.ConfigWindowsMoveFromTitleBarOnly = true;
|
||||
io.ConfigDragClickToInputText = true;
|
||||
io.ConfigDpiScaleFonts = true;
|
||||
|
||||
if (glfwGetPrimaryMonitor() != nullptr) {
|
||||
if (ImHexApi::System::isMultiWindowModeEnabled()) {
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace hex::fonts::loader {
|
||||
ImFontConfig config;
|
||||
config.MergeMode = false;
|
||||
config.SizePixels = settings.getFontSize() / ImHexApi::System::getNativeScale();
|
||||
config.OversampleH = 3;
|
||||
config.OversampleV = 2;
|
||||
config.RasterizerDensity = ImHexApi::System::getNativeScale();
|
||||
config.Flags |= ImFontFlags_NoLoadError;
|
||||
|
||||
std::memcpy(config.Name, name.get().c_str(), std::min(name.get().size(), sizeof(config.Name) - 1));
|
||||
|
||||
Reference in New Issue
Block a user