From 72f5ce93b264b707c54f902318e3a0a16b2e0909 Mon Sep 17 00:00:00 2001 From: Patrick Dawson Date: Sat, 20 Jan 2024 06:51:25 +0100 Subject: [PATCH] fix dpi scaling --- addons/imgui-godot/ImGuiGodot/ImGuiGD.cs | 5 +---- addons/imgui-godot/ImGuiGodot/Internal/BackendNet.cs | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs b/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs index 36de3c5..00641da 100644 --- a/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs +++ b/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs @@ -69,10 +69,7 @@ public static void RebuildFontAtlas() //if (_inProcessFrame) // throw new InvalidOperationException("fonts cannot be changed during process frame"); - bool scaleToDpi = (bool)ProjectSettings.GetSetting("display/window/dpi/allow_hidpi"); - int dpiFactor = Math.Max(1, DisplayServer.ScreenGetDpi() / 96); - - _backend.RebuildFontAtlas(scaleToDpi ? Scale * dpiFactor : Scale); + _backend.RebuildFontAtlas(Scale); } public static void Connect(Callable callable) diff --git a/addons/imgui-godot/ImGuiGodot/Internal/BackendNet.cs b/addons/imgui-godot/ImGuiGodot/Internal/BackendNet.cs index d7177e8..cb1ee90 100644 --- a/addons/imgui-godot/ImGuiGodot/Internal/BackendNet.cs +++ b/addons/imgui-godot/ImGuiGodot/Internal/BackendNet.cs @@ -39,7 +39,9 @@ public void Connect(Callable callable) public void RebuildFontAtlas(float scale) { - State.Instance.Fonts.RebuildFontAtlas(scale); + bool scaleToDpi = (bool)ProjectSettings.GetSetting("display/window/dpi/allow_hidpi"); + int dpiFactor = Math.Max(1, DisplayServer.ScreenGetDpi() / 96); + State.Instance.Fonts.RebuildFontAtlas(scaleToDpi ? dpiFactor * scale : scale); } public void ResetFonts()