]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/utils/FontHelper.java
Small but effective HiDPI fixes for platform G2D
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / utils / FontHelper.java
index 06bd80aa8e027c45a971de4b179bf1899c3e38c6..98d5c78f664759653e2a5ffad20cbf7600da24af 100644 (file)
 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 {
 
@@ -35,8 +35,7 @@ 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);