X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fotfdrive.c;h=97e197471cad0a41e7bf9e2dbc19b43f9f08dcd1;hb=899309820a57de1a178b8001eb799782ecb80cfc;hp=44432210a061ca2d3a52e8c42abd4140a28ca41b;hpb=1f63f1255af90702b9ea7838cc8b7af8f2644bcd;p=m17n%2Flibotf.git diff --git a/src/otfdrive.c b/src/otfdrive.c index 4443221..97e1974 100644 --- a/src/otfdrive.c +++ b/src/otfdrive.c @@ -1,6 +1,6 @@ /* 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 @@ -112,11 +112,14 @@ gstring_subst (OTF *otf, OTF_GlyphString *gstring, int from, int to, int flag, 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 = 1; @@ -437,7 +440,8 @@ lookup_gsub (OTF *otf, OTF_LookupList *lookup_list, unsigned lookup_list_index, } 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; @@ -456,6 +460,14 @@ lookup_gsub (OTF *otf, OTF_LookupList *lookup_list, unsigned lookup_list_index, 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; @@ -480,8 +492,12 @@ lookup_gsub (OTF *otf, OTF_LookupList *lookup_list, unsigned lookup_list_index, 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 @@ -536,7 +552,7 @@ lookup_gsub (OTF *otf, OTF_LookupList *lookup_list, unsigned lookup_list_index, 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; } @@ -567,7 +583,7 @@ lookup_gsub (OTF *otf, OTF_LookupList *lookup_list, unsigned lookup_list_index, 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; } @@ -588,7 +604,7 @@ lookup_gsub (OTF *otf, OTF_LookupList *lookup_list, unsigned lookup_list_index, 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; @@ -617,7 +633,7 @@ lookup_gsub (OTF *otf, OTF_LookupList *lookup_list, unsigned lookup_list_index, 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; } @@ -653,7 +669,7 @@ lookup_gsub (OTF *otf, OTF_LookupList *lookup_list, unsigned lookup_list_index, 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; } @@ -676,7 +692,7 @@ lookup_gsub (OTF *otf, OTF_LookupList *lookup_list, unsigned lookup_list_index, 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; @@ -1692,19 +1708,17 @@ OTF_get_variation_glyphs (OTF *otf, int c, OTF_GlyphID code[256]) 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, @@ -1763,7 +1777,6 @@ OTF_drive_gsub_internal (OTF *otf, OTF_GlyphString *gstring, for (i = 0; i < gsub->LookupList.LookupCount; i++) { int gidx; - int j; if (! lookup_flags[i]) continue; @@ -1777,12 +1790,10 @@ OTF_drive_gsub_internal (OTF *otf, OTF_GlyphString *gstring, if (result < 0) return errret; if (gidx < result) - { - for (j = gidx; j < result; j++) - gstring->glyphs[j].positioning_type - = with_log ? (lookup_flags[i] << 4) : 0; - 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++; } @@ -1797,12 +1808,10 @@ OTF_drive_gsub_internal (OTF *otf, OTF_GlyphString *gstring, if (result < 0) return errret; if (gidx > result) - { - for (j = gidx; j > result; j--) - gstring->glyphs[j].positioning_type - = with_log ? (lookup_flags[i] << 4) : 0; - 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--; } @@ -1869,7 +1878,6 @@ OTF_drive_gpos_internal (OTF *otf, OTF_GlyphString *gstring, for (i = 0; i < gpos->LookupList.LookupCount; i++) { int gidx = 0; - int j; if (! lookup_flags[i]) continue; @@ -1880,18 +1888,15 @@ OTF_drive_gpos_internal (OTF *otf, OTF_GlyphString *gstring, if (result < 0) return errret; if (gidx < result) - { - for (j = gidx; j < result; j++) - { - int positioning_type - = gstring->glyphs[j].positioning_type & 0xF; + for (; gidx < result; gidx++) + { + int positioning_type + = gstring->glyphs[gidx].positioning_type & 0xF; - if (with_log && positioning_type) - gstring->glyphs[j].positioning_type - = positioning_type | (lookup_flags[i] << 4); - } - gidx = result; - } + if (with_log && positioning_type) + gstring->glyphs[gidx].positioning_type + = positioning_type | (lookup_flags[i] << 4); + } else gidx++; }