If applying a ligature lookup makes adjacent two glyphs that were not
authorOwen Taylor <otaylor@redhat.com>
Sat, 26 Jul 2003 13:50:23 +0000 (13:50 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sat, 26 Jul 2003 13:50:23 +0000 (13:50 +0000)
Sat Jul 26 09:41:22 2003  Owen Taylor  <otaylor@redhat.com>

        * pango/opentype/ftxgsub.c (Lookup_LigatureSubst):
        If applying a ligature lookup makes adjacent two glyphs
        that were not originally adjacent, avoid making
        subsequent ligatures between those glyphs.
        (From FreeType, Werner Lemberg, 2001-08-22, 2001-08-23)

src/ftxgsub.c

index f56ae6f..5ab9558 100644 (file)
     FT_UShort      index, property;
     FT_Error       error;
     FT_UShort      numlig, i, j, is_mark, first_is_mark = FALSE;
-    FT_UShort*     s_in;
+    FT_UShort      first_ligID, first_comp;
+    FT_UShort      *s_in, *lig_in, *comp_in;
     FT_UShort*     c;
 
     TTO_Ligature*  lig;
       if ( in->pos + lig->ComponentCount > in->length )
         continue;                         /* Not enough glyphs in input */
 
-      s_in = &in->string[in->pos];
-      c    = lig->Component;
+      s_in        = &in->string[in->pos];
+      lig_in      = &in->ligIDs[in->pos];
+      comp_in     = &in->components[in->pos];
+      first_ligID = *lig_in;
+      first_comp  = *comp_in;
+      c           = lig->Component;
 
       is_mark = first_is_mark;
 
             break;
         }
 
+        /* don't apply a ligature lookup to glyphs with different
+           ligature IDs.  Example:
+
+                                                       '
+                                  ^'              '    ^
+             f ^ l ' -> fl ^ ' -> fl  but not  fl ^ -> fl         */
+
+        if ( first_ligID != lig_in[j] )
+          break;
+
+        /* don't apply a ligature lookup to glyphs with different
+           component values.  Example:
+
+                                                            '
+                                     ^'                '    ^
+             f ^ f ' l -> ffl ^ ' -> ffl  but not  ffl ^ -> ffl   */
+
+        if ( first_comp != comp_in[j] )
+          break;
+
         if ( !( property == TTO_MARK || property & IGNORE_SPECIAL_MARKS ) )
           is_mark = FALSE;