int i, j;
for (i = 0; i < script_list->ScriptCount; i++)
- if (script_list->Script[i].ScriptTag == script_tag)
+ if (! script_tag
+ || script_list->Script[i].ScriptTag == script_tag)
{
OTF_Script *script = script_list->Script + i;
class = get_class_def (&context2->ClassDef, g->glyph_id);
set = context2->ClassSet + class;
- for (j = 0; j < set->ClassRuleCnt; j++)
- {
- rule = set->ClassRule + j;
- if (match_classes (&context2->ClassDef,
- gstring, gidx + 1,
- rule->GlyphCount - 1, rule->Class)
- < 0)
- continue;
- orig_used = gstring->used;
- for (k = 0; k < rule->LookupCount; k++)
- lookup_gsub (lookup_list,
- rule->LookupRecord[k].LookupListIndex,
- gstring,
- gidx + rule->LookupRecord[k].SequenceIndex);
- gidx += rule->GlyphCount + (gstring->used - orig_used);
- break;
- }
+ if (set)
+ for (j = 0; j < set->ClassRuleCnt; j++)
+ {
+ rule = set->ClassRule + j;
+ if (match_classes (&context2->ClassDef,
+ gstring, gidx + 1,
+ rule->GlyphCount - 1, rule->Class)
+ < 0)
+ continue;
+ orig_used = gstring->used;
+ for (k = 0; k < rule->LookupCount; k++)
+ lookup_gsub (lookup_list,
+ rule->LookupRecord[k].LookupListIndex,
+ gstring,
+ gidx + rule->LookupRecord[k].SequenceIndex);
+ gidx += rule->GlyphCount + (gstring->used - orig_used);
+ break;
+ }
}
else /* subtable->Format == 3 */
{
if (gidx < context3->BacktrackGlyphCount
|| (gidx + context3->InputGlyphCount
+ context3->LookaheadGlyphCount) > gstring->used)
- return -1;
+ continue;
if (match_chain_coverages (gstring, gidx, context3) < 0)
continue;
orig_used = gstring->used;
break;
case 2:
- if (gidx + 1 >= gstring->used)
- continue;
- if (subtable->Format == 1)
- {
- OTF_GPOS_Pair1 *pair1 = &subtable->u.pair1;
- OTF_PairSet *set = pair1->PairSet + coverage_idx;
- int j;
+ {
+ int next_gidx = gidx + 1;
+ OTF_Glyph *nextg;
- for (j = 0; j < set->PairValueCount; j++)
- {
- if (set->PairValueRecord[j].SecondGlyph != g[1].glyph_id)
- continue;
- gidx++;
- g->positioning_type = lookup->LookupType;
- g->f.f2.format = pair1->ValueFormat1;
- g->f.f2.value = &set->PairValueRecord[j].Value1;
- if (pair1->ValueFormat2)
+ while (next_gidx < gstring->used
+ && ! gstring->glyphs[next_gidx].glyph_id)
+ next_gidx++;
+
+ if (next_gidx >= gstring->used)
+ continue;
+ nextg = gstring->glyphs + next_gidx;
+ if (subtable->Format == 1)
+ {
+ OTF_GPOS_Pair1 *pair1 = &subtable->u.pair1;
+ OTF_PairSet *set = pair1->PairSet + coverage_idx;
+ int j;
+
+ for (j = 0; j < set->PairValueCount; j++)
+ if (set->PairValueRecord[j].SecondGlyph == nextg->glyph_id)
{
- g++, gidx++;
- g->positioning_type = lookup->LookupType;
- g->f.f2.format = pair1->ValueFormat2;
- g->f.f2.value = &set->PairValueRecord[j].Value2;
+ if (pair1->ValueFormat1)
+ {
+ g->positioning_type = lookup->LookupType;
+ g->f.f2.format = pair1->ValueFormat1;
+ g->f.f2.value = &set->PairValueRecord[j].Value1;
+ }
+ gidx = next_gidx;
+ if (pair1->ValueFormat2)
+ {
+ nextg->positioning_type = lookup->LookupType;
+ nextg->f.f2.format = pair1->ValueFormat2;
+ nextg->f.f2.value = &set->PairValueRecord[j].Value2;
+ gidx++;
+ }
+ break;
}
- }
- }
- else if (subtable->Format == 2)
- {
- OTF_GPOS_Pair2 *pair2 = &subtable->u.pair2;
- unsigned class1, class2;
-
- gidx++;
- class1 = get_class_def (&pair2->ClassDef1, g->glyph_id);
- class2 = get_class_def (&pair2->ClassDef2, g[1].glyph_id);
- g->positioning_type = lookup->LookupType;
- g->f.f2.format = pair2->ValueFormat1;
- g->f.f2.value
- = &pair2->Class1Record[class1].Class2Record[class2].Value1;
- if (pair2->ValueFormat2)
- {
- g++, gidx++;
- g->positioning_type = lookup->LookupType;
- g->f.f2.format = pair2->ValueFormat2;
- g->f.f2.value
- = &pair2->Class1Record[class1].Class2Record[class2].Value2;
- }
- }
+ }
+ else if (subtable->Format == 2)
+ {
+ OTF_GPOS_Pair2 *pair2 = &subtable->u.pair2;
+ unsigned class1, class2;
+
+ class1 = get_class_def (&pair2->ClassDef1, g->glyph_id);
+ class2 = get_class_def (&pair2->ClassDef2, nextg->glyph_id);
+ if (pair2->ValueFormat1)
+ {
+ g->positioning_type = lookup->LookupType;
+ g->f.f2.format = pair2->ValueFormat1;
+ g->f.f2.value
+ = &pair2->Class1Record[class1].Class2Record[class2].Value1;
+ }
+ gidx = next_gidx;
+ if (pair2->ValueFormat2)
+ {
+ nextg->positioning_type = lookup->LookupType;
+ nextg->f.f2.format = pair2->ValueFormat2;
+ nextg->f.f2.value
+ = &pair2->Class1Record[class1].Class2Record[class2].Value2;
+ gidx++;
+ }
+ }
+ }
break;
case 3: