< prev index next >

src/java.desktop/share/classes/sun/font/FontUtilities.java

Print this page




  36 
  37 import java.security.PrivilegedAction;
  38 import javax.swing.plaf.FontUIResource;
  39 
  40 import sun.util.logging.PlatformLogger;
  41 
  42 /**
  43  * A collection of utility methods.
  44  */
  45 public final class FontUtilities {
  46 
  47     public static boolean isSolaris;
  48 
  49     public static boolean isLinux;
  50 
  51     public static boolean isMacOSX;
  52 
  53     public static boolean useJDKScaler;
  54 
  55     public static boolean useT2K;


  56 
  57     public static boolean isWindows;
  58 
  59     public static boolean isOpenJDK;
  60 
  61     static final String LUCIDA_FILE_NAME = "LucidaSansRegular.ttf";
  62 
  63     private static boolean debugFonts = false;
  64     private static PlatformLogger logger = null;
  65     private static boolean logging;
  66 
  67     // This static initializer block figures out the OS constants.
  68     static {
  69 
  70         AccessController.doPrivileged(new PrivilegedAction<Object>() {
  71             @SuppressWarnings("deprecation") // PlatformLogger.setLevel is deprecated.
  72             @Override
  73             public Object run() {
  74                 String osName = System.getProperty("os.name", "unknownOS");
  75                 isSolaris = osName.startsWith("SunOS");


  77                 isLinux = osName.startsWith("Linux");
  78 
  79                 isMacOSX = osName.contains("OS X"); // TODO: MacOSX
  80 
  81                 /* Support a value of "t2k" as meaning use the JDK internal
  82                  * scaler over the platform scaler whether or not t2k is
  83                  * actually available.
  84                  * This can be considered transitional support for some
  85                  * level of compatibility, as in it avoids the native scaler
  86                  * as before but cannot guarantee rendering equivalence
  87                  * with T2K.
  88                  * It will also use t2k instead of freetype if t2k is
  89                  * available - this is the same as before.
  90                  * The new value of "jdk" means even if t2k is available,
  91                  * the decision as to whether to use that or freetype is
  92                  * not affected by this setting.
  93                  */
  94                 String scalerStr = System.getProperty("sun.java2d.font.scaler");
  95                 if (scalerStr != null) {
  96                     useT2K = "t2k".equals(scalerStr);







  97                     useJDKScaler = useT2K || "jdk".equals(scalerStr);
  98                 } else {
  99                     useT2K = false;

 100                     useJDKScaler = false;
 101                 }
 102                 isWindows = osName.startsWith("Windows");
 103                 String jreLibDirName = System.getProperty("java.home", "")
 104                                                       + File.separator + "lib";
 105                 String jreFontDirName =
 106                         jreLibDirName + File.separator + "fonts";
 107                 File lucidaFile = new File(jreFontDirName + File.separator
 108                                            + LUCIDA_FILE_NAME);
 109                 isOpenJDK = !lucidaFile.exists();
 110 
 111                 String debugLevel =
 112                     System.getProperty("sun.java2d.debugfonts");
 113 
 114                 if (debugLevel != null && !debugLevel.equals("false")) {
 115                     debugFonts = true;
 116                     logger = PlatformLogger.getLogger("sun.java2d");
 117                     if (debugLevel.equals("warning")) {
 118                         logger.setLevel(PlatformLogger.Level.WARNING);
 119                     } else if (debugLevel.equals("severe")) {




  36 
  37 import java.security.PrivilegedAction;
  38 import javax.swing.plaf.FontUIResource;
  39 
  40 import sun.util.logging.PlatformLogger;
  41 
  42 /**
  43  * A collection of utility methods.
  44  */
  45 public final class FontUtilities {
  46 
  47     public static boolean isSolaris;
  48 
  49     public static boolean isLinux;
  50 
  51     public static boolean isMacOSX;
  52 
  53     public static boolean useJDKScaler;
  54 
  55     public static boolean useT2K;
  56     // useLegacy is a short-term debugging transition aid.
  57     public static boolean useLegacy;
  58 
  59     public static boolean isWindows;
  60 
  61     public static boolean isOpenJDK;
  62 
  63     static final String LUCIDA_FILE_NAME = "LucidaSansRegular.ttf";
  64 
  65     private static boolean debugFonts = false;
  66     private static PlatformLogger logger = null;
  67     private static boolean logging;
  68 
  69     // This static initializer block figures out the OS constants.
  70     static {
  71 
  72         AccessController.doPrivileged(new PrivilegedAction<Object>() {
  73             @SuppressWarnings("deprecation") // PlatformLogger.setLevel is deprecated.
  74             @Override
  75             public Object run() {
  76                 String osName = System.getProperty("os.name", "unknownOS");
  77                 isSolaris = osName.startsWith("SunOS");


  79                 isLinux = osName.startsWith("Linux");
  80 
  81                 isMacOSX = osName.contains("OS X"); // TODO: MacOSX
  82 
  83                 /* Support a value of "t2k" as meaning use the JDK internal
  84                  * scaler over the platform scaler whether or not t2k is
  85                  * actually available.
  86                  * This can be considered transitional support for some
  87                  * level of compatibility, as in it avoids the native scaler
  88                  * as before but cannot guarantee rendering equivalence
  89                  * with T2K.
  90                  * It will also use t2k instead of freetype if t2k is
  91                  * available - this is the same as before.
  92                  * The new value of "jdk" means even if t2k is available,
  93                  * the decision as to whether to use that or freetype is
  94                  * not affected by this setting.
  95                  */
  96                 String scalerStr = System.getProperty("sun.java2d.font.scaler");
  97                 if (scalerStr != null) {
  98                     useT2K = "t2k".equals(scalerStr);
  99                     if (useT2K) {
 100                         System.out.println("WARNING: t2k will be removed in JDK 11.");
 101                     }
 102                     useLegacy = "legacy".equals(scalerStr);
 103                     if (useLegacy) {
 104                         System.out.println("WARNING: legacy behavior will be removed in JDK 11.");
 105                     }
 106                     useJDKScaler = useT2K || "jdk".equals(scalerStr);
 107                 } else {
 108                     useT2K = false;
 109                     useLegacy = false;
 110                     useJDKScaler = false;
 111                 }
 112                 isWindows = osName.startsWith("Windows");
 113                 String jreLibDirName = System.getProperty("java.home", "")
 114                                                       + File.separator + "lib";
 115                 String jreFontDirName =
 116                         jreLibDirName + File.separator + "fonts";
 117                 File lucidaFile = new File(jreFontDirName + File.separator
 118                                            + LUCIDA_FILE_NAME);
 119                 isOpenJDK = !lucidaFile.exists();
 120 
 121                 String debugLevel =
 122                     System.getProperty("sun.java2d.debugfonts");
 123 
 124                 if (debugLevel != null && !debugLevel.equals("false")) {
 125                     debugFonts = true;
 126                     logger = PlatformLogger.getLogger("sun.java2d");
 127                     if (debugLevel.equals("warning")) {
 128                         logger.setLevel(PlatformLogger.Level.WARNING);
 129                     } else if (debugLevel.equals("severe")) {


< prev index next >