From 6774463883978b00b4d8c719ed75edfc4537c77f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 20 May 2010 15:40:12 +0100 Subject: [PATCH] Apply user features to ranges! --- src/hb-ot-shape.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 81892a2e5..509ce7d55 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -116,12 +116,33 @@ setup_lookups (hb_face_t *face, add_feature (face, table_tag, feature_index, 1, lookups, num_lookups, room_lookups); } + /* Clear buffer masks. */ + unsigned int count = buffer->len; + for (unsigned int i = 0; i < count; i++) + buffer->info[i].mask = 1; + + unsigned int last_bit_used = 1; for (i = 0; i < num_features; i++) { + unsigned int bits_needed = _hb_bit_storage (features[i].value); + if (!bits_needed) + continue; + unsigned int mask = (1 << (last_bit_used + bits_needed)) - (1 << last_bit_used); + unsigned int value = features[i].value << last_bit_used; + last_bit_used += bits_needed; + if (hb_ot_layout_language_find_feature (face, table_tag, script_index, language_index, features[i].tag, &feature_index)) - add_feature (face, table_tag, feature_index, 1, lookups, num_lookups, room_lookups); + add_feature (face, table_tag, feature_index, mask, lookups, num_lookups, room_lookups); + + /* Turn mask on in the buffer, the über-slow way! */ + unsigned int count = buffer->len; + for (unsigned int i = 0; i < count; i++) { + unsigned int cluster = buffer->info[i].cluster; + if (features[i].start <= cluster && cluster < features[i].end) + buffer->info[i].mask |= value; + } } qsort (lookups, *num_lookups, sizeof (lookups[0]), cmp_lookups);