/* otfdrive.c -- OpenType font driver.
-Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
National Institute of Advanced Industrial Science and Technology (AIST)
Registration Number H15PRO167
if (gstring->glyphs[from + i].glyph_id != ids[i])
{
gstring->glyphs[from + i].c = 0;
- if (otf->gdef)
+ if (otf->gdef && otf->gdef->glyph_class_def.offset)
gstring->glyphs[from + i].GlyphClass
= get_class_def (&otf->gdef->glyph_class_def, ids[i]);
else
gstring->glyphs[from + i].GlyphClass = 0;
+ if (otf->gdef && otf->gdef->mark_attach_class_def.offset)
+ gstring->glyphs[from + i].MarkAttachClass
+ = get_class_def (&otf->gdef->mark_attach_class_def, ids[i]);
}
gstring->glyphs[from + i].glyph_id = ids[i];
- gstring->glyphs[from + i].positioning_type = 0;
+ gstring->glyphs[from + i].positioning_type = 1;
gstring->glyphs[from + i].f.index.from = from_idx;
gstring->glyphs[from + i].f.index.to = to_idx;
}
{
feature = FeatureList->Feature + index;
for (j = 0; j < feature->LookupCount; j++)
- lookup_flags[feature->LookupListIndex[j]] = i + 1;
+ lookup_flags[feature->LookupListIndex[j]] = index + 1;
}
}
break;
tag = OTF_tag (tagname);
for (i = 0; i < LangSys->FeatureCount; i++)
{
- feature = FeatureList->Feature + LangSys->FeatureIndex[i];
+ int index = LangSys->FeatureIndex[i];
+
+ feature = FeatureList->Feature + index;
if (tag == feature->FeatureTag)
{
if (feature_table[i])
break;
if (use_it > 0)
for (j = 0; j < feature->LookupCount; j++)
- lookup_flags[feature->LookupListIndex[j]] = j + 1;
+ lookup_flags[feature->LookupListIndex[j]] = index + 1;
feature_table[i] = use_it;
break;
}
}
if (alternate_subst
- ? (lookup_type != 3 && lookup_type != 5 && lookup_type != 6)
+ ? (alternate_subst == 1
+ && lookup_type != 3 && lookup_type != 5 && lookup_type != 6)
: (lookup_type == 3))
continue;
g->glyph_id += subtable->u.single1.DeltaGlyphID;
else
g->glyph_id = subtable->u.single2.Substitute[coverage_idx];
+ if (otf->gdef && otf->gdef->glyph_class_def.offset)
+ g->GlyphClass
+ = get_class_def (&otf->gdef->glyph_class_def, g->glyph_id);
+ else
+ g->GlyphClass = 0;
+ if (otf->gdef && otf->gdef->mark_attach_class_def.offset)
+ g->MarkAttachClass
+ = get_class_def (&otf->gdef->mark_attach_class_def, g->glyph_id);
+ g->positioning_type = 1;
gidx++;
break;
OTF_GSUB_Alternate1 *alt1 = &subtable->u.alternate1;
OTF_AlternateSet *altset = alt1->AlternateSet + coverage_idx;
- gstring_subst (otf, gstring, gidx, gidx + 1, flag,
- altset->Alternate, altset->GlyphCount);
+ if (alternate_subst == 1)
+ gstring_subst (otf, gstring, gidx, gidx + 1, flag,
+ altset->Alternate, altset->GlyphCount);
+ else
+ gstring_subst (otf, gstring, gidx, gidx + 1, flag,
+ altset->Alternate, 1);
gidx += altset->GlyphCount;;
}
else
rule->LookupRecord[k].LookupListIndex,
gstring,
gidx + rule->LookupRecord[k].SequenceIndex,
- alternate_subst);
+ alternate_subst ? alternate_subst : 2);
gidx += rule->GlyphCount + (gstring->used - orig_used);
break;
}
rule->LookupRecord[k].LookupListIndex,
gstring,
gidx + rule->LookupRecord[k].SequenceIndex,
- alternate_subst);
+ alternate_subst ? alternate_subst : 2);
gidx += rule->GlyphCount + (gstring->used - orig_used);
break;
}
context3->LookupRecord[j].LookupListIndex,
gstring,
gidx + context3->LookupRecord[j].SequenceIndex,
- alternate_subst);
+ alternate_subst ? alternate_subst : 2);
gidx += context3->GlyphCount + (gstring->used - orig_used);
}
break;
rule->LookupRecord[k].LookupListIndex,
gstring,
gidx + rule->LookupRecord[k].SequenceIndex,
- alternate_subst);
+ alternate_subst ? alternate_subst : 2);
gidx += rule->InputGlyphCount + (gstring->used - orig_used);
break;
}
rule->LookupRecord[k].LookupListIndex,
gstring,
gidx + rule->LookupRecord[k].SequenceIndex,
- alternate_subst);
+ alternate_subst ? alternate_subst : 2);
gidx += rule->InputGlyphCount + (gstring->used - orig_used);
break;
}
context3->LookupRecord[j].LookupListIndex,
gstring,
gidx + context3->LookupRecord[j].SequenceIndex,
- alternate_subst);
+ alternate_subst ? alternate_subst : 2);
gidx += context3->InputGlyphCount + (gstring->used - orig_used);
}
break;
if (j < reverse->LookaheadGlyphCount)
continue;
g->glyph_id = reverse->Substitute[coverage_idx];
+ g->positioning_type = 1;
gidx--;
}
switch (lookup_type)
{
case 1:
- positioning_type = lookup_type;
if (subtable->Format == 1)
{
OTF_GPOS_Single1 *single1 = &subtable->u.single1;
format = single2->ValueFormat;
value = single2->Value + coverage_idx;
}
- if (accumulate && g->positioning_type)
+ if (accumulate && (g->positioning_type & 0xF))
{
gidx = gstring_insert_for_gpos (gstring, gidx);
g = gstring->glyphs + gidx;
}
g->positioning_type
- = (g->positioning_type & 0xFFFFFFF0) | positioning_type;
+ = (g->positioning_type & 0xFFFFFFF0) | lookup_type;
g->f.f1.format = format;
g->f.f1.value = value;
if (debug_flag)
OTF_GPOS_Cursive1 *cursive1 = &subtable->u.cursive1;
g->positioning_type
- = (g->positioning_type & 0xFFFFFFF0) | lookup_type;
+ = (g->positioning_type & 0xFFFFFFF0) | lookup_type;
g->f.f3.entry_anchor
= &cursive1->EntryExitRecord[coverage_idx].EntryAnchor;
g->f.f3.exit_anchor
return n;
}
-
int
OTF_drive_gdef (OTF *otf, OTF_GlyphString *gstring)
{
OTF_GDEF *gdef;
int i;
- if (! otf->gdef
- && OTF_get_table (otf, "GDEF") < 0)
- return -1;
+ if (! otf->gdef)
+ OTF_get_table (otf, "GDEF");
gdef = otf->gdef;
- if (gdef->glyph_class_def.offset)
+ if (gdef && gdef->glyph_class_def.offset)
for (i = 0; i < gstring->used; i++)
gstring->glyphs[i].GlyphClass
= get_class_def (&gdef->glyph_class_def,
for (i = 0; i < gsub->LookupList.LookupCount; i++)
{
int gidx;
- int j;
if (! lookup_flags[i]) continue;
if (result < 0)
return errret;
if (gidx < result)
- {
- if (with_log)
- for (j = gidx; j < result; j++)
- gstring->glyphs[j].positioning_type
- = ((gstring->glyphs[j].positioning_type & 0xF)
- | (lookup_flags[i] << 4));
- gidx = result;
- }
+ for (; gidx < result; gidx++)
+ gstring->glyphs[gidx].positioning_type
+ = ((with_log && gstring->glyphs[gidx].positioning_type)
+ ? (lookup_flags[i] << 4) : 0);
else
gidx++;
}
if (result < 0)
return errret;
if (gidx > result)
- {
- if (with_log)
- for (j = gidx; j > result; j--)
- gstring->glyphs[j].positioning_type
- = ((gstring->glyphs[j].positioning_type & 0xF)
- | (lookup_flags[i] << 4));
- gidx = result;
- }
+ for (; gidx > result; gidx--)
+ gstring->glyphs[gidx].positioning_type
+ = ((with_log && gstring->glyphs[gidx].positioning_type)
+ ? (lookup_flags[i] << 4) : 0);
else
gidx--;
}
for (i = 0; i < gpos->LookupList.LookupCount; i++)
{
int gidx = 0;
- int j;
if (! lookup_flags[i]) continue;
if (result < 0)
return errret;
if (gidx < result)
- {
- if (with_log)
- for (j = gidx; j < result; j++)
- gstring->glyphs[j].positioning_type
- = ((gstring->glyphs[j].positioning_type & 0xF)
- | (lookup_flags[i] << 4));
- gidx = result;
- }
+ for (; gidx < result; gidx++)
+ {
+ int positioning_type
+ = gstring->glyphs[gidx].positioning_type & 0xF;
+
+ if (with_log && positioning_type)
+ gstring->glyphs[gidx].positioning_type
+ = positioning_type | (lookup_flags[i] << 4);
+ }
else
gidx++;
}