for (j = 0; j < script->LangSysCount; j++)
if (script->LangSysRecord[j].LangSysTag == langsys_tag)
return script->LangSys + j;
- return &script->DefaultLangSys;
+ return &script->DefaultLangSys;
}
}
for (j = 0; j < dflt->LangSysCount; j++)
if (dflt->LangSysRecord[j].LangSysTag == langsys_tag)
return dflt->LangSys + j;
- return &dflt->DefaultLangSys;
+ return &dflt->DefaultLangSys;
}
static int
if (*features == '*')
{
/* Consume all remaining features. */
- for (i = 0; i < LangSys->FeatureCount; i++)
+ for (i = 0; i < LangSys->FeatureCount; i++)
{
int index = LangSys->FeatureIndex[i];
static int
match_ids (OTF_GlyphString *gstring, int gidx, int flag,
- int count, OTF_GlyphID *ids)
+ int count, OTF_GlyphID *ids, int direction)
{
- OTF_Glyph *gbeg = gstring->glyphs + gidx;
- OTF_Glyph *gend = gstring->glyphs + gstring->used;
- OTF_Glyph *g;
- int i;
-
- for (g = gbeg, i = 0; g < gend && i < count; g++)
- if (! IGNORED_GLYPH (g, flag) && g->glyph_id != ids[i++])
- return -1;
- return (i < count ? -1 : g - gbeg);
-}
-
-static int
-match_ids_backward (OTF_GlyphString *gstring, int gidx, int flag,
- int count, OTF_GlyphID *ids)
-{
- OTF_Glyph *gbeg = gstring->glyphs + gidx;
- OTF_Glyph *gend = gstring->glyphs;
- OTF_Glyph *g;
- int i;
+ OTF_Glyph *g = gstring->glyphs + gidx;
+ OTF_Glyph *gend = gstring->glyphs + (direction > 0 ? gstring->used : -1);
+ int i, j;
- for (g = gbeg, i = 0; g >= gend && i < count; g--)
- if (! IGNORED_GLYPH (g, flag) && g->glyph_id != ids[i++])
+ for (i = j = 0; i < count && g != gend; g += direction)
+ if (! IGNORED_GLYPH (g, flag)
+ && g->glyph_id != ids[i++])
return -1;
- return (i < count ? -1 : gbeg - g);
+ return (i < count ? -1 : j);
}
static int
{
int i = rule->BacktrackGlyphCount;
- if (i > 0)
- {
- int j;
- OTF_Glyph *g;
-
- for (j = gidx - 1, g = gstring->glyphs + j; j >= 0; j--, g--)
- if (! IGNORED_GLYPH (g, flag) && --i == 0)
- break;
- if (i > 0)
- return -1;
- if (match_ids_backward (gstring, j, flag,
- rule->BacktrackGlyphCount, rule->Backtrack)
- < 0)
- return -1;
- }
+ if (i > 0
+ && (gidx < i
+ || match_ids (gstring, gidx - 1, flag, i, rule->Backtrack, -1) < 0))
+ return -1;
gidx++;
i = match_ids (gstring, gidx, flag,
- rule->InputGlyphCount - 1, rule->Input);
+ rule->InputGlyphCount - 1, rule->Input, 1);
if (i < 0)
return -1;
gidx += i;
i = match_ids (gstring, gidx, flag,
- rule->LookaheadGlyphCount, rule->LookAhead);
+ rule->LookaheadGlyphCount, rule->LookAhead, 1);
if (i < 0)
return -1;
return 0;
static int
match_classes (OTF_ClassDef *class_def, OTF_GlyphString *gstring, int gidx,
- int flag, int count, unsigned *classes)
+ int flag, int count, unsigned *classes, int direction)
{
- OTF_Glyph *gbeg = gstring->glyphs + gidx;
- OTF_Glyph *gend = gstring->glyphs + gstring->used;
- OTF_Glyph *g;
- int i;
+ OTF_Glyph *g = gstring->glyphs + gidx;
+ OTF_Glyph *gend = gstring->glyphs + (direction > 0 ? gstring->used : -1);
+ int i, j;
- for (g = gbeg, i = 0; g < gend && i < count; g++)
+ for (i = j = 0; i < count && g != gend; g += direction)
if (! IGNORED_GLYPH (g, flag)
&& get_class_def (class_def, g->glyph_id) != classes[i++])
return -1;
- return (i < count ? -1 : g - gbeg);
+ return (i < count ? -1 : j);
}
static int
{
int i = rule->BacktrackGlyphCount;
- if (i > 0)
- {
- int j;
- OTF_Glyph *g;
-
- for (j = gidx - 1, g = gstring->glyphs + j; j >= 0; j--, g--)
- if (! IGNORED_GLYPH (g, flag) && i-- == 0)
- break;
- if (i > 0)
- return -1;
- if (match_classes (BacktrackClassDef, gstring, j, flag,
- rule->BacktrackGlyphCount, rule->Backtrack) < 0);
- return -1;
- }
+ if (i > 0
+ && (gidx < i
+ || match_classes (BacktrackClassDef, gstring, gidx - 1, flag, i,
+ rule->Backtrack, -1) < 0))
+ return -1;
gidx++;
i = match_classes (InputClassDef, gstring, gidx, flag,
- rule->InputGlyphCount - 1, rule->Input);
+ rule->InputGlyphCount - 1, rule->Input, 1);
if (i < 0)
return -1;
gidx += i;
i = match_classes (LookaheadClassDef, gstring, gidx, flag,
- rule->LookaheadGlyphCount, rule->LookAhead);
+ rule->LookaheadGlyphCount, rule->LookAhead, 1);
if (i < 0)
return -1;
return 0;
static int
match_coverages (OTF_GlyphString *gstring, int gidx, int flag, int count,
- OTF_Coverage *coverages)
+ OTF_Coverage *coverages, int direction)
{
- OTF_Glyph *gbeg = gstring->glyphs + gidx;
- OTF_Glyph *gend = gstring->glyphs + gstring->used;
- OTF_Glyph *g;
- int i;
+ OTF_Glyph *g = gstring->glyphs + gidx;
+ OTF_Glyph *gend = gstring->glyphs + (direction > 0 ? gstring->used : - 1);
+ int i, j;
- for (g = gbeg, i = 0; g < gend && i < count; g++)
+ for (i = j = 0; i < count && g != gend; g += direction, j++)
if (! IGNORED_GLYPH (g, flag)
&& get_coverage_index (coverages + i++, g->glyph_id) < 0)
return -1;
- return (i < count ? -1 : g - gbeg);
+ return (i < count ? -1 : j);
}
static int
{
int i = context3->BacktrackGlyphCount;
- if (i > 0)
- {
- int j;
- OTF_Glyph *g;
-
- for (j = gidx - 1, g= gstring->glyphs +j; j >= 0; j--, g--)
- if (! IGNORED_GLYPH (g, flag) && --i == 0)
- break;
- if (i > 0)
- return -1;
- if (match_coverages (gstring, j, flag, context3->BacktrackGlyphCount,
- context3->Backtrack) < 0)
- return -1;
- }
+ if (i > 0
+ && (gidx < i
+ || match_coverages (gstring, gidx - 1, flag, i,
+ context3->Backtrack, -1) < 0))
+ return -1;
gidx++;
if (context3->InputGlyphCount > 1)
{
i = match_coverages (gstring, gidx, flag, context3->InputGlyphCount - 1,
- context3->Input + 1);
+ context3->Input + 1, 1);
if (i < 0)
return -1;
gidx += i;
}
if (match_coverages (gstring, gidx, flag, context3->LookaheadGlyphCount,
- context3->LookAhead) < 0)
+ context3->LookAhead, 1) < 0)
return -1;
return 0;
}
lig = ligset->Ligature + j;
n = match_ids (gstring, gidx + 1, flag,
- lig->CompCount - 1, lig->Component);
+ lig->CompCount - 1, lig->Component, 1);
if (n < 0)
continue;
gstring_subst (otf, gstring, gidx, gidx + 1 + n, flag,
{
rule = set->Rule + j;
if (match_ids (gstring, gidx + 1, flag,
- rule->GlyphCount - 1, rule->Input) < 0)
+ rule->GlyphCount - 1, rule->Input, 1) < 0)
continue;
orig_used = gstring->used;
for (k = 0; k < rule->LookupCount; k++)
rule = set->ClassRule + j;
if (match_classes (&context2->ClassDef,
gstring, gidx + 1, flag,
- rule->GlyphCount - 1, rule->Class)
+ rule->GlyphCount - 1, rule->Class, 1)
< 0)
continue;
orig_used = gstring->used;
if (match_coverages (gstring, gidx + 1, flag,
context3->GlyphCount - 1,
- context3->Coverage + 1) < 0)
+ context3->Coverage + 1, 1) < 0)
continue;
orig_used = gstring->used;
for (j = 0; j < context3->LookupCount; j++)
OTF_ChainRuleSet *set = context1->ChainRuleSet + coverage_idx;
int orig_used;
int j, k;
-
+
for (j = 0; j < set->ChainRuleCount; j++)
{
OTF_ChainRule *rule = set->ChainRule + j;
}
if (accumulate && g->positioning_type)
{
- gidx = gstring_insert_for_gpos (gstring, gidx);
+ gidx = gstring_insert_for_gpos (gstring, gidx);
g = gstring->glyphs + gidx;
}
g->positioning_type = positioning_type;
case 3:
{
OTF_GPOS_Cursive1 *cursive1 = &subtable->u.cursive1;
-
+
g->positioning_type = lookup_type;
g->f.f3.entry_anchor
= &cursive1->EntryExitRecord[coverage_idx].EntryAnchor;
OTF_LigatureAttach *attach;
int *num_class = alloca (sizeof (int) * mark_lig1->ClassCount);
int j;
-
+
for (j = 0; j < mark_lig1->ClassCount; j++)
num_class[j] = 0;
{
rule = set->Rule + j;
if (match_ids (gstring, gidx + 1, flag,
- rule->GlyphCount - 1, rule->Input) < 0)
+ rule->GlyphCount - 1, rule->Input, 1) < 0)
continue;
orig_used = gstring->used;
for (k = 0; k < rule->LookupCount; k++)
rule = set->ClassRule + j;
if (match_classes (&context2->ClassDef,
gstring, gidx + 1, flag,
- rule->GlyphCount - 1, rule->Class)
+ rule->GlyphCount - 1, rule->Class, 1)
< 0)
continue;
orig_used = gstring->used;
if (match_coverages (gstring, gidx + 1, flag,
context3->GlyphCount - 1,
- context3->Coverage + 1) < 0)
+ context3->Coverage + 1, 1) < 0)
continue;
orig_used = gstring->used;
for (j = 0; j < context3->LookupCount; j++)
OTF_ChainRuleSet *set = context1->ChainRuleSet + coverage_idx;
int orig_used;
int j, k;
-
+
for (j = 0; j < set->ChainRuleCount; j++)
{
OTF_ChainRule *rule = set->ChainRule + j;
static void
check_cmap_uvs (OTF_cmap *cmap, OTF_GlyphString *gstring, int idx)
-{
+{
OTF_EncodingSubtable14 *sub14;
int c1 = gstring->glyphs[idx - 1].c;
int c2 = gstring->glyphs[idx].c;
}
static int
-iterate_coverage (OTF *otf, const char *feature,
+iterate_coverage (OTF *otf, const char *feature,
OTF_Feature_Callback callback,
OTF_Coverage *coverage)
{