OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2007,2008,2009,2010 Red Hat, Inc. | 2 * Copyright © 2007,2008,2009,2010 Red Hat, Inc. |
3 * Copyright © 2010,2012,2013 Google, Inc. | 3 * Copyright © 2010,2012,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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 unsigned int count = substitute.len; | 258 unsigned int count = substitute.len; |
259 for (unsigned int i = 0; i < count; i++) | 259 for (unsigned int i = 0; i < count; i++) |
260 c->output->add (substitute[i]); | 260 c->output->add (substitute[i]); |
261 } | 261 } |
262 | 262 |
263 inline bool apply (hb_apply_context_t *c) const | 263 inline bool apply (hb_apply_context_t *c) const |
264 { | 264 { |
265 TRACE_APPLY (this); | 265 TRACE_APPLY (this); |
266 unsigned int count = substitute.len; | 266 unsigned int count = substitute.len; |
267 | 267 |
268 /* TODO: | |
269 * Testing shows that Uniscribe actually allows zero-len susbstitute, | |
270 * which essentially deletes a glyph. We don't allow for now. It | |
271 * can be confusing to the client since the cluster from the deleted | |
272 * glyph won't be merged with any output cluster... Also, currently | |
273 * buffer->move_to() makes assumptions about this too. Perhaps fix | |
274 * in the future after figuring out what to do with the clusters. | |
275 */ | |
276 if (unlikely (!count)) return_trace (false); | |
277 | |
278 /* Special-case to make it in-place and not consider this | 268 /* Special-case to make it in-place and not consider this |
279 * as a "multiplied" substitution. */ | 269 * as a "multiplied" substitution. */ |
280 if (unlikely (count == 1)) | 270 if (unlikely (count == 1)) |
281 { | 271 { |
282 c->replace_glyph (substitute.array[0]); | 272 c->replace_glyph (substitute.array[0]); |
283 return_trace (true); | 273 return_trace (true); |
284 } | 274 } |
| 275 /* Spec disallows this, but Uniscribe allows it. |
| 276 * https://github.com/behdad/harfbuzz/issues/253 */ |
| 277 else if (unlikely (count == 0)) |
| 278 { |
| 279 c->buffer->delete_glyph (); |
| 280 return_trace (true); |
| 281 } |
285 | 282 |
286 unsigned int klass = _hb_glyph_info_is_ligature (&c->buffer->cur()) ? | 283 unsigned int klass = _hb_glyph_info_is_ligature (&c->buffer->cur()) ? |
287 HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0; | 284 HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0; |
288 | 285 |
289 for (unsigned int i = 0; i < count; i++) { | 286 for (unsigned int i = 0; i < count; i++) { |
290 _hb_glyph_info_set_lig_props_for_component (&c->buffer->cur(), i); | 287 _hb_glyph_info_set_lig_props_for_component (&c->buffer->cur(), i); |
291 c->output_glyph_for_component (substitute.array[i], klass); | 288 c->output_glyph_for_component (substitute.array[i], klass); |
292 } | 289 } |
293 c->buffer->skip_glyph (); | 290 c->buffer->skip_glyph (); |
294 | 291 |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 c->set_lookup_index (saved_lookup_index); | 1342 c->set_lookup_index (saved_lookup_index); |
1346 c->set_lookup_props (saved_lookup_props); | 1343 c->set_lookup_props (saved_lookup_props); |
1347 return ret; | 1344 return ret; |
1348 } | 1345 } |
1349 | 1346 |
1350 | 1347 |
1351 } /* namespace OT */ | 1348 } /* namespace OT */ |
1352 | 1349 |
1353 | 1350 |
1354 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ | 1351 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ |
OLD | NEW |