Don't seed the RNG from the contents of the buffer
authorDavid Corbett <corbett.dav@husky.neu.edu>
Fri, 23 Feb 2018 17:22:32 +0000 (12:22 -0500)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 11 Sep 2018 08:47:59 +0000 (10:47 +0200)
src/hb-ot-layout-gsubgpos.hh
src/hb-ot-layout.cc
test/shaping/data/in-house/tests/rand.tests

index 113433d..3a028f3 100644 (file)
@@ -503,16 +503,13 @@ struct hb_ot_apply_context_t :
                        auto_zwnj (true),
                        auto_zwj (true),
                        random (false),
-                       random_state (0),
+                       random_state (1),
                        has_glyph_classes (gdef.has_glyph_classes ()) {}
 
   inline void set_lookup_mask (hb_mask_t mask) { lookup_mask = mask; }
   inline void set_auto_zwj (bool auto_zwj_) { auto_zwj = auto_zwj_; }
   inline void set_auto_zwnj (bool auto_zwnj_) { auto_zwnj = auto_zwnj_; }
-  inline void set_random_state (uint64_t random_state_) {
-    random = true;
-    random_state = random_state_;
-  }
+  inline void set_random (bool random_) { random = random_; }
   inline void set_recurse_func (recurse_func_t func) { recurse_func = func; }
   inline void set_lookup_index (unsigned int lookup_index_) { lookup_index = lookup_index_; }
   inline void set_lookup_props (unsigned int lookup_props_)
index b31dbbc..51c1198 100644 (file)
@@ -1270,10 +1270,7 @@ inline void hb_ot_map_t::apply (const Proxy &proxy,
       c.set_auto_zwnj (lookups[table_index][i].auto_zwnj);
       if (lookups[table_index][i].random)
       {
-       uint64_t random_state = 1;
-       for (unsigned int j = 0; j < buffer->len; j++)
-         random_state = 31 * random_state + buffer->info[j].codepoint;
-       c.set_random_state (random_state);
+       c.set_random (true);
        buffer->unsafe_to_break_all ();
       }
       apply_string<Proxy> (&c,
index f1023e8..781abf4 100644 (file)
@@ -1,3 +1,3 @@
 ../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=-rand:U+0054,U+0055,U+0056:[1=0+560|2=1+602|3=2+602]
 ../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=rand=2:U+0054,U+0055,U+0056:[5=0+560|8=1+602|11=2+602]
-../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names:U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056:[4=0+560|7=1+602|11=2+602|6=3+560|8=4+602|10=5+602|5=6+560|9=7+602|10=8+602|5=9+560|7=10+602|12=11+602]
+../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names:U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056:[6=0+560|9=1+602|10=2+602|6=3+560|9=4+602|12=5+602|5=6+560|8=7+602|11=8+602|6=9+560|8=10+602|10=11+602]