From 820b3b9edcb6144c77809e0e9ecc7e6b9eba3f3c Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 22 Sep 2020 17:48:18 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-38376=20JDK11=E4=B8=8BLabel=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=96=87=E5=AD=97=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/utils/DesignUtils.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index 2bf64642f2..f443a10ecf 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -19,10 +19,10 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.CommonCodeUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.os.OperatingSystem; import com.fr.start.ServerStarter; import com.fr.workspace.WorkContext; -import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import java.awt.Desktop; @@ -31,7 +31,6 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; @@ -83,6 +82,7 @@ public class DesignUtils { /** * 判断设计器端口是否被其他程序占用 * 尝试去通信,无回应就是其他程序占用端口,否则需要继续判断是否为设计器进程未关闭 + * * @return */ public static boolean isPortOccupied() { @@ -153,7 +153,7 @@ public class DesignUtils { return; } try (Socket socket = new Socket("localhost", port)) { - clientSend(lines, socket); + clientSend(lines, socket); } catch (Exception ignore) { } @@ -189,10 +189,10 @@ public class DesignUtils { DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); ServerStarter.browserDemoURL(); } else if ("check".equals(line)) { - clientSend(new String[] {"response"}, socket); + clientSend(new String[]{"response"}, socket); } else if ("end".equals(line)) { - DesignerExiter.getInstance().execute(); } - else if (StringUtils.isNotEmpty(line)) { + DesignerExiter.getInstance().execute(); + } else if (StringUtils.isNotEmpty(line)) { File f = new File(line); String path = f.getAbsolutePath(); @@ -219,7 +219,7 @@ public class DesignUtils { } - public static void responseToClient(Socket socket) { + public static void responseToClient(Socket socket) { try (OutputStream outputStream = socket.getOutputStream()) { outputStream.write("reponse".getBytes(StandardCharsets.UTF_8)); outputStream.flush(); @@ -285,13 +285,20 @@ public class DesignUtils { return key.startsWith("TextField.") || key.startsWith("PasswordField."); } + /** + * 获取当前系统语言下设计器用的默认字体 + * + * @return 默认字体 + */ private static FRFont getCurrentLocaleFont() { FRFont guiFRFont; Locale defaultLocale = Locale.getDefault(); - - if (isDisplaySimSun(defaultLocale)) { + // JDK9 之后宋体在计算label中字母的空间上出现问题,暂时先用雅黑兼容,以后再统一字体 + if (StableUtils.getMajorJavaVersion() >= 9 && OperatingSystem.isWindows()) { + guiFRFont = getNamedFont("Microsoft YaHei"); + } else if (isDisplaySimSun(defaultLocale)) { guiFRFont = getNamedFont("SimSun"); - } else { + } else { guiFRFont = getNamedFont("Dialog"); }