102 * it may be.
103 *
104 * One could also argue that the job of the composite font is to assign physical fonts
105 * to text runs, however it wishes. we don't necessarily have to provide script info
106 * to let it do this. it can determine based on whatever. so having a special 'next'
107 * function that takes script (and limit) is redundant. It can fetch the script again
108 * if need be.
109 *
110 * both this and the script iterator are turning char sequences into code point
111 * sequences. maybe it would be better to feed a single code point into each iterator-- push
112 * the data instead of pull it?
113 */
114
115 public boolean next(int script, int lim) {
116 if (pos == lim) {
117 return false;
118 }
119
120 int ch = nextCodePoint(lim);
121 int sl = mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK;
122 slot = sl >>> 24;
123 while ((ch = nextCodePoint(lim)) != DONE && (mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK) == sl);
124 pushback(ch);
125
126 return true;
127 }
128
129 public boolean next() {
130 return next(Script.COMMON, limit);
131 }
132
133 static final int SURROGATE_START = 0x10000;
134 static final int LEAD_START = 0xd800;
135 static final int LEAD_LIMIT = 0xdc00;
136 static final int TAIL_START = 0xdc00;
137 static final int TAIL_LIMIT = 0xe000;
138 static final int LEAD_SURROGATE_SHIFT = 10;
139 static final int SURROGATE_OFFSET = SURROGATE_START - (LEAD_START << LEAD_SURROGATE_SHIFT) - TAIL_START;
140
141 static final int DONE = -1;
142
143 int nextCodePoint() {
|
102 * it may be.
103 *
104 * One could also argue that the job of the composite font is to assign physical fonts
105 * to text runs, however it wishes. we don't necessarily have to provide script info
106 * to let it do this. it can determine based on whatever. so having a special 'next'
107 * function that takes script (and limit) is redundant. It can fetch the script again
108 * if need be.
109 *
110 * both this and the script iterator are turning char sequences into code point
111 * sequences. maybe it would be better to feed a single code point into each iterator-- push
112 * the data instead of pull it?
113 */
114
115 public boolean next(int script, int lim) {
116 if (pos == lim) {
117 return false;
118 }
119
120 int ch = nextCodePoint(lim);
121 int sl = mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK;
122 int secondPosition = pos;
123 int preChar = ch;
124 boolean consumed = false;
125 slot = sl >>> 24;
126 while ((ch = nextCodePoint(lim)) != DONE ) {
127 if (CharToGlyphMapper.isVariationSelector(ch)
128 && CharToGlyphMapper.isBaseChar(preChar)
129 && consumed == false) {
130 consumed = true;
131 int[] chars = {preChar, ch};
132 int[] glyphs = {0, 0};
133 mapper.charsToGlyphs(2, chars, glyphs);
134 int vsSize = 1;
135 if (ch >= 0x10000) {
136 vsSize = 2;
137 }
138 if (secondPosition + vsSize == pos) { // Real slot
139 sl = glyphs[0] & CompositeGlyphMapper.SLOTMASK;
140 slot = sl >>> 24;
141 }
142 if ((glyphs[0] & CompositeGlyphMapper.SLOTMASK) != sl) {
143 pushback(ch);
144 pushback(preChar);
145 return true;
146 }
147 } else {
148 consumed = false;
149 if ((mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK)
150 != sl) {
151 break;
152 }
153 }
154 preChar = ch;
155 }
156 pushback(ch);
157
158 return true;
159 }
160
161 public boolean next() {
162 return next(Script.COMMON, limit);
163 }
164
165 static final int SURROGATE_START = 0x10000;
166 static final int LEAD_START = 0xd800;
167 static final int LEAD_LIMIT = 0xdc00;
168 static final int TAIL_START = 0xdc00;
169 static final int TAIL_LIMIT = 0xe000;
170 static final int LEAD_SURROGATE_SHIFT = 10;
171 static final int SURROGATE_OFFSET = SURROGATE_START - (LEAD_START << LEAD_SURROGATE_SHIFT) - TAIL_START;
172
173 static final int DONE = -1;
174
175 int nextCodePoint() {
|