Commit a42f918434ec132737b2107a2d7356d02d4919bc

Werner Lemberg 2014-01-03T18:29:41

[autofit] Fix handling of default coverages. * src/autofit/afglobal.c (af_face_globals_compute_style_coverage): First handle non-default coverages, then the default coverage of the default script, and finally the other default coverages.

diff --git a/ChangeLog b/ChangeLog
index b5352e6..0dcd4a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2014-01-03  Werner Lemberg  <wl@gnu.org>
 
+	[autofit] Fix handling of default coverages.
+
+	* src/autofit/afglobal.c (af_face_globals_compute_style_coverage):
+	First handle non-default coverages, then the default coverage of the
+	default script, and finally the other default coverages.
+
+2014-01-03  Werner Lemberg  <wl@gnu.org>
+
 	[autofit] Fix scaling of HarfBuzz shaping.
 
 	* src/autofit/hbshim.c (af_get_char_index): Scale to units per EM.
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index d92c6ad..7682c14 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -127,6 +127,7 @@
     FT_Byte*    gstyles     = globals->glyph_styles;
     FT_UInt     ss;
     FT_UInt     i;
+    FT_UInt     dflt        = -1;
 
 
     /* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */
@@ -164,6 +165,9 @@
        */
       if ( style_class->coverage == AF_COVERAGE_DEFAULT )
       {
+        if ( style_class->script == globals->module->default_script )
+          dflt = ss;
+
         for ( range = script_class->script_uni_ranges;
               range->first != 0;
               range++ )
@@ -192,9 +196,24 @@
           }
         }
       }
+      else
+      {
+        /* get glyphs not directly addressable by cmap */
+        af_get_coverage( globals, style_class, gstyles );
+      }
+    }
+
+    /* handle the default OpenType features of the default script ... */
+    af_get_coverage( globals, AF_STYLE_CLASSES_GET[dflt], gstyles );
+
+    /* ... and the remaining default OpenType features */
+    for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
+    {
+      AF_StyleClass  style_class = AF_STYLE_CLASSES_GET[ss];
+
 
-      /* get glyphs not directly addressable by cmap */
-      af_get_coverage( globals, style_class, gstyles );
+      if ( ss != dflt && style_class->coverage == AF_COVERAGE_DEFAULT )
+        af_get_coverage( globals, style_class, gstyles );
     }
 
     /* mark ASCII digits */