8199789: Emit a warning message when t2k is selected via system property
authorprr
Thu, 22 Mar 2018 14:10:30 -0700
changeset 49310 edbc57573a1c
parent 49309 92b1cb4cd716
child 49311 67b897123581
child 49314 b4ff41220ad9
8199789: Emit a warning message when t2k is selected via system property Reviewed-by: serb, pnarayanan
src/java.desktop/share/classes/sun/font/FontScaler.java
src/java.desktop/share/classes/sun/font/FontUtilities.java
--- a/src/java.desktop/share/classes/sun/font/FontScaler.java	Thu Mar 22 14:02:20 2018 -0700
+++ b/src/java.desktop/share/classes/sun/font/FontScaler.java	Thu Mar 22 14:10:30 2018 -0700
@@ -96,12 +96,23 @@
         try {
             @SuppressWarnings("unchecked")
             Class<? extends FontScaler> tmp = (Class<? extends FontScaler>)
-                (!FontUtilities.useT2K ?
+                ((!FontUtilities.useT2K && !FontUtilities.useLegacy) ?
                  Class.forName("sun.font.FreetypeFontScaler") :
                  Class.forName("sun.font.T2KFontScaler"));
             scalerClass = tmp;
         } catch (ClassNotFoundException e) {
+            try {
+                @SuppressWarnings("unchecked")
+                Class<? extends FontScaler> tmp = (Class<? extends FontScaler>)
+                    Class.forName("sun.font.FreetypeFontScaler");
+                scalerClass = tmp;
+            } catch (ClassNotFoundException e1) {
                 scalerClass = NullFontScaler.class;
+            }
+        } finally {
+            if (FontUtilities.debugFonts()) {
+                System.out.println("Scaler class="+scalerClass);
+            }
         }
 
         //NB: rewrite using factory? constructor is ugly way
--- a/src/java.desktop/share/classes/sun/font/FontUtilities.java	Thu Mar 22 14:02:20 2018 -0700
+++ b/src/java.desktop/share/classes/sun/font/FontUtilities.java	Thu Mar 22 14:10:30 2018 -0700
@@ -53,6 +53,8 @@
     public static boolean useJDKScaler;
 
     public static boolean useT2K;
+    // useLegacy is a short-term debugging transition aid.
+    public static boolean useLegacy;
 
     public static boolean isWindows;
 
@@ -94,9 +96,17 @@
                 String scalerStr = System.getProperty("sun.java2d.font.scaler");
                 if (scalerStr != null) {
                     useT2K = "t2k".equals(scalerStr);
+                    if (useT2K) {
+                        System.out.println("WARNING: t2k will be removed in JDK 11.");
+                    }
+                    useLegacy = "legacy".equals(scalerStr);
+                    if (useLegacy) {
+                        System.out.println("WARNING: legacy behavior will be removed in JDK 11.");
+                    }
                     useJDKScaler = useT2K || "jdk".equals(scalerStr);
                 } else {
                     useT2K = false;
+                    useLegacy = false;
                     useJDKScaler = false;
                 }
                 isWindows = osName.startsWith("Windows");