163 {
164 int glyphOffset = 0;
165 if (!multiByteGlyphs) {
166 glyphOffset = firstGlyphID - 1;
167 }
168
169 std::vector<BFChar> bfcharEntries;
170 std::vector<BFRange> bfrangeEntries;
171
172 BFRange currentRangeEntry = {0, 0, 0};
173 bool rangeEmpty = true;
174 const int limit = (
int)lastGlyphID + 1 - glyphOffset;
175
176 for (
int i = firstGlyphID - glyphOffset;
i < limit + 1; ++
i) {
178 bool inSubset =
i < limit && (subset ==
nullptr || subset->
has(gid));
179 if (!rangeEmpty) {
180
181
182
183 bool inRange =
184 i == currentRangeEntry.fEnd + 1 &&
185 i >> 8 == currentRangeEntry.fStart >> 8 &&
187 glyphToUnicode[gid] ==
188 currentRangeEntry.fUnicode +
i - currentRangeEntry.fStart;
189 if (!inSubset || !inRange) {
190 if (currentRangeEntry.fEnd > currentRangeEntry.fStart) {
191 bfrangeEntries.push_back(currentRangeEntry);
192 } else {
193 bfcharEntries.push_back({currentRangeEntry.fStart, currentRangeEntry.fUnicode});
194 }
195 rangeEmpty = true;
196 }
197 }
198 if (inSubset) {
199 currentRangeEntry.fEnd =
i;
200 if (rangeEmpty) {
201 currentRangeEntry.fStart =
i;
202 currentRangeEntry.fUnicode = glyphToUnicode[gid];
203 rangeEmpty = false;
204 }
205 }
206 }
207
208
209
212}
static void append_bfrange_section(const std::vector< BFRange > &bfrange, bool multiByte, SkDynamicMemoryWStream *cmap)
static void append_bfchar_section(const std::vector< BFChar > &bfchar, bool multiByte, SkDynamicMemoryWStream *cmap)
bool has(SkGlyphID gid) const