[autofit] Restore OpenType feature check. This was removed while rewriting the HarfBuzz interface. * src/autofit/afglobal.h (AF_FaceGlobalsRec): Add `hb_buf' field to hold internal HarfBuzz buffer, needed for feature comparison. * src/autofit/afglobal.c (af_face_globals_new, af_face_globals_free): Initialize and destroy `hb_buf'. * src/autofit/afshaper.c (af_shaper_get_cluster): Compare character (cluster) with and without applied feature. * src/autofit/aflatin.c (af_latin_metrics_init_blues): Fix tracing message.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
diff --git a/ChangeLog b/ChangeLog
index 5cda52d..3ab437a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2015-12-10 Werner Lemberg <wl@gnu.org>
+ [autofit] Restore OpenType feature check.
+
+ This was removed while rewriting the HarfBuzz interface.
+
+ * src/autofit/afglobal.h (AF_FaceGlobalsRec): Add `hb_buf' field to
+ hold internal HarfBuzz buffer, needed for feature comparison.
+
+ * src/autofit/afglobal.c (af_face_globals_new,
+ af_face_globals_free): Initialize and destroy `hb_buf'.
+
+ * src/autofit/afshaper.c (af_shaper_get_cluster): Compare character
+ (cluster) with and without applied feature.
+
+ * src/autofit/aflatin.c (af_latin_metrics_init_blues): Fix tracing
+ message.
+
+2015-12-10 Werner Lemberg <wl@gnu.org>
+
[autofit] Remove redundant code.
* src/autofit/aflatin.c (af_latin_metrics_init_widths): Do it.
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 207b41c..3223358 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -364,6 +364,7 @@
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
globals->hb_font = hb_ft_font_create( face, NULL );
+ globals->hb_buf = hb_buffer_create();
#endif
error = af_face_globals_compute_style_coverage( globals );
@@ -410,6 +411,9 @@
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
hb_font_destroy( globals->hb_font );
globals->hb_font = NULL;
+
+ hb_buffer_destroy( globals->hb_buf );
+ globals->hb_buf = NULL;
#endif
globals->glyph_count = 0;
diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h
index c1170d4..5b4e439 100644
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -110,6 +110,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
hb_font_t* hb_font;
+ hb_buffer_t* hb_buf; /* for feature comparison */
#endif
/* per-face auto-hinter properties */
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 3358c99..fa285f7 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -396,6 +396,12 @@
p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
+ if ( !num_idx )
+ {
+ FT_TRACE5(( " U+%04lX unavailable\n", ch ));
+ continue;
+ }
+
if ( AF_LATIN_IS_TOP_BLUE( bs ) )
best_y_extremum = FT_INT_MIN;
else
diff --git a/src/autofit/afshaper.c b/src/autofit/afshaper.c
index e72fe49..6ba9190 100644
--- a/src/autofit/afshaper.c
+++ b/src/autofit/afshaper.c
@@ -466,7 +466,7 @@
while ( *p == ' ' )
p++;
- /* count characters up to next space (or end of buffer) */
+ /* count bytes up to next space (or end of buffer) */
q = p;
while ( !( *q == ' ' || *q == '\0' ) )
GET_UTF8_CHAR( dummy, q );
@@ -483,6 +483,46 @@
/* glyph indices, possibly applying a feature */
hb_shape( font, buf, feature, feature ? 1 : 0 );
+ if ( feature )
+ {
+ hb_buffer_t* hb_buf = metrics->globals->hb_buf;
+
+ unsigned int gcount;
+ hb_glyph_info_t* ginfo;
+
+ unsigned int hb_gcount;
+ hb_glyph_info_t* hb_ginfo;
+
+
+ /* we have to check whether applying a feature does actually change */
+ /* glyph indices; otherwise the affected glyph or glyphs aren't */
+ /* available at all in the feature */
+
+ hb_buffer_clear_contents( hb_buf );
+ hb_buffer_add_utf8( hb_buf, p, len, 0, len );
+ hb_buffer_guess_segment_properties( hb_buf );
+ hb_shape( font, hb_buf, NULL, 0 );
+
+ ginfo = hb_buffer_get_glyph_infos( buf, &gcount );
+ hb_ginfo = hb_buffer_get_glyph_infos( hb_buf, &hb_gcount );
+
+ if ( gcount == hb_gcount )
+ {
+ unsigned int i;
+
+
+ for (i = 0; i < gcount; i++ )
+ if ( ginfo[i].codepoint != hb_ginfo[i].codepoint )
+ break;
+
+ if ( i == gcount )
+ {
+ /* both buffers have identical glyph indices */
+ hb_buffer_clear_contents( buf );
+ }
+ }
+ }
+
*count = hb_buffer_get_length( buf );
#ifdef FT_DEBUG_LEVEL_TRACE