retain FDSelect & FDArray with --retain-gids
authorMichiharu Ariza <ariza@adobe.com>
Thu, 7 Feb 2019 23:32:32 +0000 (15:32 -0800)
committerMichiharu Ariza <ariza@adobe.com>
Thu, 7 Feb 2019 23:32:32 +0000 (15:32 -0800)
so in sync with fonttools behavior

src/hb-subset-cff-common.cc
test/api/fonts/SourceHanSans-Regular.41,4C2E.retaingids.otf

index 46821fe..f29937a 100644 (file)
@@ -66,21 +66,17 @@ hb_plan_subset_cff_fdselect (const hb_subset_plan_t *plan,
     hb_set_t  *set = hb_set_create ();
     if (set == &Null (hb_set_t))
       return false;
-    hb_codepoint_t  prev_fd = 0;
+    hb_codepoint_t  prev_fd = CFF_UNDEF_CODE;
     for (hb_codepoint_t i = 0; i < subset_num_glyphs; i++)
     {
       hb_codepoint_t   glyph;
       hb_codepoint_t   fd;
       if (!plan->old_gid_for_new_gid (i, &glyph))
       {
-       /* for a missing glyph, use the same fd as the previous
-        * as an attempt to minimize the number of ranges */
-       fd = prev_fd;
-      }
-      else
-      {
-       fd = src.get_fd (glyph);
+       /* fonttools retains FDSelect & font dicts for missing glyphs. do the same */
+       glyph = i;
       }
+      fd = src.get_fd (glyph);
       set->add (fd);
 
       if (fd != prev_fd)
index 6da8ad3..906bdbe 100644 (file)
Binary files a/test/api/fonts/SourceHanSans-Regular.41,4C2E.retaingids.otf and b/test/api/fonts/SourceHanSans-Regular.41,4C2E.retaingids.otf differ