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) vsSize = 2;
136 if (secondPosition + vsSize == pos){ // Real slot
137 sl = glyphs[0] & CompositeGlyphMapper.SLOTMASK;
138 slot = sl >>> 24;
139 }
140 if ((glyphs[0] & CompositeGlyphMapper.SLOTMASK) != sl) {
141 pushback(ch);
142 pushback(preChar);
143 return true;
144 }
145 }else{
146 consumed = false;
147 if ((mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK) != sl) {
148 break;
149 }
150 }
151 preChar = ch;
152 }
153 pushback(ch);
154
155 return true;
156 }
157
158 public boolean next() {
159 return next(Script.COMMON, limit);
160 }
161
162 static final int SURROGATE_START = 0x10000;
163 static final int LEAD_START = 0xd800;
164 static final int LEAD_LIMIT = 0xdc00;
165 static final int TAIL_START = 0xdc00;
166 static final int TAIL_LIMIT = 0xe000;
167 static final int LEAD_SURROGATE_SHIFT = 10;
168 static final int SURROGATE_OFFSET = SURROGATE_START - (LEAD_START << LEAD_SURROGATE_SHIFT) - TAIL_START;
169
170 static final int DONE = -1;
171
172 int nextCodePoint() {
|