OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2009,2010 Red Hat, Inc. | 2 * Copyright © 2009,2010 Red Hat, Inc. |
3 * Copyright © 2010,2011,2013 Google, Inc. | 3 * Copyright © 2010,2011,2013 Google, Inc. |
4 * | 4 * |
5 * This is part of HarfBuzz, a text shaping library. | 5 * This is part of HarfBuzz, a text shaping library. |
6 * | 6 * |
7 * Permission is hereby granted, without written agreement and without | 7 * Permission is hereby granted, without written agreement and without |
8 * license or royalty fees, to use, copy, modify, and distribute this | 8 * license or royalty fees, to use, copy, modify, and distribute this |
9 * software and its documentation for any purpose, provided that the | 9 * software and its documentation for any purpose, provided that the |
10 * above copyright notice and the following two paragraphs appear in | 10 * above copyright notice and the following two paragraphs appear in |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 void | 34 void |
35 hb_ot_map_t::add_lookups (hb_face_t *face, | 35 hb_ot_map_t::add_lookups (hb_face_t *face, |
36 unsigned int table_index, | 36 unsigned int table_index, |
37 unsigned int feature_index, | 37 unsigned int feature_index, |
38 hb_mask_t mask, | 38 hb_mask_t mask, |
39 bool auto_zwj) | 39 bool auto_zwj) |
40 { | 40 { |
41 unsigned int lookup_indices[32]; | 41 unsigned int lookup_indices[32]; |
42 unsigned int offset, len; | 42 unsigned int offset, len; |
| 43 unsigned int table_lookup_count; |
| 44 |
| 45 table_lookup_count = hb_ot_layout_table_get_lookup_count (face, table_tags[tab
le_index]); |
43 | 46 |
44 offset = 0; | 47 offset = 0; |
45 do { | 48 do { |
46 len = ARRAY_LENGTH (lookup_indices); | 49 len = ARRAY_LENGTH (lookup_indices); |
47 hb_ot_layout_feature_get_lookups (face, | 50 hb_ot_layout_feature_get_lookups (face, |
48 table_tags[table_index], | 51 table_tags[table_index], |
49 feature_index, | 52 feature_index, |
50 offset, &len, | 53 offset, &len, |
51 lookup_indices); | 54 lookup_indices); |
52 | 55 |
53 for (unsigned int i = 0; i < len; i++) { | 56 for (unsigned int i = 0; i < len; i++) |
| 57 { |
| 58 if (lookup_indices[i] >= table_lookup_count) |
| 59 » continue; |
54 hb_ot_map_t::lookup_map_t *lookup = lookups[table_index].push (); | 60 hb_ot_map_t::lookup_map_t *lookup = lookups[table_index].push (); |
55 if (unlikely (!lookup)) | 61 if (unlikely (!lookup)) |
56 return; | 62 return; |
57 lookup->mask = mask; | 63 lookup->mask = mask; |
58 lookup->index = lookup_indices[i]; | 64 lookup->index = lookup_indices[i]; |
59 lookup->auto_zwj = auto_zwj; | 65 lookup->auto_zwj = auto_zwj; |
60 } | 66 } |
61 | 67 |
62 offset += len; | 68 offset += len; |
63 } while (len == ARRAY_LENGTH (lookup_indices)); | 69 } while (len == ARRAY_LENGTH (lookup_indices)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 if (unlikely (!info)) return; | 101 if (unlikely (!info)) return; |
96 info->tag = tag; | 102 info->tag = tag; |
97 info->seq = feature_infos.len; | 103 info->seq = feature_infos.len; |
98 info->max_value = value; | 104 info->max_value = value; |
99 info->flags = flags; | 105 info->flags = flags; |
100 info->default_value = (flags & F_GLOBAL) ? value : 0; | 106 info->default_value = (flags & F_GLOBAL) ? value : 0; |
101 info->stage[0] = current_stage[0]; | 107 info->stage[0] = current_stage[0]; |
102 info->stage[1] = current_stage[1]; | 108 info->stage[1] = current_stage[1]; |
103 } | 109 } |
104 | 110 |
105 inline void hb_ot_map_t::apply (unsigned int table_index, | |
106 const hb_ot_shape_plan_t *plan, | |
107 hb_font_t *font, | |
108 hb_buffer_t *buffer) const | |
109 { | |
110 unsigned int i = 0; | |
111 | |
112 for (unsigned int stage_index = 0; stage_index < stages[table_index].len; stag
e_index++) { | |
113 const stage_map_t *stage = &stages[table_index][stage_index]; | |
114 for (; i < stage->last_lookup; i++) | |
115 switch (table_index) | |
116 { | |
117 case 0: | |
118 hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].
index, | |
119 lookups[table_index][i].mask, | |
120 lookups[table_index][i].auto_zwj); | |
121 break; | |
122 | |
123 case 1: | |
124 hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].in
dex, | |
125 lookups[table_index][i].mask, | |
126 lookups[table_index][i].auto_zwj); | |
127 break; | |
128 } | |
129 | |
130 if (stage->pause_func) | |
131 { | |
132 buffer->clear_output (); | |
133 stage->pause_func (plan, font, buffer); | |
134 } | |
135 } | |
136 } | |
137 | |
138 void hb_ot_map_t::substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, h
b_buffer_t *buffer) const | |
139 { | |
140 apply (0, plan, font, buffer); | |
141 } | |
142 | |
143 void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_
buffer_t *buffer) const | |
144 { | |
145 apply (1, plan, font, buffer); | |
146 } | |
147 | |
148 | 111 |
149 void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_o
ut) const | 112 void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_o
ut) const |
150 { | 113 { |
151 for (unsigned int i = 0; i < lookups[table_index].len; i++) | 114 for (unsigned int i = 0; i < lookups[table_index].len; i++) |
152 hb_set_add (lookups_out, lookups[table_index][i].index); | 115 hb_set_add (lookups_out, lookups[table_index][i].index); |
153 } | 116 } |
154 | 117 |
155 void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::paus
e_func_t pause_func) | 118 void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::paus
e_func_t pause_func) |
156 { | 119 { |
157 stage_info_t *s = stages[table_index].push (); | 120 stage_info_t *s = stages[table_index].push (); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 if ((info->flags & F_GLOBAL) && info->max_value == 1) | 174 if ((info->flags & F_GLOBAL) && info->max_value == 1) |
212 /* Uses the global bit */ | 175 /* Uses the global bit */ |
213 bits_needed = 0; | 176 bits_needed = 0; |
214 else | 177 else |
215 bits_needed = _hb_bit_storage (info->max_value); | 178 bits_needed = _hb_bit_storage (info->max_value); |
216 | 179 |
217 if (!info->max_value || next_bit + bits_needed > 8 * sizeof (hb_mask_t)) | 180 if (!info->max_value || next_bit + bits_needed > 8 * sizeof (hb_mask_t)) |
218 continue; /* Feature disabled, or not enough bits. */ | 181 continue; /* Feature disabled, or not enough bits. */ |
219 | 182 |
220 | 183 |
221 bool found = false; | 184 hb_bool_t found = false; |
222 unsigned int feature_index[2]; | 185 unsigned int feature_index[2]; |
223 for (unsigned int table_index = 0; table_index < 2; table_index++) | 186 for (unsigned int table_index = 0; table_index < 2; table_index++) |
224 found |= hb_ot_layout_language_find_feature (face, | 187 found |= hb_ot_layout_language_find_feature (face, |
225 table_tags[table_index], | 188 table_tags[table_index], |
226 script_index[table_index], | 189 script_index[table_index], |
227 language_index[table_index], | 190 language_index[table_index], |
228 info->tag, | 191 info->tag, |
229 &feature_index[table_index]); | 192 &feature_index[table_index]); |
230 if (!found && !(info->flags & F_HAS_FALLBACK)) | 193 if (!found && !(info->flags & F_HAS_FALLBACK)) |
231 continue; | 194 continue; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 if (likely (stage_map)) { | 272 if (likely (stage_map)) { |
310 stage_map->last_lookup = last_num_lookups; | 273 stage_map->last_lookup = last_num_lookups; |
311 stage_map->pause_func = stages[table_index][stage_index].pause_func; | 274 stage_map->pause_func = stages[table_index][stage_index].pause_func; |
312 } | 275 } |
313 | 276 |
314 stage_index++; | 277 stage_index++; |
315 } | 278 } |
316 } | 279 } |
317 } | 280 } |
318 } | 281 } |
OLD | NEW |