Skip to content

Commit

Permalink
fix dpi scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdawson committed Jan 20, 2024
1 parent 9bf93f0 commit 72f5ce9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 1 addition & 4 deletions addons/imgui-godot/ImGuiGodot/ImGuiGD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion addons/imgui-godot/ImGuiGodot/Internal/BackendNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 72f5ce9

Please sign in to comment.