< prev index next >

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

Print this page




 155         } else if (encoding.indexOf( "gb18030.2000-0") >= 0) {
 156             jclass = "sun.font.X11GB18030_0";
 157             nBytes = DOUBLE_BYTE;
 158         } else if (encoding.indexOf("hkscs") >= 0) {
 159             jclass = "MS950_HKSCS_XP";
 160             nBytes = DOUBLE_BYTE;
 161         }
 162         return new XMap(jclass, minU, maxU, nBytes, addAscii, lowPartOnly);
 163     }
 164 
 165     private static final char SURR_MIN = '\uD800';
 166     private static final char SURR_MAX = '\uDFFF';
 167 
 168     private XMap(String className, int minU, int maxU, int nBytes,
 169                  boolean addAscii, boolean lowPartOnly) {
 170 
 171         CharsetEncoder enc = null;
 172         if (className != null) {
 173             try {
 174                 if (className.startsWith("sun.awt")) {
 175                     enc = ((Charset)Class.forName(className).newInstance()).newEncoder();

 176                 } else {
 177                     enc = Charset.forName(className).newEncoder();
 178                 }
 179             } catch (Exception x) {x.printStackTrace();}
 180         }
 181         if (enc == null) {
 182             convertedGlyphs = new char[256];
 183             for (int i=0; i<256; i++) {
 184                 convertedGlyphs[i] = (char)i;
 185             }
 186             return;
 187         } else {
 188             /* chars is set to the unicode values to convert,
 189              * bytes is where the X11 character codes will be output.
 190              * Finally we pack the byte pairs into chars.
 191              */
 192             int count = maxU - minU + 1;
 193             byte[] bytes = new byte[count*nBytes];
 194             char[] chars  = new char[count];
 195             for (int i=0; i<count; i++) {




 155         } else if (encoding.indexOf( "gb18030.2000-0") >= 0) {
 156             jclass = "sun.font.X11GB18030_0";
 157             nBytes = DOUBLE_BYTE;
 158         } else if (encoding.indexOf("hkscs") >= 0) {
 159             jclass = "MS950_HKSCS_XP";
 160             nBytes = DOUBLE_BYTE;
 161         }
 162         return new XMap(jclass, minU, maxU, nBytes, addAscii, lowPartOnly);
 163     }
 164 
 165     private static final char SURR_MIN = '\uD800';
 166     private static final char SURR_MAX = '\uDFFF';
 167 
 168     private XMap(String className, int minU, int maxU, int nBytes,
 169                  boolean addAscii, boolean lowPartOnly) {
 170 
 171         CharsetEncoder enc = null;
 172         if (className != null) {
 173             try {
 174                 if (className.startsWith("sun.awt")) {
 175                     enc = ((Charset)Class.forName(className).getDeclaredConstructor().
 176                                                   newInstance()).newEncoder();
 177                 } else {
 178                     enc = Charset.forName(className).newEncoder();
 179                 }
 180             } catch (Exception x) {x.printStackTrace();}
 181         }
 182         if (enc == null) {
 183             convertedGlyphs = new char[256];
 184             for (int i=0; i<256; i++) {
 185                 convertedGlyphs[i] = (char)i;
 186             }
 187             return;
 188         } else {
 189             /* chars is set to the unicode values to convert,
 190              * bytes is where the X11 character codes will be output.
 191              * Finally we pack the byte pairs into chars.
 192              */
 193             int count = maxU - minU + 1;
 194             byte[] bytes = new byte[count*nBytes];
 195             char[] chars  = new char[count];
 196             for (int i=0; i<count; i++) {


< prev index next >