| 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 Google, Inc. | 3 * Copyright © 2010,2012 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 268 } |
| 269 | 269 |
| 270 inline bool apply (hb_apply_context_t *c) const | 270 inline bool apply (hb_apply_context_t *c) const |
| 271 { | 271 { |
| 272 TRACE_APPLY (this); | 272 TRACE_APPLY (this); |
| 273 if (unlikely (!substitute.len)) return TRACE_RETURN (false); | 273 if (unlikely (!substitute.len)) return TRACE_RETURN (false); |
| 274 | 274 |
| 275 unsigned int klass = c->buffer->cur().glyph_props() & | 275 unsigned int klass = c->buffer->cur().glyph_props() & |
| 276 HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE ? HB_OT_LAYOUT_GLYPH_
PROPS_BASE_GLYPH : 0; | 276 HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE ? HB_OT_LAYOUT_GLYPH_
PROPS_BASE_GLYPH : 0; |
| 277 unsigned int count = substitute.len; | 277 unsigned int count = substitute.len; |
| 278 for (unsigned int i = 0; i < count; i++) { | 278 if (count == 1) /* Special-case to make it in-place. */ |
| 279 set_lig_props_for_component (c->buffer->cur(), i); | 279 { |
| 280 c->output_glyph (substitute.array[i], klass); | 280 c->replace_glyph (substitute.array[0]); |
| 281 } | 281 } |
| 282 c->buffer->skip_glyph (); | 282 else |
| 283 { |
| 284 for (unsigned int i = 0; i < count; i++) { |
| 285 » set_lig_props_for_component (c->buffer->cur(), i); |
| 286 » c->output_glyph (substitute.array[i], klass); |
| 287 } |
| 288 c->buffer->skip_glyph (); |
| 289 } |
| 283 | 290 |
| 284 return TRACE_RETURN (true); | 291 return TRACE_RETURN (true); |
| 285 } | 292 } |
| 286 | 293 |
| 287 inline bool serialize (hb_serialize_context_t *c, | 294 inline bool serialize (hb_serialize_context_t *c, |
| 288 Supplier<GlyphID> &glyphs, | 295 Supplier<GlyphID> &glyphs, |
| 289 unsigned int num_glyphs) | 296 unsigned int num_glyphs) |
| 290 { | 297 { |
| 291 TRACE_SERIALIZE (this); | 298 TRACE_SERIALIZE (this); |
| 292 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 299 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 bool ret = false; | 1196 bool ret = false; |
| 1190 | 1197 |
| 1191 if (unlikely (!c->buffer->len || !c->lookup_mask)) | 1198 if (unlikely (!c->buffer->len || !c->lookup_mask)) |
| 1192 return false; | 1199 return false; |
| 1193 | 1200 |
| 1194 c->set_recurse_func (apply_recurse_func); | 1201 c->set_recurse_func (apply_recurse_func); |
| 1195 c->set_lookup (*this); | 1202 c->set_lookup (*this); |
| 1196 | 1203 |
| 1197 if (likely (!is_reverse ())) | 1204 if (likely (!is_reverse ())) |
| 1198 { | 1205 { |
| 1199 » /* in/out forward substitution */ | 1206 /* in/out forward substitution */ |
| 1200 » c->buffer->clear_output (); | 1207 c->buffer->clear_output (); |
| 1201 » c->buffer->idx = 0; | 1208 c->buffer->idx = 0; |
| 1202 | 1209 |
| 1203 » while (c->buffer->idx < c->buffer->len) | 1210 while (c->buffer->idx < c->buffer->len) |
| 1204 » { | 1211 { |
| 1205 » if ((c->buffer->cur().mask & c->lookup_mask) && | 1212 » if (digest->may_have (c->buffer->cur().codepoint) && |
| 1206 » digest->may_have (c->buffer->cur().codepoint) && | 1213 » (c->buffer->cur().mask & c->lookup_mask) && |
| 1207 » apply_once (c)) | 1214 » apply_once (c)) |
| 1208 » ret = true; | 1215 » ret = true; |
| 1209 » else | 1216 » else |
| 1210 » c->buffer->next_glyph (); | 1217 » c->buffer->next_glyph (); |
| 1211 » } | 1218 } |
| 1212 » if (ret) | 1219 if (ret) |
| 1213 » c->buffer->swap_buffers (); | 1220 » c->buffer->swap_buffers (); |
| 1214 } | 1221 } |
| 1215 else | 1222 else |
| 1216 { | 1223 { |
| 1217 » /* in-place backward substitution */ | 1224 /* in-place backward substitution */ |
| 1218 » c->buffer->remove_output (); | 1225 c->buffer->remove_output (); |
| 1219 » c->buffer->idx = c->buffer->len - 1; | 1226 c->buffer->idx = c->buffer->len - 1; |
| 1220 » do | 1227 do |
| 1221 » { | 1228 { |
| 1222 » if ((c->buffer->cur().mask & c->lookup_mask) && | 1229 » if (digest->may_have (c->buffer->cur().codepoint) && |
| 1223 » digest->may_have (c->buffer->cur().codepoint) && | 1230 » (c->buffer->cur().mask & c->lookup_mask) && |
| 1224 » apply_once (c)) | 1231 » apply_once (c)) |
| 1225 » ret = true; | 1232 » ret = true; |
| 1226 » else | 1233 » else |
| 1227 » c->buffer->idx--; | 1234 » c->buffer->idx--; |
| 1228 | 1235 |
| 1229 » } | 1236 } |
| 1230 » while ((int) c->buffer->idx >= 0); | 1237 while ((int) c->buffer->idx >= 0); |
| 1231 } | 1238 } |
| 1232 | 1239 |
| 1233 return ret; | 1240 return ret; |
| 1234 } | 1241 } |
| 1235 | 1242 |
| 1236 inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c, | 1243 inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c, |
| 1237 unsigned int i) | 1244 unsigned int i) |
| 1238 { return CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable)[i].serialize (c
, this); } | 1245 { return CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable)[i].serialize (c
, this); } |
| 1239 | 1246 |
| 1240 inline bool serialize_single (hb_serialize_context_t *c, | 1247 inline bool serialize_single (hb_serialize_context_t *c, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 bool ret = l.apply_once (c); | 1410 bool ret = l.apply_once (c); |
| 1404 c->lookup_props = saved_lookup_props; | 1411 c->lookup_props = saved_lookup_props; |
| 1405 return ret; | 1412 return ret; |
| 1406 } | 1413 } |
| 1407 | 1414 |
| 1408 | 1415 |
| 1409 } /* namespace OT */ | 1416 } /* namespace OT */ |
| 1410 | 1417 |
| 1411 | 1418 |
| 1412 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ | 1419 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ |
| OLD | NEW |