< prev index next >

src/java.desktop/unix/classes/sun/font/FontConfigManager.java

Print this page


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


 126      */
 127     public static Object getFontConfigAAHint(String fcFamily) {
 128         if (FontUtilities.isWindows) {
 129             return null;
 130         } else {
 131             int hint = getFontConfigAASettings(getFCLocaleStr(), fcFamily);
 132             if (hint < 0) {
 133                 return null;
 134             } else {
 135                 return SunHints.Value.get(SunHints.INTKEY_TEXT_ANTIALIASING,
 136                                           hint);
 137             }
 138         }
 139     }
 140 
 141 
 142     private static String getFCLocaleStr() {
 143         Locale l = SunToolkit.getStartupLocale();
 144         String localeStr = l.getLanguage();
 145         String country = l.getCountry();
 146         if (!country.equals("")) {
 147             localeStr = localeStr + "-" + country;
 148         }
 149         return localeStr;
 150     }
 151 
 152     /* This does cause the native libfontconfig to be loaded and unloaded,
 153      * but it does not incur the overhead of initialisation of its
 154      * data structures, so shouldn't have a measurable impact.
 155      */
 156     public static native int getFontConfigVersion();
 157 
 158     /* This can be made public if it's needed to force a re-read
 159      * rather than using the cached values. The re-read would be needed
 160      * only if some event signalled that the fontconfig has changed.
 161      * In that event this method would need to return directly the array
 162      * to be used by the caller in case it subsequently changed.
 163      */
 164     public synchronized void initFontConfigFonts(boolean includeFallbacks) {
 165 
 166         if (fontConfigFonts != null) {


   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


 126      */
 127     public static Object getFontConfigAAHint(String fcFamily) {
 128         if (FontUtilities.isWindows) {
 129             return null;
 130         } else {
 131             int hint = getFontConfigAASettings(getFCLocaleStr(), fcFamily);
 132             if (hint < 0) {
 133                 return null;
 134             } else {
 135                 return SunHints.Value.get(SunHints.INTKEY_TEXT_ANTIALIASING,
 136                                           hint);
 137             }
 138         }
 139     }
 140 
 141 
 142     private static String getFCLocaleStr() {
 143         Locale l = SunToolkit.getStartupLocale();
 144         String localeStr = l.getLanguage();
 145         String country = l.getCountry();
 146         if (!country.isEmpty()) {
 147             localeStr = localeStr + "-" + country;
 148         }
 149         return localeStr;
 150     }
 151 
 152     /* This does cause the native libfontconfig to be loaded and unloaded,
 153      * but it does not incur the overhead of initialisation of its
 154      * data structures, so shouldn't have a measurable impact.
 155      */
 156     public static native int getFontConfigVersion();
 157 
 158     /* This can be made public if it's needed to force a re-read
 159      * rather than using the cached values. The re-read would be needed
 160      * only if some event signalled that the fontconfig has changed.
 161      * In that event this method would need to return directly the array
 162      * to be used by the caller in case it subsequently changed.
 163      */
 164     public synchronized void initFontConfigFonts(boolean includeFallbacks) {
 165 
 166         if (fontConfigFonts != null) {


< prev index next >