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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 struct SingleSubst | 193 struct SingleSubst |
194 { | 194 { |
195 inline bool serialize (hb_serialize_context_t *c, | 195 inline bool serialize (hb_serialize_context_t *c, |
196 Supplier<GlyphID> &glyphs, | 196 Supplier<GlyphID> &glyphs, |
197 Supplier<GlyphID> &substitutes, | 197 Supplier<GlyphID> &substitutes, |
198 unsigned int num_glyphs) | 198 unsigned int num_glyphs) |
199 { | 199 { |
200 TRACE_SERIALIZE (this); | 200 TRACE_SERIALIZE (this); |
201 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); | 201 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); |
202 unsigned int format = 2; | 202 unsigned int format = 2; |
203 int delta; | 203 int delta = 0; |
204 if (num_glyphs) { | 204 if (num_glyphs) { |
205 format = 1; | 205 format = 1; |
206 /* TODO(serialize) check for wrap-around */ | 206 /* TODO(serialize) check for wrap-around */ |
207 delta = substitutes[0] - glyphs[0]; | 207 delta = substitutes[0] - glyphs[0]; |
208 for (unsigned int i = 1; i < num_glyphs; i++) | 208 for (unsigned int i = 1; i < num_glyphs; i++) |
209 if (delta != substitutes[i] - glyphs[i]) { | 209 if (delta != substitutes[i] - glyphs[i]) { |
210 format = 2; | 210 format = 2; |
211 break; | 211 break; |
212 } | 212 } |
213 } | 213 } |
214 u.format.set (format); | 214 u.format.set (format); |
215 switch (u.format) { | 215 switch (u.format) { |
216 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, num_glyphs, del
ta)); | 216 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, num_glyphs, del
ta)); |
217 case 2: return TRACE_RETURN (u.format2.serialize (c, glyphs, substitutes, nu
m_glyphs)); | 217 case 2: return TRACE_RETURN (u.format2.serialize (c, glyphs, substitutes, nu
m_glyphs)); |
218 default:return TRACE_RETURN (false); | 218 default:return TRACE_RETURN (false); |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 template <typename context_t> | 222 template <typename context_t> |
223 inline typename context_t::return_t dispatch (context_t *c) const | 223 inline typename context_t::return_t dispatch (context_t *c) const |
224 { | 224 { |
225 TRACE_DISPATCH (this); | 225 TRACE_DISPATCH (this, u.format); |
226 switch (u.format) { | 226 switch (u.format) { |
227 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 227 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
228 case 2: return TRACE_RETURN (c->dispatch (u.format2)); | 228 case 2: return TRACE_RETURN (c->dispatch (u.format2)); |
229 default:return TRACE_RETURN (c->default_return_value ()); | 229 default:return TRACE_RETURN (c->default_return_value ()); |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 inline bool sanitize (hb_sanitize_context_t *c) { | 233 inline bool sanitize (hb_sanitize_context_t *c) { |
234 TRACE_SANITIZE (this); | 234 TRACE_SANITIZE (this); |
235 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 235 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 u.format.set (format); | 415 u.format.set (format); |
416 switch (u.format) { | 416 switch (u.format) { |
417 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, substitute_len_
list, num_glyphs, substitute_glyphs_list)); | 417 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, substitute_len_
list, num_glyphs, substitute_glyphs_list)); |
418 default:return TRACE_RETURN (false); | 418 default:return TRACE_RETURN (false); |
419 } | 419 } |
420 } | 420 } |
421 | 421 |
422 template <typename context_t> | 422 template <typename context_t> |
423 inline typename context_t::return_t dispatch (context_t *c) const | 423 inline typename context_t::return_t dispatch (context_t *c) const |
424 { | 424 { |
425 TRACE_DISPATCH (this); | 425 TRACE_DISPATCH (this, u.format); |
426 switch (u.format) { | 426 switch (u.format) { |
427 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 427 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
428 default:return TRACE_RETURN (c->default_return_value ()); | 428 default:return TRACE_RETURN (c->default_return_value ()); |
429 } | 429 } |
430 } | 430 } |
431 | 431 |
432 inline bool sanitize (hb_sanitize_context_t *c) { | 432 inline bool sanitize (hb_sanitize_context_t *c) { |
433 TRACE_SANITIZE (this); | 433 TRACE_SANITIZE (this); |
434 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 434 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
435 switch (u.format) { | 435 switch (u.format) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 u.format.set (format); | 566 u.format.set (format); |
567 switch (u.format) { | 567 switch (u.format) { |
568 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, alternate_len_l
ist, num_glyphs, alternate_glyphs_list)); | 568 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, alternate_len_l
ist, num_glyphs, alternate_glyphs_list)); |
569 default:return TRACE_RETURN (false); | 569 default:return TRACE_RETURN (false); |
570 } | 570 } |
571 } | 571 } |
572 | 572 |
573 template <typename context_t> | 573 template <typename context_t> |
574 inline typename context_t::return_t dispatch (context_t *c) const | 574 inline typename context_t::return_t dispatch (context_t *c) const |
575 { | 575 { |
576 TRACE_DISPATCH (this); | 576 TRACE_DISPATCH (this, u.format); |
577 switch (u.format) { | 577 switch (u.format) { |
578 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 578 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
579 default:return TRACE_RETURN (c->default_return_value ()); | 579 default:return TRACE_RETURN (c->default_return_value ()); |
580 } | 580 } |
581 } | 581 } |
582 | 582 |
583 inline bool sanitize (hb_sanitize_context_t *c) { | 583 inline bool sanitize (hb_sanitize_context_t *c) { |
584 TRACE_SANITIZE (this); | 584 TRACE_SANITIZE (this); |
585 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 585 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
586 switch (u.format) { | 586 switch (u.format) { |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 switch (u.format) { | 882 switch (u.format) { |
883 case 1: return TRACE_RETURN (u.format1.serialize (c, first_glyphs, ligature_
per_first_glyph_count_list, num_first_glyphs, | 883 case 1: return TRACE_RETURN (u.format1.serialize (c, first_glyphs, ligature_
per_first_glyph_count_list, num_first_glyphs, |
884 ligatures_list, component_
count_list, component_list)); | 884 ligatures_list, component_
count_list, component_list)); |
885 default:return TRACE_RETURN (false); | 885 default:return TRACE_RETURN (false); |
886 } | 886 } |
887 } | 887 } |
888 | 888 |
889 template <typename context_t> | 889 template <typename context_t> |
890 inline typename context_t::return_t dispatch (context_t *c) const | 890 inline typename context_t::return_t dispatch (context_t *c) const |
891 { | 891 { |
892 TRACE_DISPATCH (this); | 892 TRACE_DISPATCH (this, u.format); |
893 switch (u.format) { | 893 switch (u.format) { |
894 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 894 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
895 default:return TRACE_RETURN (c->default_return_value ()); | 895 default:return TRACE_RETURN (c->default_return_value ()); |
896 } | 896 } |
897 } | 897 } |
898 | 898 |
899 inline bool sanitize (hb_sanitize_context_t *c) { | 899 inline bool sanitize (hb_sanitize_context_t *c) { |
900 TRACE_SANITIZE (this); | 900 TRACE_SANITIZE (this); |
901 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 901 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
902 switch (u.format) { | 902 switch (u.format) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 * GlyphIDs--ordered by Coverage Index *
/ | 1046 * GlyphIDs--ordered by Coverage Index *
/ |
1047 public: | 1047 public: |
1048 DEFINE_SIZE_MIN (10); | 1048 DEFINE_SIZE_MIN (10); |
1049 }; | 1049 }; |
1050 | 1050 |
1051 struct ReverseChainSingleSubst | 1051 struct ReverseChainSingleSubst |
1052 { | 1052 { |
1053 template <typename context_t> | 1053 template <typename context_t> |
1054 inline typename context_t::return_t dispatch (context_t *c) const | 1054 inline typename context_t::return_t dispatch (context_t *c) const |
1055 { | 1055 { |
1056 TRACE_DISPATCH (this); | 1056 TRACE_DISPATCH (this, u.format); |
1057 switch (u.format) { | 1057 switch (u.format) { |
1058 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 1058 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
1059 default:return TRACE_RETURN (c->default_return_value ()); | 1059 default:return TRACE_RETURN (c->default_return_value ()); |
1060 } | 1060 } |
1061 } | 1061 } |
1062 | 1062 |
1063 inline bool sanitize (hb_sanitize_context_t *c) { | 1063 inline bool sanitize (hb_sanitize_context_t *c) { |
1064 TRACE_SANITIZE (this); | 1064 TRACE_SANITIZE (this); |
1065 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 1065 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
1066 switch (u.format) { | 1066 switch (u.format) { |
(...skipping 26 matching lines...) Expand all Loading... |
1093 Ligature = 4, | 1093 Ligature = 4, |
1094 Context = 5, | 1094 Context = 5, |
1095 ChainContext = 6, | 1095 ChainContext = 6, |
1096 Extension = 7, | 1096 Extension = 7, |
1097 ReverseChainSingle = 8 | 1097 ReverseChainSingle = 8 |
1098 }; | 1098 }; |
1099 | 1099 |
1100 template <typename context_t> | 1100 template <typename context_t> |
1101 inline typename context_t::return_t dispatch (context_t *c, unsigned int looku
p_type) const | 1101 inline typename context_t::return_t dispatch (context_t *c, unsigned int looku
p_type) const |
1102 { | 1102 { |
1103 TRACE_DISPATCH (this); | 1103 TRACE_DISPATCH (this, lookup_type); |
1104 switch (lookup_type) { | 1104 switch (lookup_type) { |
1105 case Single: return TRACE_RETURN (u.single.dispatch (c)); | 1105 case Single: return TRACE_RETURN (u.single.dispatch (c)); |
1106 case Multiple: return TRACE_RETURN (u.multiple.dispatch (c)); | 1106 case Multiple: return TRACE_RETURN (u.multiple.dispatch (c)); |
1107 case Alternate: return TRACE_RETURN (u.alternate.dispatch (c)); | 1107 case Alternate: return TRACE_RETURN (u.alternate.dispatch (c)); |
1108 case Ligature: return TRACE_RETURN (u.ligature.dispatch (c)); | 1108 case Ligature: return TRACE_RETURN (u.ligature.dispatch (c)); |
1109 case Context: return TRACE_RETURN (u.context.dispatch (c)); | 1109 case Context: return TRACE_RETURN (u.context.dispatch (c)); |
1110 case ChainContext: return TRACE_RETURN (u.chainContext.dispatch (c)
); | 1110 case ChainContext: return TRACE_RETURN (u.chainContext.dispatch (c)
); |
1111 case Extension: return TRACE_RETURN (u.extension.dispatch (c)); | 1111 case Extension: return TRACE_RETURN (u.extension.dispatch (c)); |
1112 case ReverseChainSingle: return TRACE_RETURN (u.reverseChainContextSingle
.dispatch (c)); | 1112 case ReverseChainSingle: return TRACE_RETURN (u.reverseChainContextSingle
.dispatch (c)); |
1113 default: return TRACE_RETURN (c->default_return_value ())
; | 1113 default: return TRACE_RETURN (c->default_return_value ())
; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 return TRACE_RETURN (serialize_subtable (c, 0).u.ligature.serialize (c, firs
t_glyphs, ligature_per_first_glyph_count_list, num_first_glyphs, | 1268 return TRACE_RETURN (serialize_subtable (c, 0).u.ligature.serialize (c, firs
t_glyphs, ligature_per_first_glyph_count_list, num_first_glyphs, |
1269 ligatur
es_list, component_count_list, component_list)); | 1269 ligatur
es_list, component_count_list, component_list)); |
1270 } | 1270 } |
1271 | 1271 |
1272 template <typename context_t> | 1272 template <typename context_t> |
1273 static inline typename context_t::return_t dispatch_recurse_func (context_t *c
, unsigned int lookup_index); | 1273 static inline typename context_t::return_t dispatch_recurse_func (context_t *c
, unsigned int lookup_index); |
1274 | 1274 |
1275 template <typename context_t> | 1275 template <typename context_t> |
1276 inline typename context_t::return_t dispatch (context_t *c) const | 1276 inline typename context_t::return_t dispatch (context_t *c) const |
1277 { | 1277 { |
1278 TRACE_DISPATCH (this); | |
1279 unsigned int lookup_type = get_type (); | 1278 unsigned int lookup_type = get_type (); |
| 1279 TRACE_DISPATCH (this, lookup_type); |
1280 unsigned int count = get_subtable_count (); | 1280 unsigned int count = get_subtable_count (); |
1281 for (unsigned int i = 0; i < count; i++) { | 1281 for (unsigned int i = 0; i < count; i++) { |
1282 typename context_t::return_t r = get_subtable (i).dispatch (c, lookup_type
); | 1282 typename context_t::return_t r = get_subtable (i).dispatch (c, lookup_type
); |
1283 if (c->stop_sublookup_iteration (r)) | 1283 if (c->stop_sublookup_iteration (r)) |
1284 return TRACE_RETURN (r); | 1284 return TRACE_RETURN (r); |
1285 } | 1285 } |
1286 return TRACE_RETURN (c->default_return_value ()); | 1286 return TRACE_RETURN (c->default_return_value ()); |
1287 } | 1287 } |
1288 | 1288 |
1289 inline bool sanitize (hb_sanitize_context_t *c) | 1289 inline bool sanitize (hb_sanitize_context_t *c) |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 bool ret = l.apply_once (c); | 1383 bool ret = l.apply_once (c); |
1384 c->lookup_props = saved_lookup_props; | 1384 c->lookup_props = saved_lookup_props; |
1385 return ret; | 1385 return ret; |
1386 } | 1386 } |
1387 | 1387 |
1388 | 1388 |
1389 } /* namespace OT */ | 1389 } /* namespace OT */ |
1390 | 1390 |
1391 | 1391 |
1392 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ | 1392 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ |
OLD | NEW |