added desubroutinize & retain-gids full test cases with CFF fonts

and CFF retain-gids fixes
diff --git a/src/hb-subset-cff1.cc b/src/hb-subset-cff1.cc
index bc8ce55..49ac0bf 100644
--- a/src/hb-subset-cff1.cc
+++ b/src/hb-subset-cff1.cc
@@ -476,24 +476,20 @@
     unsigned int glyph;
     for (glyph = 1; glyph < plan->num_output_glyphs (); glyph++)
     {
-      hb_codepoint_t  orig_glyph;
-      if (!plan->old_gid_for_new_gid (glyph, &orig_glyph))
+      hb_codepoint_t  old_glyph;
+      if (!plan->old_gid_for_new_gid (glyph, &old_glyph))
       {
-	/* pretend a missing glyph has the last code + 1
-	 * as an attempt to minimize the number of ranges */
-	code = last_code + 1;
+      	/* Retain the code for the old missing glyph ID */
+	old_glyph = glyph;
       }
-      else
+      code = acc.glyph_to_code (old_glyph);
+      if (code == CFF_UNDEF_CODE)
       {
-	code = acc.glyph_to_code (orig_glyph);
-	if (code == CFF_UNDEF_CODE)
-	{
-	  subset_enc_num_codes = glyph - 1;
-	  break;
-	}
+	subset_enc_num_codes = glyph - 1;
+	break;
       }
 
-      if (code != last_code + 1)
+      if ((last_code == CFF_UNDEF_CODE) || (code != last_code + 1))
       {
 	code_pair_t pair = { code, glyph };
 	subset_enc_code_ranges.push (pair);
@@ -502,7 +498,7 @@
 
       if (encoding != &Null(Encoding))
       {
-	hb_codepoint_t  sid = acc.glyph_to_sid (orig_glyph);
+	hb_codepoint_t  sid = acc.glyph_to_sid (old_glyph);
 	encoding->get_supplement_codes (sid, supp_codes);
 	for (unsigned int i = 0; i < supp_codes.length; i++)
 	{
@@ -540,22 +536,18 @@
     unsigned int glyph;
     for (glyph = 1; glyph < plan->num_output_glyphs (); glyph++)
     {
-      hb_codepoint_t  orig_glyph;
-      if (!plan->old_gid_for_new_gid (glyph, &orig_glyph))
+      hb_codepoint_t  old_glyph;
+      if (!plan->old_gid_for_new_gid (glyph, &old_glyph))
       {
-	/* pretend a missing glyph has the last sid + 1
-	 * as an attempt to minimize the number of ranges */
-	sid = last_sid + 1;
+      	/* Retain the SID for the old missing glyph ID */
+	old_glyph = glyph;
       }
-      else
-      {
-      	sid = acc.glyph_to_sid (orig_glyph);
+      sid = acc.glyph_to_sid (old_glyph);
 
-      	if (!acc.is_CID ())
-	  sid = sidmap.add (sid);
-      }
+      if (!acc.is_CID ())
+	sid = sidmap.add (sid);
 
-      if (sid != last_sid + 1)
+      if ((last_sid == CFF_UNDEF_CODE) || (sid != last_sid + 1))
       {
 	code_pair_t pair = { sid, glyph };
 	subset_charset_ranges.push (pair);
diff --git a/test/api/fonts/SourceHanSans-Regular.41,4C2E.retaingids.otf b/test/api/fonts/SourceHanSans-Regular.41,4C2E.retaingids.otf
index 3064ffe..6da8ad3 100644
--- a/test/api/fonts/SourceHanSans-Regular.41,4C2E.retaingids.otf
+++ b/test/api/fonts/SourceHanSans-Regular.41,4C2E.retaingids.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.desubroutinize-retain-gids.1FC,21,41,20,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.desubroutinize-retain-gids.1FC,21,41,20,62,63.otf
new file mode 100644
index 0000000..ca54654
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.desubroutinize-retain-gids.1FC,21,41,20,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.desubroutinize-retain-gids.61,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.desubroutinize-retain-gids.61,62,63.otf
new file mode 100644
index 0000000..0f52e66
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.desubroutinize-retain-gids.61,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.desubroutinize-retain-gids.D7,D8,D9,DA,DE.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.desubroutinize-retain-gids.D7,D8,D9,DA,DE.otf
new file mode 100644
index 0000000..170c151
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.desubroutinize-retain-gids.D7,D8,D9,DA,DE.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.1FC,21,41,20,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.1FC,21,41,20,62,63.otf
new file mode 100644
index 0000000..87c8f00
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.1FC,21,41,20,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.61,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.61,62,63.otf
new file mode 100644
index 0000000..f381f13
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.61,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.D7,D8,D9,DA,DE.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.D7,D8,D9,DA,DE.otf
new file mode 100644
index 0000000..f32a1fc
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize-retain-gids.D7,D8,D9,DA,DE.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize.1FC,21,41,20,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize.1FC,21,41,20,62,63.otf
similarity index 100%
rename from test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize.1FC,21,41,20,62,63.otf
rename to test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize.1FC,21,41,20,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize.61,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize.61,62,63.otf
new file mode 100644
index 0000000..419dfa0
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize.61,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize.D7,D8,D9,DA,DE.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize.D7,D8,D9,DA,DE.otf
similarity index 100%
rename from test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize.D7,D8,D9,DA,DE.otf
rename to test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-desubroutinize.D7,D8,D9,DA,DE.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-retain-gids.1FC,21,41,20,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-retain-gids.1FC,21,41,20,62,63.otf
new file mode 100644
index 0000000..9a5c09a
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-retain-gids.1FC,21,41,20,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-retain-gids.61,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-retain-gids.61,62,63.otf
new file mode 100644
index 0000000..f5b4ebd
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-retain-gids.61,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-retain-gids.D7,D8,D9,DA,DE.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-retain-gids.D7,D8,D9,DA,DE.otf
new file mode 100644
index 0000000..57f9a8d
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints-retain-gids.D7,D8,D9,DA,DE.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize-retain-gids.1FC,21,41,20,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize-retain-gids.1FC,21,41,20,62,63.otf
new file mode 100644
index 0000000..6e8660b
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize-retain-gids.1FC,21,41,20,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize-retain-gids.61,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize-retain-gids.61,62,63.otf
new file mode 100644
index 0000000..5b396db
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize-retain-gids.61,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize-retain-gids.D7,D8,D9,DA,DE.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize-retain-gids.D7,D8,D9,DA,DE.otf
new file mode 100644
index 0000000..ea0cc5e
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize-retain-gids.D7,D8,D9,DA,DE.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize.retain-gids.D7,D8,D9,DA,DE.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize.retain-gids.D7,D8,D9,DA,DE.otf
new file mode 100644
index 0000000..f32a1fc
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.desubroutinize.retain-gids.D7,D8,D9,DA,DE.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.retain-gids.D7,D8,D9,DA,DE.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.retain-gids.D7,D8,D9,DA,DE.otf
new file mode 100644
index 0000000..57f9a8d
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.drop-hints.retain-gids.D7,D8,D9,DA,DE.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.retain-gids.1FC,21,41,20,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.retain-gids.1FC,21,41,20,62,63.otf
new file mode 100644
index 0000000..2caee79
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.retain-gids.1FC,21,41,20,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.retain-gids.61,62,63.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.retain-gids.61,62,63.otf
new file mode 100644
index 0000000..b428a7b
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.retain-gids.61,62,63.otf
Binary files differ
diff --git a/test/subset/data/expected/full-font/SourceSansPro-Regular.retain-gids.D7,D8,D9,DA,DE.otf b/test/subset/data/expected/full-font/SourceSansPro-Regular.retain-gids.D7,D8,D9,DA,DE.otf
new file mode 100644
index 0000000..ccb4428
--- /dev/null
+++ b/test/subset/data/expected/full-font/SourceSansPro-Regular.retain-gids.D7,D8,D9,DA,DE.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.3042,3044,3046,3048,304A,304B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.3042,3044,3046,3048,304A,304B.otf
new file mode 100644
index 0000000..8445645
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.3042,3044,3046,3048,304A,304B.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf
new file mode 100644
index 0000000..9d2e5d6
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.61,63,65,6B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.61,63,65,6B.otf
new file mode 100644
index 0000000..6ca270a
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.61,63,65,6B.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf
new file mode 100644
index 0000000..50ec062
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.660E.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.660E.otf
new file mode 100644
index 0000000..fe8e716
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize-retain-gids.660E.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize..otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize..otf
deleted file mode 100644
index 7c0c5fd..0000000
--- a/test/subset/data/expected/japanese/SourceHanSans-Regular.desubroutinize..otf
+++ /dev/null
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.3042,3044,3046,3048,304A,304B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.3042,3044,3046,3048,304A,304B.otf
new file mode 100644
index 0000000..30087bc
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.3042,3044,3046,3048,304A,304B.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf
new file mode 100644
index 0000000..1ef807f
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.61,63,65,6B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.61,63,65,6B.otf
new file mode 100644
index 0000000..55b4230
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.61,63,65,6B.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf
new file mode 100644
index 0000000..991300e
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.660E.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.660E.otf
new file mode 100644
index 0000000..2f3f863
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize-retain-gids.660E.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.3042,3044,3046,3048,304A,304B.otf
similarity index 65%
copy from test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E.otf
copy to test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.3042,3044,3046,3048,304A,304B.otf
index 27c4676..3f83101 100644
--- a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E.otf
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.3042,3044,3046,3048,304A,304B.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.3042,3044,3046,73E0,5EA6,8F38.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.3042,3044,3046,73E0,5EA6,8F38.otf
similarity index 65%
rename from test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.3042,3044,3046,73E0,5EA6,8F38.otf
rename to test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.3042,3044,3046,73E0,5EA6,8F38.otf
index c707bcd..9e6e9cf 100644
--- a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.3042,3044,3046,73E0,5EA6,8F38.otf
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.3042,3044,3046,73E0,5EA6,8F38.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.61,63,65,6B.otf
similarity index 74%
copy from test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E.otf
copy to test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.61,63,65,6B.otf
index 27c4676..02d7aaf 100644
--- a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E.otf
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.61,63,65,6B.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E,6975,73E0,5EA6,8F38,6E05.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.660E,6975,73E0,5EA6,8F38,6E05.otf
similarity index 64%
rename from test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E,6975,73E0,5EA6,8F38,6E05.otf
rename to test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.660E,6975,73E0,5EA6,8F38,6E05.otf
index efc98b6..a1adef2 100644
--- a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E,6975,73E0,5EA6,8F38,6E05.otf
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.660E,6975,73E0,5EA6,8F38,6E05.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.660E.otf
similarity index 85%
rename from test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E.otf
rename to test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.660E.otf
index 27c4676..da13955 100644
--- a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.660E.otf
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-desubroutinize.660E.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.3042,3044,3046,3048,304A,304B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.3042,3044,3046,3048,304A,304B.otf
new file mode 100644
index 0000000..c7b6250
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.3042,3044,3046,3048,304A,304B.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf
new file mode 100644
index 0000000..b1f9cb3
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.61,63,65,6B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.61,63,65,6B.otf
new file mode 100644
index 0000000..03f8fff
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.61,63,65,6B.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf
new file mode 100644
index 0000000..0acb6ad
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.660E.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.660E.otf
new file mode 100644
index 0000000..d9a5fab
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints-retain-gids.660E.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize..otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize..otf
deleted file mode 100644
index a73617a..0000000
--- a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize..otf
+++ /dev/null
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.3042,3044,3046,3048,304A,304B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.3042,3044,3046,3048,304A,304B.otf
deleted file mode 100644
index 790b714..0000000
--- a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.3042,3044,3046,3048,304A,304B.otf
+++ /dev/null
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.61,63,65,6B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.61,63,65,6B.otf
deleted file mode 100644
index 591d139..0000000
--- a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.desubroutinize.61,63,65,6B.otf
+++ /dev/null
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.3042,3044,3046,3048,304A,304B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.3042,3044,3046,3048,304A,304B.otf
new file mode 100644
index 0000000..bd5a87d
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.3042,3044,3046,3048,304A,304B.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf
new file mode 100644
index 0000000..bfda886
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.3042,3044,3046,73E0,5EA6,8F38.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.61,63,65,6B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.61,63,65,6B.otf
new file mode 100644
index 0000000..f77e115
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.61,63,65,6B.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf
new file mode 100644
index 0000000..71a2223
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.660E,6975,73E0,5EA6,8F38,6E05.otf
Binary files differ
diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.660E.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.660E.otf
new file mode 100644
index 0000000..96da59a
--- /dev/null
+++ b/test/subset/data/expected/japanese/SourceHanSans-Regular.retain-gids.660E.otf
Binary files differ
diff --git a/test/subset/data/profiles/desubroutinize-retain-gids.txt b/test/subset/data/profiles/desubroutinize-retain-gids.txt
new file mode 100644
index 0000000..cbb37b6
--- /dev/null
+++ b/test/subset/data/profiles/desubroutinize-retain-gids.txt
@@ -0,0 +1,2 @@
+--desubroutinize
+--retain-gids
diff --git a/test/subset/data/profiles/drop-hints-desubroutinize-retain-gids.txt b/test/subset/data/profiles/drop-hints-desubroutinize-retain-gids.txt
new file mode 100644
index 0000000..848620a
--- /dev/null
+++ b/test/subset/data/profiles/drop-hints-desubroutinize-retain-gids.txt
@@ -0,0 +1,3 @@
+--no-hinting
+--desubroutinize
+--retain-gids
diff --git a/test/subset/data/tests/full-font.tests b/test/subset/data/tests/full-font.tests
index f422ff5..74c61fa 100644
--- a/test/subset/data/tests/full-font.tests
+++ b/test/subset/data/tests/full-font.tests
@@ -5,6 +5,12 @@
 PROFILES:
 default.txt
 drop-hints.txt
+drop-hints-retain-gids.txt
+retain-gids.txt
+desubroutinize.txt
+desubroutinize-retain-gids.txt
+drop-hints-desubroutinize.txt
+drop-hints-desubroutinize-retain-gids.txt
 
 SUBSETS:
 abc
diff --git a/test/subset/data/tests/japanese.tests b/test/subset/data/tests/japanese.tests
index fc58646..e288912 100644
--- a/test/subset/data/tests/japanese.tests
+++ b/test/subset/data/tests/japanese.tests
@@ -5,6 +5,12 @@
 PROFILES:
 default.txt
 drop-hints.txt
+drop-hints-retain-gids.txt
+retain-gids.txt
+desubroutinize.txt
+desubroutinize-retain-gids.txt
+drop-hints-desubroutinize.txt
+drop-hints-desubroutinize-retain-gids.txt
 
 SUBSETS:

diff --git a/test/subset/subset_test_suite.py b/test/subset/subset_test_suite.py
index 5e3368e..955a00d 100644
--- a/test/subset/subset_test_suite.py
+++ b/test/subset/subset_test_suite.py
@@ -34,7 +34,7 @@
 		return font_base_name_parts[1]
 
 	def applicable(self):
-		return self.profile_path.find("desubroutinize") < 0 or self.get_font_extension() == "otf"
+		return self.profile_path.find("desubroutinize") < 0 and self.profile_path.find("retain-gids") < 0 or self.get_font_extension() == ".otf"
 
 # A group of tests to perform on the subsetter. Each test
 # Identifies a font a subsetting profile, and a subset to be cut.