[subset] Correct calculation of max offset; fixes bug where loca would erroneously...
authorrsheeter <rsheeter@google.com>
Fri, 31 May 2019 22:14:44 +0000 (15:14 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Sat, 1 Jun 2019 02:43:30 +0000 (19:43 -0700)
src/hb-ot-glyf-table.hh

index 6113dbc..1ac9f6b 100644 (file)
@@ -85,7 +85,7 @@ struct glyf
   static bool
   _add_loca_and_head (hb_subset_plan_t * plan, Iterator padded_offsets)
   {
-    unsigned int max_offset = + padded_offsets | hb_reduce (hb_max, 0);
+    unsigned max_offset = + padded_offsets | hb_reduce(hb_add, 0);
     unsigned num_offsets = padded_offsets.len () + 1;
     bool use_short_loca = max_offset < 0x1FFFF;
     unsigned entry_size = use_short_loca ? 2 : 4;
@@ -93,6 +93,8 @@ struct glyf
 
     if (unlikely (!loca_prime_data)) return false;
 
+    DEBUG_MSG(SUBSET, nullptr, "loca entry_size %d num_offsets %d max_offset %d size %d", entry_size, num_offsets, max_offset, entry_size * num_offsets);
+
     if (use_short_loca)
       _write_loca (padded_offsets, 1, hb_array ((HBUINT16*) loca_prime_data, num_offsets));
     else
@@ -164,6 +166,7 @@ struct glyf
     | hb_map (&SubsetGlyph::padded_size)
     ;
 
+    if (c->serializer->in_error ()) return_trace (false);
     return_trace (c->serializer->check_success (_add_loca_and_head (c->plan, padded_offsets)));
   }