static OTF_GlyphID
get_uvs_glyph (OTF_cmap *cmap, OTF_EncodingSubtable14 *sub14, int c1, int c2)
{
+ unsigned nRecords = sub14->nRecords;
+ OTF_VariationSelectorRecord *record;
+ unsigned i;
+
+ for (i = 0; i < nRecords; i++)
+ {
+ record = &sub14->Records[i];
+ if (record->varSelector == c2)
+ {
+ if (record->defaultUVSOffset)
+ {
+ OTF_UnicodeValueRange *uVRs = record->unicodeValueRanges;
+ unsigned numUVRs = record->numUnicodeValueRanges;
+ unsigned top = numUVRs, bottom = 0, middle;
+
+ if (uVRs[0].startUnicodeValue <= c1)
+ {
+ unsigned additionalCount, startUnicodeValue;
+
+ for (;;)
+ {
+ middle = (top + bottom) / 2;
+ if (c1 < uVRs[middle].startUnicodeValue)
+ top = middle;
+ else if (bottom == middle)
+ break;
+ else
+ bottom = middle;
+ }
+ startUnicodeValue = uVRs[bottom].startUnicodeValue;
+ additionalCount = uVRs[bottom].additionalCount;
+ if (c1 <= startUnicodeValue + additionalCount)
+ return cmap->unicode_table[c1];
+ }
+ }
+ if (record->nonDefaultUVSOffset)
+ {
+ OTF_UVSMapping *uvsMappings = record->uvsMappings;
+ unsigned numUVSMs = record->numUVSMappings;
+ unsigned top = numUVSMs, bottom = 0, middle;
+
+ if (uvsMappings[0].unicodeValue <= c1)
+ {
+ for (;;)
+ {
+ middle = (top + bottom) / 2;
+ if (c1 < uvsMappings[middle].unicodeValue)
+ top = middle;
+ else if (bottom == middle)
+ break;
+ else
+ bottom = middle;
+ }
+ if (uvsMappings[bottom].unicodeValue == c1)
+ return uvsMappings[bottom].glyphID;
+ }
+ }
+ return 0;
+ }
+ }
return 0;
}