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 fde94f4b873..4b0c4785994 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 @@ -5015,8 +5015,7 @@ private class SetFontOperation extends Operation { private final Font font; SetFontOperation(Font font) { - this.font = new Font(font.getDevice(), font.getFontData()); - registerForDisposal(this.font); + this.font = font != null ? SWTFontProvider.getFont(font.getDevice(), font.getFontData()[0], data.nativeZoom) : null; } @Override diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java index 9ab3a9889ec..1f3118f36d3 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java @@ -605,6 +605,9 @@ public void test_setClippingLorg_eclipse_swt_graphics_Rectangle() { @Test public void test_setFontLorg_eclipse_swt_graphics_Font() { + gc.setFont(null); + assertEquals(shell.getDisplay().getSystemFont(), gc.getFont()); + gc.setFont(shell.getDisplay().getSystemFont()); Font font = gc.getFont(); assertEquals(shell.getDisplay().getSystemFont(), font);