< prev index next >

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

Print this page
rev 59383 : [mq]: final
   1 /*
   2  * Copyright (c) 2008, 2019, 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


  27 
  28 import java.awt.Font;
  29 import java.io.BufferedReader;
  30 import java.io.File;
  31 import java.io.FileInputStream;
  32 import java.io.InputStreamReader;
  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     public static boolean isMacOSX14;
  53 
  54     public static boolean useJDKScaler;
  55 
  56     public static boolean isWindows;
  57 
  58     private static boolean debugFonts = false;
  59     private static PlatformLogger logger = null;
  60     private static boolean logging;
  61 
  62     // This static initializer block figures out the OS constants.
  63     static {
  64 
  65         AccessController.doPrivileged(new PrivilegedAction<Object>() {
  66             @SuppressWarnings("deprecation") // PlatformLogger.setLevel is deprecated.
  67             @Override
  68             public Object run() {
  69                 String osName = System.getProperty("os.name", "unknownOS");
  70                 isSolaris = osName.startsWith("SunOS");
  71 
  72                 isLinux = osName.startsWith("Linux");
  73 
  74                 isMacOSX = osName.contains("OS X"); // TODO: MacOSX
  75                 if (isMacOSX) {
  76                     // os.version has values like 10.13.6, 10.14.6
  77                     // If it is not positively recognised as 10.13 or less,
  78                     // assume it means 10.14 or some later version.
  79                     isMacOSX14 = true;
  80                     String version = System.getProperty("os.version", "");
  81                     if (version.startsWith("10.")) {
  82                         version = version.substring(3);
  83                         int periodIndex = version.indexOf('.');
  84                         if (periodIndex != -1) {
  85                             version = version.substring(0, periodIndex);
  86                         }
  87                         try {
  88                             int v = Integer.parseInt(version);
  89                             isMacOSX14 = (v >= 14);
  90                         } catch (NumberFormatException e) {


   1 /*
   2  * Copyright (c) 2008, 2020, 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


  27 
  28 import java.awt.Font;
  29 import java.io.BufferedReader;
  30 import java.io.File;
  31 import java.io.FileInputStream;
  32 import java.io.InputStreamReader;
  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 isLinux;
  48 
  49     public static boolean isMacOSX;
  50     public static boolean isMacOSX14;
  51 
  52     public static boolean useJDKScaler;
  53 
  54     public static boolean isWindows;
  55 
  56     private static boolean debugFonts = false;
  57     private static PlatformLogger logger = null;
  58     private static boolean logging;
  59 
  60     // This static initializer block figures out the OS constants.
  61     static {
  62 
  63         AccessController.doPrivileged(new PrivilegedAction<Object>() {
  64             @SuppressWarnings("deprecation") // PlatformLogger.setLevel is deprecated.
  65             @Override
  66             public Object run() {
  67                 String osName = System.getProperty("os.name", "unknownOS");

  68 
  69                 isLinux = osName.startsWith("Linux");
  70 
  71                 isMacOSX = osName.contains("OS X"); // TODO: MacOSX
  72                 if (isMacOSX) {
  73                     // os.version has values like 10.13.6, 10.14.6
  74                     // If it is not positively recognised as 10.13 or less,
  75                     // assume it means 10.14 or some later version.
  76                     isMacOSX14 = true;
  77                     String version = System.getProperty("os.version", "");
  78                     if (version.startsWith("10.")) {
  79                         version = version.substring(3);
  80                         int periodIndex = version.indexOf('.');
  81                         if (periodIndex != -1) {
  82                             version = version.substring(0, periodIndex);
  83                         }
  84                         try {
  85                             int v = Integer.parseInt(version);
  86                             isMacOSX14 = (v >= 14);
  87                         } catch (NumberFormatException e) {


< prev index next >