< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  33 import java.lang.ref.SoftReference;
  34 import java.util.concurrent.ConcurrentHashMap;
  35 import java.security.AccessController;
  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 isWindows;
  56 
  57     private static boolean debugFonts = false;
  58     private static PlatformLogger logger = null;
  59     private static boolean logging;
  60 
  61     // This static initializer block figures out the OS constants.
  62     static {
  63 
  64         AccessController.doPrivileged(new PrivilegedAction<Object>() {
  65             @SuppressWarnings("deprecation") // PlatformLogger.setLevel is deprecated.
  66             @Override
  67             public Object run() {
  68                 String osName = System.getProperty("os.name", "unknownOS");
  69                 isSolaris = osName.startsWith("SunOS");
  70 
  71                 isLinux = osName.startsWith("Linux");
  72 
  73                 isMacOSX = osName.contains("OS X"); // TODO: MacOSX


  74 
  75                 /* If set to "jdk", use the JDK's scaler rather than
  76                  * the platform one. This may be a no-op on platforms where
  77                  * JDK has been configured so that it always relies on the
  78                  * platform scaler. The principal case where it has an
  79                  * effect is that on Windows, 2D will never use GDI.
  80                  */
  81                 String scalerStr = System.getProperty("sun.java2d.font.scaler");
  82                 if (scalerStr != null) {
  83                     useJDKScaler = "jdk".equals(scalerStr);
  84                 } else {
  85                     useJDKScaler = false;
  86                 }
  87                 isWindows = osName.startsWith("Windows");
  88                 String debugLevel =
  89                     System.getProperty("sun.java2d.debugfonts");
  90 
  91                 if (debugLevel != null && !debugLevel.equals("false")) {
  92                     debugFonts = true;
  93                     logger = PlatformLogger.getLogger("sun.java2d");


   1 /*
   2  * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  33 import java.lang.ref.SoftReference;
  34 import java.util.concurrent.ConcurrentHashMap;
  35 import java.security.AccessController;
  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 isAIX;
  54 
  55     public static boolean useJDKScaler;
  56 
  57     public static boolean isWindows;
  58 
  59     private static boolean debugFonts = false;
  60     private static PlatformLogger logger = null;
  61     private static boolean logging;
  62 
  63     // This static initializer block figures out the OS constants.
  64     static {
  65 
  66         AccessController.doPrivileged(new PrivilegedAction<Object>() {
  67             @SuppressWarnings("deprecation") // PlatformLogger.setLevel is deprecated.
  68             @Override
  69             public Object run() {
  70                 String osName = System.getProperty("os.name", "unknownOS");
  71                 isSolaris = osName.startsWith("SunOS");
  72 
  73                 isLinux = osName.startsWith("Linux");
  74 
  75                 isMacOSX = osName.contains("OS X"); // TODO: MacOSX
  76 
  77                 isAIX = osName.startsWith("AIX");
  78 
  79                 /* If set to "jdk", use the JDK's scaler rather than
  80                  * the platform one. This may be a no-op on platforms where
  81                  * JDK has been configured so that it always relies on the
  82                  * platform scaler. The principal case where it has an
  83                  * effect is that on Windows, 2D will never use GDI.
  84                  */
  85                 String scalerStr = System.getProperty("sun.java2d.font.scaler");
  86                 if (scalerStr != null) {
  87                     useJDKScaler = "jdk".equals(scalerStr);
  88                 } else {
  89                     useJDKScaler = false;
  90                 }
  91                 isWindows = osName.startsWith("Windows");
  92                 String debugLevel =
  93                     System.getProperty("sun.java2d.debugfonts");
  94 
  95                 if (debugLevel != null && !debugLevel.equals("false")) {
  96                     debugFonts = true;
  97                     logger = PlatformLogger.getLogger("sun.java2d");


< prev index next >