119 /** |
119 /** |
120 * Get the starting index of the current script run. |
120 * Get the starting index of the current script run. |
121 * |
121 * |
122 * @return the index of the first character in the current script run. |
122 * @return the index of the first character in the current script run. |
123 */ |
123 */ |
124 public final int getScriptStart() { |
124 public int getScriptStart() { |
125 return scriptStart; |
125 return scriptStart; |
126 } |
126 } |
127 |
127 |
128 /** |
128 /** |
129 * Get the index of the first character after the current script run. |
129 * Get the index of the first character after the current script run. |
130 * |
130 * |
131 * @return the index of the first character after the current script run. |
131 * @return the index of the first character after the current script run. |
132 */ |
132 */ |
133 public final int getScriptLimit() { |
133 public int getScriptLimit() { |
134 return scriptLimit; |
134 return scriptLimit; |
135 } |
135 } |
136 |
136 |
137 /** |
137 /** |
138 * Get the script code for the script of the current script run. |
138 * Get the script code for the script of the current script run. |
139 * |
139 * |
140 * @return the script code for the script of the current script run. |
140 * @return the script code for the script of the current script run. |
141 * @see #Script |
141 * @see #Script |
142 */ |
142 */ |
143 public final int getScriptCode() { |
143 public int getScriptCode() { |
144 return scriptCode; |
144 return scriptCode; |
145 } |
145 } |
146 |
146 |
147 /** |
147 /** |
148 * Find the next script run. Returns <code>false</code> if there |
148 * Find the next script run. Returns <code>false</code> if there |
149 * isn't another run, returns <code>true</code> if there is. |
149 * isn't another run, returns <code>true</code> if there is. |
150 * |
150 * |
151 * @return <code>false</code> if there isn't another run, <code>true</code> if there is. |
151 * @return <code>false</code> if there isn't another run, <code>true</code> if there is. |
152 */ |
152 */ |
153 public final boolean next() { |
153 public boolean next() { |
154 int startSP = parenSP; // used to find the first new open character |
154 int startSP = parenSP; // used to find the first new open character |
155 |
155 |
156 // if we've fallen off the end of the text, we're done |
156 // if we've fallen off the end of the text, we're done |
157 if (scriptLimit >= textLimit) { |
157 if (scriptLimit >= textLimit) { |
158 return false; |
158 return false; |
240 static final int LEAD_SURROGATE_SHIFT = 10; |
240 static final int LEAD_SURROGATE_SHIFT = 10; |
241 static final int SURROGATE_OFFSET = SURROGATE_START - (LEAD_START << LEAD_SURROGATE_SHIFT) - TAIL_START; |
241 static final int SURROGATE_OFFSET = SURROGATE_START - (LEAD_START << LEAD_SURROGATE_SHIFT) - TAIL_START; |
242 |
242 |
243 static final int DONE = -1; |
243 static final int DONE = -1; |
244 |
244 |
245 private final int nextCodePoint() { |
245 private int nextCodePoint() { |
246 if (scriptLimit >= textLimit) { |
246 if (scriptLimit >= textLimit) { |
247 return DONE; |
247 return DONE; |
248 } |
248 } |
249 int ch = text[scriptLimit++]; |
249 int ch = text[scriptLimit++]; |
250 if (ch >= LEAD_START && ch < LEAD_LIMIT && scriptLimit < textLimit) { |
250 if (ch >= LEAD_START && ch < LEAD_LIMIT && scriptLimit < textLimit) { |