< prev index next >

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

Print this page




  63  *         int limit  = scriptRun.getScriptLimit();
  64  *         int script = scriptRun.getScriptCode();
  65  *
  66  *         System.out.println("Script \"" + Script.getName(script) + "\" from " +
  67  *                            start + " to " + limit + ".");
  68  *     }
  69  *  }
  70  * </pre>
  71  *
  72  */
  73 public final class ScriptRun
  74 {
  75     private char[] text;   // fixed once set by constructor
  76     private int textStart;
  77     private int textLimit;
  78 
  79     private int scriptStart;     // change during iteration
  80     private int scriptLimit;
  81     private int scriptCode;
  82 
  83     private int stack[];         // stack used to handle paired punctuation if encountered
  84     private int parenSP;
  85 
  86     public ScriptRun() {
  87         // must call init later or we die.
  88     }
  89 
  90     /**
  91      * Construct a {@code ScriptRun} object which iterates over a subrange
  92      * of the given characetrs.
  93      *
  94      * @param chars the array of characters over which to iterate.
  95      * @param start the index of the first character over which to iterate
  96      * @param count the number of characters over which to iterate
  97      */
  98     public ScriptRun(char[] chars, int start, int count)
  99     {
 100         init(chars, start, count);
 101     }
 102 
 103     public void init(char[] chars, int start, int count)


 337         if (ch >= pairedChars[pairedCharExtra]) {
 338             index = pairedCharExtra;
 339         }
 340 
 341         while (probe > (1 << 0)) {
 342             probe >>= 1;
 343 
 344             if (ch >= pairedChars[index + probe]) {
 345                 index += probe;
 346             }
 347         }
 348 
 349         if (pairedChars[index] != ch) {
 350             index = -1;
 351         }
 352 
 353         return index;
 354     }
 355 
 356     // all common
 357     private static int pairedChars[] = {
 358         0x0028, 0x0029, // ascii paired punctuation  // common
 359         0x003c, 0x003e, // common
 360         0x005b, 0x005d, // common
 361         0x007b, 0x007d, // common
 362         0x00ab, 0x00bb, // guillemets // common
 363         0x2018, 0x2019, // general punctuation // common
 364         0x201c, 0x201d, // common
 365         0x2039, 0x203a, // common
 366         0x3008, 0x3009, // chinese paired punctuation // common
 367         0x300a, 0x300b,
 368         0x300c, 0x300d,
 369         0x300e, 0x300f,
 370         0x3010, 0x3011,
 371         0x3014, 0x3015,
 372         0x3016, 0x3017,
 373         0x3018, 0x3019,
 374         0x301a, 0x301b
 375     };
 376 
 377     private static final int pairedCharPower = 1 << highBit(pairedChars.length);


  63  *         int limit  = scriptRun.getScriptLimit();
  64  *         int script = scriptRun.getScriptCode();
  65  *
  66  *         System.out.println("Script \"" + Script.getName(script) + "\" from " +
  67  *                            start + " to " + limit + ".");
  68  *     }
  69  *  }
  70  * </pre>
  71  *
  72  */
  73 public final class ScriptRun
  74 {
  75     private char[] text;   // fixed once set by constructor
  76     private int textStart;
  77     private int textLimit;
  78 
  79     private int scriptStart;     // change during iteration
  80     private int scriptLimit;
  81     private int scriptCode;
  82 
  83     private int[] stack;         // stack used to handle paired punctuation if encountered
  84     private int parenSP;
  85 
  86     public ScriptRun() {
  87         // must call init later or we die.
  88     }
  89 
  90     /**
  91      * Construct a {@code ScriptRun} object which iterates over a subrange
  92      * of the given characetrs.
  93      *
  94      * @param chars the array of characters over which to iterate.
  95      * @param start the index of the first character over which to iterate
  96      * @param count the number of characters over which to iterate
  97      */
  98     public ScriptRun(char[] chars, int start, int count)
  99     {
 100         init(chars, start, count);
 101     }
 102 
 103     public void init(char[] chars, int start, int count)


 337         if (ch >= pairedChars[pairedCharExtra]) {
 338             index = pairedCharExtra;
 339         }
 340 
 341         while (probe > (1 << 0)) {
 342             probe >>= 1;
 343 
 344             if (ch >= pairedChars[index + probe]) {
 345                 index += probe;
 346             }
 347         }
 348 
 349         if (pairedChars[index] != ch) {
 350             index = -1;
 351         }
 352 
 353         return index;
 354     }
 355 
 356     // all common
 357     private static int[] pairedChars = {
 358         0x0028, 0x0029, // ascii paired punctuation  // common
 359         0x003c, 0x003e, // common
 360         0x005b, 0x005d, // common
 361         0x007b, 0x007d, // common
 362         0x00ab, 0x00bb, // guillemets // common
 363         0x2018, 0x2019, // general punctuation // common
 364         0x201c, 0x201d, // common
 365         0x2039, 0x203a, // common
 366         0x3008, 0x3009, // chinese paired punctuation // common
 367         0x300a, 0x300b,
 368         0x300c, 0x300d,
 369         0x300e, 0x300f,
 370         0x3010, 0x3011,
 371         0x3014, 0x3015,
 372         0x3016, 0x3017,
 373         0x3018, 0x3019,
 374         0x301a, 0x301b
 375     };
 376 
 377     private static final int pairedCharPower = 1 << highBit(pairedChars.length);
< prev index next >