Skip to content

Commit

Permalink
[win32] possible wrong zoom set for system font
Browse files Browse the repository at this point in the history
This commit adapts the initialization of a new base system font in the ScalingSWTFontRegistry to ensure the correct zoom is set at initialization.

contributes to #62 and #127
  • Loading branch information
akoch-yatta authored and HeikoKlare committed Oct 31, 2024
1 parent c363394 commit 9141dc8
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ public Font getSystemFont(int zoom) {
private ScaledFontContainer getOrCreateBaseSystemFontContainer(Device device) {
ScaledFontContainer systemFontContainer = fontKeyMap.get(KEY_SYSTEM_FONTS);
if (systemFontContainer == null) {
int targetZoom = DPIUtil.mapDPIToZoom(device.getDPI().x);
long systemFontHandle = createSystemFont(targetZoom);
Font systemFont = Font.win32_new(device, systemFontHandle);
systemFontContainer = new ScaledFontContainer(systemFont, targetZoom);
long hDC = device.internal_new_GC (null);
int dpiX = OS.GetDeviceCaps (hDC, OS.LOGPIXELSX);
device.internal_dispose_GC (hDC, null);
int primaryZoom = DPIUtil.mapDPIToZoom(dpiX);
long systemFontHandle = createSystemFont(primaryZoom);
Font systemFont = Font.win32_new(device, systemFontHandle, primaryZoom);
systemFontContainer = new ScaledFontContainer(systemFont, primaryZoom);
fontHandleMap.put(systemFont.handle, systemFontContainer);
fontKeyMap.put(KEY_SYSTEM_FONTS, systemFontContainer);
}
Expand Down

0 comments on commit 9141dc8

Please sign in to comment.