Skip to content

Commit cb16f62

Browse files
ShahzaibIbrahimfedejeanne
authored andcommitted
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.
1 parent f8c19db commit cb16f62

File tree

1 file changed

+1
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+1
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4943,7 +4943,7 @@ private class SetFontOperation extends Operation {
49434943

49444944
@Override
49454945
void apply() {
4946-
data.font = font != null ? SWTFontProvider.getFont(device, font.getFontData()[0], data.nativeZoom) : SWTFontProvider.getSystemFont(device, data.nativeZoom);
4946+
data.font = font != null ? SWTFontProvider.getFont(font.getDevice(), font.getFontData()[0], data.nativeZoom) : SWTFontProvider.getSystemFont(device, data.nativeZoom);
49474947
data.state &= ~FONT;
49484948
}
49494949
}

0 commit comments

Comments
 (0)