[autofit] Fix handling of default coverages. With this commit, the implementation of coverage handling is completed. * src/autofit/hbshim.c (af_get_coverage): Exit early if nothing to do. Reject coverages which don't contain appropriate glyphs for blue zones.
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
diff --git a/ChangeLog b/ChangeLog
index 0dcd4a7..148e8d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,18 @@
[autofit] Fix handling of default coverages.
+ With this commit, the implementation of coverage handling is
+ completed.
+
+ * src/autofit/hbshim.c (af_get_coverage): Exit early if nothing to
+ do.
+ Reject coverages which don't contain appropriate glyphs for blue
+ zones.
+
+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.
diff --git a/src/autofit/hbshim.c b/src/autofit/hbshim.c
index b352545..844c6bb 100644
--- a/src/autofit/hbshim.c
+++ b/src/autofit/hbshim.c
@@ -166,6 +166,10 @@
NULL,
coverage_tags,
gsub_lookups );
+
+ if ( hb_set_is_empty( gsub_lookups ) )
+ return FT_Err_Ok; /* nothing to do */
+
hb_ot_layout_collect_lookups( face,
HB_OT_TAG_GPOS,
script_tags,
@@ -236,6 +240,53 @@
#endif
/*
+ * We now check whether we can construct blue zones, using glyphs
+ * covered by the feature only. In case there is not a single zone
+ * (this is, not a single character is covered), we skip this coverage.
+ *
+ */
+ {
+ AF_Blue_Stringset bss = style_class->blue_stringset;
+ const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
+
+ FT_Bool found = 0;
+
+
+ for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
+ {
+ const char* p = &af_blue_strings[bs->string];
+
+
+ while ( *p )
+ {
+ hb_codepoint_t ch;
+
+
+ GET_UTF8_CHAR( ch, p );
+
+ for ( idx = -1; hb_set_next( gsub_lookups, &idx ); )
+ {
+ hb_codepoint_t gidx = FT_Get_Char_Index( globals->face, ch );
+
+
+ if ( hb_ot_layout_lookup_would_substitute( face, idx,
+ &gidx, 1, 1 ) )
+ {
+ found = 1;
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !found )
+ {
+ FT_TRACE4(( " no blue characters found; style skipped\n" ));
+ return FT_Err_Ok;
+ }
+ }
+
+ /*
* Various OpenType features might use the same glyphs at different
* vertical positions; for example, superscript and subscript glyphs
* could be the same. However, FreeType's auto-hinting is completely