From b8a2b4cfc6efc11f1124359266569c708e8ee193 Mon Sep 17 00:00:00 2001 From: Shahzaib Ibrahim Date: Thu, 10 Jul 2025 14:07:15 +0200 Subject: [PATCH] Use font device when setting the font instead of gc device When a font is initialized with a Printer as its device, it should only be used with a GC that was also created from that same Printer. Using such a font with a GC tied to a different device, like a Display, leads to a device mismatch. Since the printer may have a much higher DPI (e.g., 600 DPI) compared to the display (typically 96 DPI), this mismatch causes the text to render extremely large. --- .../Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java index e61fa23614f..b46419d4d63 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java @@ -4943,7 +4943,7 @@ private class SetFontOperation extends Operation { @Override void apply() { - data.font = font != null ? SWTFontProvider.getFont(device, font.getFontData()[0], data.nativeZoom) : SWTFontProvider.getSystemFont(device, data.nativeZoom); + data.font = font != null ? SWTFontProvider.getFont(font.getDevice(), font.getFontData()[0], data.nativeZoom) : SWTFontProvider.getSystemFont(device, data.nativeZoom); data.state &= ~FONT; } }