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


< prev index next >