From: handa Date: Tue, 9 Nov 2004 01:14:15 +0000 (+0000) Subject: (lookup_gsub): New arg alternate_subst. Callers X-Git-Tag: REL-0-9-5~90 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=55ccc28173ebb005058fd1a01416a030179ca67d;p=m17n%2Flibotf.git (lookup_gsub): New arg alternate_subst. Callers changed. (OTF_drive_gsub_internal): Renamed from OTF_drive_gsub. (OTF_drive_gsub): Just call OTF_drive_gsub_internal. (OTF_drive_gsub_alternate): New function. --- diff --git a/src/otfdrive.c b/src/otfdrive.c index a962bae..9a528a8 100644 --- a/src/otfdrive.c +++ b/src/otfdrive.c @@ -400,7 +400,7 @@ match_chain_coverages (OTF_GlyphString *gstring, int gidx, int flag, static int lookup_gsub (OTF_LookupList *lookup_list, unsigned lookup_list_index, - OTF_GlyphString *gstring, int gidx) + OTF_GlyphString *gstring, int gidx, int alternate_subst) { char *errfmt = "GSUB Looking up%s"; int errret = -1; @@ -429,6 +429,11 @@ lookup_gsub (OTF_LookupList *lookup_list, unsigned lookup_list_index, subtable = extension1->ExtensionSubtable; } + if (alternate_subst + ? (lookup_type != 3 && lookup_type != 5 && lookup_type != 6) + : (lookup_type == 3)) + continue; + if (subtable->Coverage.offset) { coverage_idx = get_coverage_index (&subtable->Coverage, @@ -448,23 +453,28 @@ lookup_gsub (OTF_LookupList *lookup_list, unsigned lookup_list_index, break; case 2: - { - OTF_GSUB_Multiple1 *multiple1 = &subtable->u.multiple1; - OTF_Sequence *seq = multiple1->Sequence + coverage_idx; + if (subtable->Format == 1) + { + OTF_GSUB_Multiple1 *multiple1 = &subtable->u.multiple1; + OTF_Sequence *seq = multiple1->Sequence + coverage_idx; - gstring_subst (gstring, gidx, gidx + 1, flag, - seq->Substitute, seq->GlyphCount); - gidx += seq->GlyphCount; - } + gstring_subst (gstring, gidx, gidx + 1, flag, + seq->Substitute, seq->GlyphCount); + gidx += seq->GlyphCount; + } + else + OTF_ERROR (OTF_ERROR_GSUB_DRIVE, " (invalid SubFormat)"); break; case 3: if (subtable->Format == 1) { OTF_GSUB_Alternate1 *alt1 = &subtable->u.alternate1; + OTF_AlternateSet *altset = alt1->AlternateSet + coverage_idx; - g->alternate_set = alt1->AlternateSet + coverage_idx; - gidx++; + gstring_subst (gstring, gidx + 1, gidx + 1, flag, + altset->Alternate, altset->GlyphCount); + gidx += altset->GlyphCount;; } else OTF_ERROR (OTF_ERROR_GSUB_DRIVE, " (invalid SubFormat)"); @@ -517,7 +527,8 @@ lookup_gsub (OTF_LookupList *lookup_list, unsigned lookup_list_index, lookup_gsub (lookup_list, rule->LookupRecord[k].LookupListIndex, gstring, - gidx + rule->LookupRecord[k].SequenceIndex); + gidx + rule->LookupRecord[k].SequenceIndex, + alternate_subst); gidx += rule->GlyphCount + (gstring->used - orig_used); break; } @@ -547,7 +558,8 @@ lookup_gsub (OTF_LookupList *lookup_list, unsigned lookup_list_index, lookup_gsub (lookup_list, rule->LookupRecord[k].LookupListIndex, gstring, - gidx + rule->LookupRecord[k].SequenceIndex); + gidx + rule->LookupRecord[k].SequenceIndex, + alternate_subst); gidx += rule->GlyphCount + (gstring->used - orig_used); break; } @@ -567,7 +579,8 @@ lookup_gsub (OTF_LookupList *lookup_list, unsigned lookup_list_index, lookup_gsub (lookup_list, context3->LookupRecord[j].LookupListIndex, gstring, - gidx + context3->LookupRecord[j].SequenceIndex); + gidx + context3->LookupRecord[j].SequenceIndex, + alternate_subst); gidx += context3->GlyphCount + (gstring->used - orig_used); } break; @@ -595,7 +608,8 @@ lookup_gsub (OTF_LookupList *lookup_list, unsigned lookup_list_index, lookup_gsub (lookup_list, rule->LookupRecord[k].LookupListIndex, gstring, - gidx + rule->LookupRecord[k].SequenceIndex); + gidx + rule->LookupRecord[k].SequenceIndex, + alternate_subst); gidx += rule->InputGlyphCount + (gstring->used - orig_used); break; } @@ -630,7 +644,8 @@ lookup_gsub (OTF_LookupList *lookup_list, unsigned lookup_list_index, lookup_gsub (lookup_list, rule->LookupRecord[k].LookupListIndex, gstring, - gidx + rule->LookupRecord[k].SequenceIndex); + gidx + rule->LookupRecord[k].SequenceIndex, + alternate_subst); gidx += rule->InputGlyphCount + (gstring->used - orig_used); break; } @@ -652,7 +667,8 @@ lookup_gsub (OTF_LookupList *lookup_list, unsigned lookup_list_index, lookup_gsub (lookup_list, context3->LookupRecord[j].LookupListIndex, gstring, - gidx + context3->LookupRecord[j].SequenceIndex); + gidx + context3->LookupRecord[j].SequenceIndex, + alternate_subst); gidx += context3->InputGlyphCount + (gstring->used - orig_used); } break; @@ -1320,10 +1336,10 @@ OTF_drive_gdef (OTF *otf, OTF_GlyphString *gstring) return 0; } - -int -OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring, - char *script, char *language, char *features) +static int +OTF_drive_gsub_internal (OTF *otf, OTF_GlyphString *gstring, + char *script, char *language, char *features, + int alternate_subst) { char *errfmt = "GSUB driving%s"; int errret = -1; @@ -1368,7 +1384,8 @@ OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring, gidx = 0; while (gidx < gstring->used) { - gidx = lookup_gsub (&gsub->LookupList, index, gstring, gidx); + gidx = lookup_gsub (&gsub->LookupList, index, gstring, gidx, + alternate_subst); if (gidx < 0) return errret; } @@ -1378,7 +1395,8 @@ OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring, gidx = gstring->used - 1; while (gidx >= 0) { - gidx = lookup_gsub (&gsub->LookupList, index, gstring, gidx); + gidx = lookup_gsub (&gsub->LookupList, index, gstring, gidx, + alternate_subst); if (gidx < 0) return errret; } @@ -1389,6 +1407,13 @@ OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring, } int +OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring, + char *script, char *language, char *features) +{ + return OTF_drive_gsub_internal (otf, gstring, script, language, features, 0); +} + +int OTF_drive_gpos (OTF *otf, OTF_GlyphString *gstring, char *script, char *language, char *features) { @@ -1458,3 +1483,10 @@ OTF_drive_tables (OTF *otf, OTF_GlyphString *gstring, return -1; return 0; } + +int +OTF_drive_gsub_alternate (OTF *otf, OTF_GlyphString *gstring, + char *script, char *language, char *features) +{ + return OTF_drive_gsub_internal (otf, gstring, script, language, features, 1); +}