}
static OTF_GlyphID
-get_uvs_glyph (OTF_EncodingSubtable14 *sub14, int c1, int c2)
+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;
}
break;
if (i == cmap->numTables)
return;
- code = get_uvs_glyph (cmap->EncodingRecord[i].subtable.f.f14, c1, c2);
+ code = get_uvs_glyph (cmap, cmap->EncodingRecord[i].subtable.f.f14, c1, c2);
if (code == 0)
return;
gstring->glyphs[idx - 1].glyph_id = code;