shithub: freetype+ttf2subf

Download patch

ref: ecdb0e35c323ece12a0882444891cfa80552af74
parent: 1b5bc897540e7dc3c6414dcbadd565c85271c707
author: Werner Lemberg <[email protected]>
date: Fri Jan 3 15:49:31 EST 2014

[autofit] Thinko.

* src/autofit/hbshim.c (af_get_char_index): Similar to
`af_get_coverage', reject glyphs which are not substituted.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2014-01-03  Werner Lemberg  <[email protected]>
 
+	[autofit] Thinko.
+
+	* src/autofit/hbshim.c (af_get_char_index): Similar to
+	`af_get_coverage', reject glyphs which are not substituted.
+
+2014-01-03  Werner Lemberg  <[email protected]>
+
 	[autofit] Fix handling of default coverages.
 
 	With this commit, the implementation of coverage handling is
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -89,6 +89,9 @@
                                        [style_class->script];
 
 
+      /* XXX: Extend this with a list of possible standard characters: */
+      /*      Especially in non-default coverages, a singe standard    */
+      /*      character may not be available.                          */
       af_get_char_index( &metrics->root,
                          script_class->standard_char,
                          &glyph_index,
--- a/src/autofit/hbshim.c
+++ b/src/autofit/hbshim.c
@@ -410,10 +410,14 @@
 
     const hb_feature_t*  feature;
 
+    FT_ULong  in_idx, out_idx;
 
+
     if ( !metrics )
       return FT_THROW( Invalid_Argument );
 
+    in_idx = FT_Get_Char_Index( metrics->globals->face, charcode );
+
     style_class = metrics->style_class;
 
     feature = features[style_class->coverage];
@@ -448,9 +452,21 @@
       ginfo = hb_buffer_get_glyph_infos( buf, &gcount );
       gpos  = hb_buffer_get_glyph_positions( buf, &gcount );
 
-      *codepoint = ginfo[0].codepoint;
-      *y_offset  = gpos[0].y_offset;
+      out_idx = ginfo[0].codepoint;
 
+      /* getting the same index indicates no substitution,         */
+      /* which means that the glyph isn't available in the feature */
+      if ( in_idx == out_idx )
+      {
+        *codepoint = 0;
+        *y_offset  = 0;
+      }
+      else
+      {
+        *codepoint = out_idx;
+        *y_offset  = gpos[0].y_offset;
+      }
+
       hb_buffer_destroy( buf );
 
 #ifdef FT_DEBUG_LEVEL_TRACE
@@ -461,7 +477,7 @@
     }
     else
     {
-      *codepoint = FT_Get_Char_Index( metrics->globals->face, charcode );
+      *codepoint = in_idx;
       *y_offset  = 0;
     }