< prev index next >

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

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


  51         }
  52         initTables();
  53     }
  54 
  55 
  56     public MFontConfiguration(SunFontManager fm,
  57                               boolean preferLocaleFonts,
  58                               boolean preferPropFonts) {
  59         super(fm, preferLocaleFonts, preferPropFonts);
  60         if (FontUtilities.debugFonts()) {
  61             logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
  62         }
  63         initTables();
  64     }
  65 
  66     /* Needs to be kept in sync with updates in the languages used in
  67      * the fontconfig files.
  68      */
  69     protected void initReorderMap() {
  70         reorderMap = new HashMap<>();
  71         if (osName == null) {  /* null means SunOS */
  72             initReorderMapForSolaris();
  73         } else {
  74             initReorderMapForLinux();
  75         }
  76     }
  77 
  78     private void initReorderMapForSolaris() {
  79         /* Don't create a no-op entry, so we can optimize this case
  80          * i.e. we don't need to do anything so can avoid slower paths in
  81          * the code.
  82          */
  83 //      reorderMap.put("UTF-8", "latin-1");
  84         reorderMap.put("UTF-8.hi", "devanagari"); // NB is in Lucida.
  85         reorderMap.put("UTF-8.ja",
  86                        split("japanese-x0201,japanese-x0208,japanese-x0212"));
  87         reorderMap.put("UTF-8.ko", "korean-johab");
  88         reorderMap.put("UTF-8.th", "thai");
  89         reorderMap.put("UTF-8.zh.TW", "chinese-big5");
  90         reorderMap.put("UTF-8.zh.HK", split("chinese-big5,chinese-hkscs"));
  91         reorderMap.put("UTF-8.zh.CN",
  92                        split("chinese-gb18030-0,chinese-gb18030-1"));
  93         reorderMap.put("UTF-8.zh",
  94                        split("chinese-big5,chinese-hkscs,chinese-gb18030-0,chinese-gb18030-1"));
  95         reorderMap.put("Big5", "chinese-big5");
  96         reorderMap.put("Big5-HKSCS", split("chinese-big5,chinese-hkscs"));
  97         reorderMap.put("GB2312", split("chinese-gbk,chinese-gb2312"));
  98         reorderMap.put("x-EUC-TW",
  99             split("chinese-cns11643-1,chinese-cns11643-2,chinese-cns11643-3"));
 100         reorderMap.put("GBK", "chinese-gbk");
 101         reorderMap.put("GB18030",split("chinese-gb18030-0,chinese-gb18030-1"));
 102 
 103         reorderMap.put("TIS-620", "thai");
 104         reorderMap.put("x-PCK",
 105                        split("japanese-x0201,japanese-x0208,japanese-x0212"));
 106         reorderMap.put("x-eucJP-Open",
 107                        split("japanese-x0201,japanese-x0208,japanese-x0212"));
 108         reorderMap.put("EUC-KR", "korean");
 109         /* Don't create a no-op entry, so we can optimize this case */
 110 //      reorderMap.put("ISO-8859-1", "latin-1");
 111         reorderMap.put("ISO-8859-2", "latin-2");
 112         reorderMap.put("ISO-8859-5", "cyrillic-iso8859-5");
 113         reorderMap.put("windows-1251", "cyrillic-cp1251");
 114         reorderMap.put("KOI8-R", "cyrillic-koi8-r");
 115         reorderMap.put("ISO-8859-6", "arabic");
 116         reorderMap.put("ISO-8859-7", "greek");
 117         reorderMap.put("ISO-8859-8", "hebrew");
 118         reorderMap.put("ISO-8859-9", "latin-5");
 119         reorderMap.put("ISO-8859-13", "latin-7");
 120         reorderMap.put("ISO-8859-15", "latin-9");
 121     }
 122 
 123     private void initReorderMapForLinux() {
 124         reorderMap.put("UTF-8.ja.JP", "japanese-iso10646");
 125         reorderMap.put("UTF-8.ko.KR", "korean-iso10646");
 126         reorderMap.put("UTF-8.zh.TW", "chinese-tw-iso10646");
 127         reorderMap.put("UTF-8.zh.HK", "chinese-tw-iso10646");
 128         reorderMap.put("UTF-8.zh.CN", "chinese-cn-iso10646");
 129         reorderMap.put("x-euc-jp-linux",
 130                         split("japanese-x0201,japanese-x0208"));
 131         reorderMap.put("GB2312", "chinese-gb18030");
 132         reorderMap.put("Big5", "chinese-big5");
 133         reorderMap.put("EUC-KR", "korean");
 134         if (osName.equals("Sun")){
 135             reorderMap.put("GB18030", "chinese-cn-iso10646");
 136         }
 137         else {
 138             reorderMap.put("GB18030", "chinese-gb18030");
 139         }
 140     }
 141 
 142     /**
 143      * Sets the OS name and version from environment information.
 144      */
 145     protected void setOsNameAndVersion(){
 146         super.setOsNameAndVersion();
 147 
 148         if (osName.equals("SunOS")) {
 149             //don't care os name on Solaris
 150             osName = null;
 151         } else if (osName.equals("Linux")) {
 152             try {
 153                 File f;
 154                 if ((f = new File("/etc/fedora-release")).canRead()) {
 155                     osName = "Fedora";
 156                     osVersion = getVersionString(f);
 157                 } else if ((f = new File("/etc/redhat-release")).canRead()) {
 158                     osName = "RedHat";
 159                     osVersion = getVersionString(f);
 160                 } else if ((f = new File("/etc/turbolinux-release")).canRead()) {
 161                     osName = "Turbo";
 162                     osVersion = getVersionString(f);
 163                 } else if ((f = new File("/etc/SuSE-release")).canRead()) {
 164                     osName = "SuSE";
 165                     osVersion = getVersionString(f);
 166                 } else if ((f = new File("/etc/lsb-release")).canRead()) {
 167                     /* Ubuntu and (perhaps others) use only lsb-release.
 168                      * Syntax and encoding is compatible with java properties.
 169                      * For Ubuntu the ID is "Ubuntu".
 170                      */
 171                     Properties props = new Properties();


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


  51         }
  52         initTables();
  53     }
  54 
  55 
  56     public MFontConfiguration(SunFontManager fm,
  57                               boolean preferLocaleFonts,
  58                               boolean preferPropFonts) {
  59         super(fm, preferLocaleFonts, preferPropFonts);
  60         if (FontUtilities.debugFonts()) {
  61             logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
  62         }
  63         initTables();
  64     }
  65 
  66     /* Needs to be kept in sync with updates in the languages used in
  67      * the fontconfig files.
  68      */
  69     protected void initReorderMap() {
  70         reorderMap = new HashMap<>();






  71 














































  72         reorderMap.put("UTF-8.ja.JP", "japanese-iso10646");
  73         reorderMap.put("UTF-8.ko.KR", "korean-iso10646");
  74         reorderMap.put("UTF-8.zh.TW", "chinese-tw-iso10646");
  75         reorderMap.put("UTF-8.zh.HK", "chinese-tw-iso10646");
  76         reorderMap.put("UTF-8.zh.CN", "chinese-cn-iso10646");
  77         reorderMap.put("x-euc-jp-linux",
  78                         split("japanese-x0201,japanese-x0208"));
  79         reorderMap.put("GB2312", "chinese-gb18030");
  80         reorderMap.put("Big5", "chinese-big5");
  81         reorderMap.put("EUC-KR", "korean");




  82         reorderMap.put("GB18030", "chinese-gb18030");
  83     }

  84 
  85     /**
  86      * Sets the OS name and version from environment information.
  87      */
  88     protected void setOsNameAndVersion(){
  89         super.setOsNameAndVersion();
  90 
  91         if (osName.equals("Linux")) {



  92             try {
  93                 File f;
  94                 if ((f = new File("/etc/fedora-release")).canRead()) {
  95                     osName = "Fedora";
  96                     osVersion = getVersionString(f);
  97                 } else if ((f = new File("/etc/redhat-release")).canRead()) {
  98                     osName = "RedHat";
  99                     osVersion = getVersionString(f);
 100                 } else if ((f = new File("/etc/turbolinux-release")).canRead()) {
 101                     osName = "Turbo";
 102                     osVersion = getVersionString(f);
 103                 } else if ((f = new File("/etc/SuSE-release")).canRead()) {
 104                     osName = "SuSE";
 105                     osVersion = getVersionString(f);
 106                 } else if ((f = new File("/etc/lsb-release")).canRead()) {
 107                     /* Ubuntu and (perhaps others) use only lsb-release.
 108                      * Syntax and encoding is compatible with java properties.
 109                      * For Ubuntu the ID is "Ubuntu".
 110                      */
 111                     Properties props = new Properties();


< prev index next >