package org.simantics.g2d.utils;
import java.awt.Font;
-import java.awt.Toolkit;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.ui.PlatformUI;
+import org.simantics.utils.ui.SWTDPIUtil;
public final class FontHelper {
}
public static java.awt.Font toAwt(FontData fd) {
- int resolution = Toolkit.getDefaultToolkit().getScreenResolution();
- int awtFontSize = (int) Math.round((double) fd.getHeight() * resolution / 72.0);
+ int awtFontSize = SWTDPIUtil.upscaleSwt(fd.getHeight());
// The style constants for SWT and AWT map exactly, and since they are int constants, they should
// never change. So, the SWT style is passed through as the AWT style.
Font font = new java.awt.Font(fd.getName(), fd.getStyle(), awtFontSize);