[random] Shuffle

This commit is contained in:
Behdad Esfahbod 2018-09-11 10:51:19 +02:00
parent 71c9f84e7c
commit 08260c708a
2 changed files with 7 additions and 4 deletions

View File

@ -543,10 +543,7 @@ struct AlternateSet
/* If alt_index is MAX, randomize feature if it is the rand feature. */
if (alt_index == HB_OT_MAP_MAX_VALUE && c->random)
{
c->random_state = (0x5DEECE66Dull * c->random_state + 11) & (((uint64_t) 1 << 48) - 1);
alt_index = (c->random_state >> 32) % count + 1;
}
alt_index = c->random_number () % count + 1;
if (unlikely (alt_index > count || alt_index == 0)) return_trace (false);

View File

@ -521,6 +521,12 @@ struct hb_ot_apply_context_t :
iter_context.init (this, true);
}
inline uint32_t random_number (void)
{
random_state = (0x5DEECE66Dull * random_state + 11) & (((uint64_t) 1 << 48) - 1);
return random_state >> 32;
}
inline bool
match_properties_mark (hb_codepoint_t glyph,
unsigned int glyph_props,