Skip to content

Commit

Permalink
#5 Avoid GDI32.GetDeviceCaps() which gives wrong value when there are…
Browse files Browse the repository at this point in the history
… multiple screens with different display scales
  • Loading branch information
petoncle committed Jun 2, 2024
1 parent b891343 commit d52646e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/mousemaster/WindowsOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ private static void drawHints(WinDef.HDC hdc, WinDef.RECT windowRect, Screen scr
String selectedPrefixFontHexColor = currentHintMesh.selectedPrefixFontHexColor();
String boxHexColor = currentHintMesh.boxHexColor();
List<Key> focusedHintKeySequence = currentHintMesh.focusedKeySequence();
int scaledDpi = (int) (screen.dpi() * screen.scale());
// Convert point size to logical units.
int scaledDpi = GDI32.INSTANCE.GetDeviceCaps(hdc, ExtendedGDI32.LOGPIXELSY);
// 1 point = 1/72 inch. So, multiply by scaledDpi and divide by 72 to convert to pixels.
int fontHeight = -fontSize * scaledDpi / 72;
// In Windows API, negative font size means "point size" (as opposed to pixels).
Expand Down

0 comments on commit d52646e

Please sign in to comment.