Merge pull request #2038 from ebraminio/glyf-contour

Remove contour_point_t so we won't need to zero its unused var
diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index e664615..9ebd8e4 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -342,14 +342,22 @@
 	count--; /* Skip sentinel segment. */
       for (unsigned int i = 0; i < count; i++)
       {
+	hb_codepoint_t start = this->startCount[i];
+	hb_codepoint_t end = this->endCount[i];
 	unsigned int rangeOffset = this->idRangeOffset[i];
 	if (rangeOffset == 0)
-	  out->add_range (this->startCount[i], this->endCount[i]);
+	{
+	  for (hb_codepoint_t codepoint = start; codepoint <= end; codepoint++)
+	  {
+	    hb_codepoint_t gid = (codepoint + this->idDelta[i]) & 0xFFFFu;
+	    if (unlikely (!gid))
+	      continue;
+	    out->add (codepoint);
+	  }
+	}
 	else
 	{
-	  for (hb_codepoint_t codepoint = this->startCount[i];
-	       codepoint <= this->endCount[i];
-	       codepoint++)
+	  for (hb_codepoint_t codepoint = start; codepoint <= end; codepoint++)
 	  {
 	    unsigned int index = rangeOffset / 2 + (codepoint - this->startCount[i]) + i - this->segCount;
 	    if (unlikely (index >= this->glyphIdArrayLength))
@@ -522,10 +530,18 @@
 
   void collect_unicodes (hb_set_t *out) const
   {
-    for (unsigned int i = 0; i < this->groups.len; i++) {
-      out->add_range (this->groups[i].startCharCode,
-		      hb_min ((hb_codepoint_t) this->groups[i].endCharCode,
-			   (hb_codepoint_t) HB_UNICODE_MAX));
+    for (unsigned int i = 0; i < this->groups.len; i++)
+    {
+      hb_codepoint_t start = this->groups[i].startCharCode;
+      hb_codepoint_t end = hb_min ((hb_codepoint_t) this->groups[i].endCharCode,
+				   (hb_codepoint_t) HB_UNICODE_MAX);
+      for (hb_codepoint_t codepoint = start; codepoint <= end; codepoint++)
+      {
+	hb_codepoint_t gid = T::group_get_glyph (this->groups[i], codepoint);
+	if (unlikely (!gid))
+	  continue;
+	out->add (codepoint);
+      }
     }
   }
 
diff --git a/test/api/fonts/cmunrm.otf b/test/api/fonts/cmunrm.otf
new file mode 100644
index 0000000..b449df0
--- /dev/null
+++ b/test/api/fonts/cmunrm.otf
Binary files differ
diff --git a/test/api/test-collect-unicodes.c b/test/api/test-collect-unicodes.c
index 50965a9..8a857e1 100644
--- a/test/api/test-collect-unicodes.c
+++ b/test/api/test-collect-unicodes.c
@@ -50,6 +50,27 @@
 }
 
 static void
+test_collect_unicodes_format12_notdef (void)
+{
+  hb_face_t *face = hb_test_open_font_file ("fonts/cmunrm.otf");
+  hb_set_t *codepoints = hb_set_create();
+  hb_codepoint_t cp;
+
+  hb_face_collect_unicodes (face, codepoints);
+
+  cp = HB_SET_VALUE_INVALID;
+  g_assert (hb_set_next (codepoints, &cp));
+  g_assert_cmpuint (0x20, ==, cp);
+  g_assert (hb_set_next (codepoints, &cp));
+  g_assert_cmpuint (0x21, ==, cp);
+  g_assert (hb_set_next (codepoints, &cp));
+  g_assert_cmpuint (0x22, ==, cp);
+
+  hb_set_destroy (codepoints);
+  hb_face_destroy (face);
+}
+
+static void
 test_collect_unicodes_format12 (void)
 {
   hb_face_t *face = hb_test_open_font_file ("fonts/Roboto-Regular.abc.format12.ttf");
@@ -101,6 +122,7 @@
   hb_test_add (test_collect_unicodes);
   hb_test_add (test_collect_unicodes_format4);
   hb_test_add (test_collect_unicodes_format12);
+  hb_test_add (test_collect_unicodes_format12_notdef);
 
   return hb_test_run();
 }