| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 inline const Coverage &get_coverage (void) const | 62 inline const Coverage &get_coverage (void) const |
| 63 { | 63 { |
| 64 return this+coverage; | 64 return this+coverage; |
| 65 } | 65 } |
| 66 | 66 |
| 67 inline bool would_apply (hb_would_apply_context_t *c) const | 67 inline bool would_apply (hb_would_apply_context_t *c) const |
| 68 { | 68 { |
| 69 TRACE_WOULD_APPLY (this); | 69 TRACE_WOULD_APPLY (this); |
| 70 return TRACE_RETURN (c->len == 1 && (this+coverage).get_coverage (c->glyphs[
0]) != NOT_COVERED); | 70 return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) !=
NOT_COVERED); |
| 71 } | 71 } |
| 72 | 72 |
| 73 inline bool apply (hb_apply_context_t *c) const | 73 inline bool apply (hb_apply_context_t *c) const |
| 74 { | 74 { |
| 75 TRACE_APPLY (this); | 75 TRACE_APPLY (this); |
| 76 hb_codepoint_t glyph_id = c->buffer->cur().codepoint; | 76 hb_codepoint_t glyph_id = c->buffer->cur().codepoint; |
| 77 unsigned int index = (this+coverage).get_coverage (glyph_id); | 77 unsigned int index = (this+coverage).get_coverage (glyph_id); |
| 78 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 78 if (likely (index == NOT_COVERED)) return_trace (false); |
| 79 | 79 |
| 80 /* According to the Adobe Annotated OpenType Suite, result is always | 80 /* According to the Adobe Annotated OpenType Suite, result is always |
| 81 * limited to 16bit. */ | 81 * limited to 16bit. */ |
| 82 glyph_id = (glyph_id + deltaGlyphID) & 0xFFFFu; | 82 glyph_id = (glyph_id + deltaGlyphID) & 0xFFFFu; |
| 83 c->replace_glyph (glyph_id); | 83 c->replace_glyph (glyph_id); |
| 84 | 84 |
| 85 return TRACE_RETURN (true); | 85 return_trace (true); |
| 86 } | 86 } |
| 87 | 87 |
| 88 inline bool serialize (hb_serialize_context_t *c, | 88 inline bool serialize (hb_serialize_context_t *c, |
| 89 Supplier<GlyphID> &glyphs, | 89 Supplier<GlyphID> &glyphs, |
| 90 unsigned int num_glyphs, | 90 unsigned int num_glyphs, |
| 91 int delta) | 91 int delta) |
| 92 { | 92 { |
| 93 TRACE_SERIALIZE (this); | 93 TRACE_SERIALIZE (this); |
| 94 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 94 if (unlikely (!c->extend_min (*this))) return_trace (false); |
| 95 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); | 95 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return_trace (false); |
| 96 deltaGlyphID.set (delta); /* TODO(serilaize) overflow? */ | 96 deltaGlyphID.set (delta); /* TODO(serilaize) overflow? */ |
| 97 return TRACE_RETURN (true); | 97 return_trace (true); |
| 98 } | 98 } |
| 99 | 99 |
| 100 inline bool sanitize (hb_sanitize_context_t *c) const | 100 inline bool sanitize (hb_sanitize_context_t *c) const |
| 101 { | 101 { |
| 102 TRACE_SANITIZE (this); | 102 TRACE_SANITIZE (this); |
| 103 return TRACE_RETURN (coverage.sanitize (c, this) && deltaGlyphID.sanitize (c
)); | 103 return_trace (coverage.sanitize (c, this) && deltaGlyphID.sanitize (c)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 protected: | 106 protected: |
| 107 USHORT format; /* Format identifier--format = 1 */ | 107 USHORT format; /* Format identifier--format = 1 */ |
| 108 OffsetTo<Coverage> | 108 OffsetTo<Coverage> |
| 109 coverage; /* Offset to Coverage table--from | 109 coverage; /* Offset to Coverage table--from |
| 110 * beginning of Substitution table */ | 110 * beginning of Substitution table */ |
| 111 SHORT deltaGlyphID; /* Add to original GlyphID to get | 111 SHORT deltaGlyphID; /* Add to original GlyphID to get |
| 112 * substitute GlyphID */ | 112 * substitute GlyphID */ |
| 113 public: | 113 public: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 137 } | 137 } |
| 138 | 138 |
| 139 inline const Coverage &get_coverage (void) const | 139 inline const Coverage &get_coverage (void) const |
| 140 { | 140 { |
| 141 return this+coverage; | 141 return this+coverage; |
| 142 } | 142 } |
| 143 | 143 |
| 144 inline bool would_apply (hb_would_apply_context_t *c) const | 144 inline bool would_apply (hb_would_apply_context_t *c) const |
| 145 { | 145 { |
| 146 TRACE_WOULD_APPLY (this); | 146 TRACE_WOULD_APPLY (this); |
| 147 return TRACE_RETURN (c->len == 1 && (this+coverage).get_coverage (c->glyphs[
0]) != NOT_COVERED); | 147 return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) !=
NOT_COVERED); |
| 148 } | 148 } |
| 149 | 149 |
| 150 inline bool apply (hb_apply_context_t *c) const | 150 inline bool apply (hb_apply_context_t *c) const |
| 151 { | 151 { |
| 152 TRACE_APPLY (this); | 152 TRACE_APPLY (this); |
| 153 hb_codepoint_t glyph_id = c->buffer->cur().codepoint; | 153 hb_codepoint_t glyph_id = c->buffer->cur().codepoint; |
| 154 unsigned int index = (this+coverage).get_coverage (glyph_id); | 154 unsigned int index = (this+coverage).get_coverage (glyph_id); |
| 155 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 155 if (likely (index == NOT_COVERED)) return_trace (false); |
| 156 | 156 |
| 157 if (unlikely (index >= substitute.len)) return TRACE_RETURN (false); | 157 if (unlikely (index >= substitute.len)) return_trace (false); |
| 158 | 158 |
| 159 glyph_id = substitute[index]; | 159 glyph_id = substitute[index]; |
| 160 c->replace_glyph (glyph_id); | 160 c->replace_glyph (glyph_id); |
| 161 | 161 |
| 162 return TRACE_RETURN (true); | 162 return_trace (true); |
| 163 } | 163 } |
| 164 | 164 |
| 165 inline bool serialize (hb_serialize_context_t *c, | 165 inline bool serialize (hb_serialize_context_t *c, |
| 166 Supplier<GlyphID> &glyphs, | 166 Supplier<GlyphID> &glyphs, |
| 167 Supplier<GlyphID> &substitutes, | 167 Supplier<GlyphID> &substitutes, |
| 168 unsigned int num_glyphs) | 168 unsigned int num_glyphs) |
| 169 { | 169 { |
| 170 TRACE_SERIALIZE (this); | 170 TRACE_SERIALIZE (this); |
| 171 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 171 if (unlikely (!c->extend_min (*this))) return_trace (false); |
| 172 if (unlikely (!substitute.serialize (c, substitutes, num_glyphs))) return TR
ACE_RETURN (false); | 172 if (unlikely (!substitute.serialize (c, substitutes, num_glyphs))) return_tr
ace (false); |
| 173 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); | 173 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return_trace (false); |
| 174 return TRACE_RETURN (true); | 174 return_trace (true); |
| 175 } | 175 } |
| 176 | 176 |
| 177 inline bool sanitize (hb_sanitize_context_t *c) const | 177 inline bool sanitize (hb_sanitize_context_t *c) const |
| 178 { | 178 { |
| 179 TRACE_SANITIZE (this); | 179 TRACE_SANITIZE (this); |
| 180 return TRACE_RETURN (coverage.sanitize (c, this) && substitute.sanitize (c))
; | 180 return_trace (coverage.sanitize (c, this) && substitute.sanitize (c)); |
| 181 } | 181 } |
| 182 | 182 |
| 183 protected: | 183 protected: |
| 184 USHORT format; /* Format identifier--format = 2 */ | 184 USHORT format; /* Format identifier--format = 2 */ |
| 185 OffsetTo<Coverage> | 185 OffsetTo<Coverage> |
| 186 coverage; /* Offset to Coverage table--from | 186 coverage; /* Offset to Coverage table--from |
| 187 * beginning of Substitution table */ | 187 * beginning of Substitution table */ |
| 188 ArrayOf<GlyphID> | 188 ArrayOf<GlyphID> |
| 189 substitute; /* Array of substitute | 189 substitute; /* Array of substitute |
| 190 * GlyphIDs--ordered by Coverage Index *
/ | 190 * GlyphIDs--ordered by Coverage Index *
/ |
| 191 public: | 191 public: |
| 192 DEFINE_SIZE_ARRAY (6, substitute); | 192 DEFINE_SIZE_ARRAY (6, substitute); |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 struct SingleSubst | 195 struct SingleSubst |
| 196 { | 196 { |
| 197 inline bool serialize (hb_serialize_context_t *c, | 197 inline bool serialize (hb_serialize_context_t *c, |
| 198 Supplier<GlyphID> &glyphs, | 198 Supplier<GlyphID> &glyphs, |
| 199 Supplier<GlyphID> &substitutes, | 199 Supplier<GlyphID> &substitutes, |
| 200 unsigned int num_glyphs) | 200 unsigned int num_glyphs) |
| 201 { | 201 { |
| 202 TRACE_SERIALIZE (this); | 202 TRACE_SERIALIZE (this); |
| 203 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); | 203 if (unlikely (!c->extend_min (u.format))) return_trace (false); |
| 204 unsigned int format = 2; | 204 unsigned int format = 2; |
| 205 int delta = 0; | 205 int delta = 0; |
| 206 if (num_glyphs) { | 206 if (num_glyphs) { |
| 207 format = 1; | 207 format = 1; |
| 208 /* TODO(serialize) check for wrap-around */ | 208 /* TODO(serialize) check for wrap-around */ |
| 209 delta = substitutes[0] - glyphs[0]; | 209 delta = substitutes[0] - glyphs[0]; |
| 210 for (unsigned int i = 1; i < num_glyphs; i++) | 210 for (unsigned int i = 1; i < num_glyphs; i++) |
| 211 if (delta != substitutes[i] - glyphs[i]) { | 211 if (delta != substitutes[i] - glyphs[i]) { |
| 212 format = 2; | 212 format = 2; |
| 213 break; | 213 break; |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 u.format.set (format); | 216 u.format.set (format); |
| 217 switch (u.format) { | 217 switch (u.format) { |
| 218 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, num_glyphs, del
ta)); | 218 case 1: return_trace (u.format1.serialize (c, glyphs, num_glyphs, delta)); |
| 219 case 2: return TRACE_RETURN (u.format2.serialize (c, glyphs, substitutes, nu
m_glyphs)); | 219 case 2: return_trace (u.format2.serialize (c, glyphs, substitutes, num_glyph
s)); |
| 220 default:return TRACE_RETURN (false); | 220 default:return_trace (false); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 template <typename context_t> | 224 template <typename context_t> |
| 225 inline typename context_t::return_t dispatch (context_t *c) const | 225 inline typename context_t::return_t dispatch (context_t *c) const |
| 226 { | 226 { |
| 227 TRACE_DISPATCH (this, u.format); | 227 TRACE_DISPATCH (this, u.format); |
| 228 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); | 228 if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispa
tch_return_value ()); |
| 229 switch (u.format) { | 229 switch (u.format) { |
| 230 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 230 case 1: return_trace (c->dispatch (u.format1)); |
| 231 case 2: return TRACE_RETURN (c->dispatch (u.format2)); | 231 case 2: return_trace (c->dispatch (u.format2)); |
| 232 default:return TRACE_RETURN (c->default_return_value ()); | 232 default:return_trace (c->default_return_value ()); |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 protected: | 236 protected: |
| 237 union { | 237 union { |
| 238 USHORT format; /* Format identifier */ | 238 USHORT format; /* Format identifier */ |
| 239 SingleSubstFormat1 format1; | 239 SingleSubstFormat1 format1; |
| 240 SingleSubstFormat2 format2; | 240 SingleSubstFormat2 format2; |
| 241 } u; | 241 } u; |
| 242 }; | 242 }; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 266 unsigned int count = substitute.len; | 266 unsigned int count = substitute.len; |
| 267 | 267 |
| 268 /* TODO: | 268 /* TODO: |
| 269 * Testing shows that Uniscribe actually allows zero-len susbstitute, | 269 * Testing shows that Uniscribe actually allows zero-len susbstitute, |
| 270 * which essentially deletes a glyph. We don't allow for now. It | 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 | 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 | 272 * glyph won't be merged with any output cluster... Also, currently |
| 273 * buffer->move_to() makes assumptions about this too. Perhaps fix | 273 * buffer->move_to() makes assumptions about this too. Perhaps fix |
| 274 * in the future after figuring out what to do with the clusters. | 274 * in the future after figuring out what to do with the clusters. |
| 275 */ | 275 */ |
| 276 if (unlikely (!count)) return TRACE_RETURN (false); | 276 if (unlikely (!count)) return_trace (false); |
| 277 | 277 |
| 278 /* Special-case to make it in-place and not consider this | 278 /* Special-case to make it in-place and not consider this |
| 279 * as a "multiplied" substitution. */ | 279 * as a "multiplied" substitution. */ |
| 280 if (unlikely (count == 1)) | 280 if (unlikely (count == 1)) |
| 281 { | 281 { |
| 282 c->replace_glyph (substitute.array[0]); | 282 c->replace_glyph (substitute.array[0]); |
| 283 return TRACE_RETURN (true); | 283 return_trace (true); |
| 284 } | 284 } |
| 285 | 285 |
| 286 unsigned int klass = _hb_glyph_info_is_ligature (&c->buffer->cur()) ? | 286 unsigned int klass = _hb_glyph_info_is_ligature (&c->buffer->cur()) ? |
| 287 HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0; | 287 HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0; |
| 288 | 288 |
| 289 for (unsigned int i = 0; i < count; i++) { | 289 for (unsigned int i = 0; i < count; i++) { |
| 290 _hb_glyph_info_set_lig_props_for_component (&c->buffer->cur(), i); | 290 _hb_glyph_info_set_lig_props_for_component (&c->buffer->cur(), i); |
| 291 c->output_glyph_for_component (substitute.array[i], klass); | 291 c->output_glyph_for_component (substitute.array[i], klass); |
| 292 } | 292 } |
| 293 c->buffer->skip_glyph (); | 293 c->buffer->skip_glyph (); |
| 294 | 294 |
| 295 return TRACE_RETURN (true); | 295 return_trace (true); |
| 296 } | 296 } |
| 297 | 297 |
| 298 inline bool serialize (hb_serialize_context_t *c, | 298 inline bool serialize (hb_serialize_context_t *c, |
| 299 Supplier<GlyphID> &glyphs, | 299 Supplier<GlyphID> &glyphs, |
| 300 unsigned int num_glyphs) | 300 unsigned int num_glyphs) |
| 301 { | 301 { |
| 302 TRACE_SERIALIZE (this); | 302 TRACE_SERIALIZE (this); |
| 303 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 303 if (unlikely (!c->extend_min (*this))) return_trace (false); |
| 304 if (unlikely (!substitute.serialize (c, glyphs, num_glyphs))) return TRACE_R
ETURN (false); | 304 if (unlikely (!substitute.serialize (c, glyphs, num_glyphs))) return_trace (
false); |
| 305 return TRACE_RETURN (true); | 305 return_trace (true); |
| 306 } | 306 } |
| 307 | 307 |
| 308 inline bool sanitize (hb_sanitize_context_t *c) const | 308 inline bool sanitize (hb_sanitize_context_t *c) const |
| 309 { | 309 { |
| 310 TRACE_SANITIZE (this); | 310 TRACE_SANITIZE (this); |
| 311 return TRACE_RETURN (substitute.sanitize (c)); | 311 return_trace (substitute.sanitize (c)); |
| 312 } | 312 } |
| 313 | 313 |
| 314 protected: | 314 protected: |
| 315 ArrayOf<GlyphID> | 315 ArrayOf<GlyphID> |
| 316 substitute; /* String of GlyphIDs to substitute */ | 316 substitute; /* String of GlyphIDs to substitute */ |
| 317 public: | 317 public: |
| 318 DEFINE_SIZE_ARRAY (2, substitute); | 318 DEFINE_SIZE_ARRAY (2, substitute); |
| 319 }; | 319 }; |
| 320 | 320 |
| 321 struct MultipleSubstFormat1 | 321 struct MultipleSubstFormat1 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 340 } | 340 } |
| 341 | 341 |
| 342 inline const Coverage &get_coverage (void) const | 342 inline const Coverage &get_coverage (void) const |
| 343 { | 343 { |
| 344 return this+coverage; | 344 return this+coverage; |
| 345 } | 345 } |
| 346 | 346 |
| 347 inline bool would_apply (hb_would_apply_context_t *c) const | 347 inline bool would_apply (hb_would_apply_context_t *c) const |
| 348 { | 348 { |
| 349 TRACE_WOULD_APPLY (this); | 349 TRACE_WOULD_APPLY (this); |
| 350 return TRACE_RETURN (c->len == 1 && (this+coverage).get_coverage (c->glyphs[
0]) != NOT_COVERED); | 350 return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) !=
NOT_COVERED); |
| 351 } | 351 } |
| 352 | 352 |
| 353 inline bool apply (hb_apply_context_t *c) const | 353 inline bool apply (hb_apply_context_t *c) const |
| 354 { | 354 { |
| 355 TRACE_APPLY (this); | 355 TRACE_APPLY (this); |
| 356 | 356 |
| 357 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); | 357 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); |
| 358 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 358 if (likely (index == NOT_COVERED)) return_trace (false); |
| 359 | 359 |
| 360 return TRACE_RETURN ((this+sequence[index]).apply (c)); | 360 return_trace ((this+sequence[index]).apply (c)); |
| 361 } | 361 } |
| 362 | 362 |
| 363 inline bool serialize (hb_serialize_context_t *c, | 363 inline bool serialize (hb_serialize_context_t *c, |
| 364 Supplier<GlyphID> &glyphs, | 364 Supplier<GlyphID> &glyphs, |
| 365 Supplier<unsigned int> &substitute_len_list, | 365 Supplier<unsigned int> &substitute_len_list, |
| 366 unsigned int num_glyphs, | 366 unsigned int num_glyphs, |
| 367 Supplier<GlyphID> &substitute_glyphs_list) | 367 Supplier<GlyphID> &substitute_glyphs_list) |
| 368 { | 368 { |
| 369 TRACE_SERIALIZE (this); | 369 TRACE_SERIALIZE (this); |
| 370 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 370 if (unlikely (!c->extend_min (*this))) return_trace (false); |
| 371 if (unlikely (!sequence.serialize (c, num_glyphs))) return TRACE_RETURN (fal
se); | 371 if (unlikely (!sequence.serialize (c, num_glyphs))) return_trace (false); |
| 372 for (unsigned int i = 0; i < num_glyphs; i++) | 372 for (unsigned int i = 0; i < num_glyphs; i++) |
| 373 if (unlikely (!sequence[i].serialize (c, this).serialize (c, | 373 if (unlikely (!sequence[i].serialize (c, this).serialize (c, |
| 374 substitute_glyph
s_list, | 374 substitute_glyph
s_list, |
| 375 » » » » » » » » substitute_len_l
ist[i]))) return TRACE_RETURN (false); | 375 » » » » » » » » substitute_len_l
ist[i]))) return_trace (false); |
| 376 substitute_len_list.advance (num_glyphs); | 376 substitute_len_list.advance (num_glyphs); |
| 377 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); | 377 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return_trace (false); |
| 378 return TRACE_RETURN (true); | 378 return_trace (true); |
| 379 } | 379 } |
| 380 | 380 |
| 381 inline bool sanitize (hb_sanitize_context_t *c) const | 381 inline bool sanitize (hb_sanitize_context_t *c) const |
| 382 { | 382 { |
| 383 TRACE_SANITIZE (this); | 383 TRACE_SANITIZE (this); |
| 384 return TRACE_RETURN (coverage.sanitize (c, this) && sequence.sanitize (c, th
is)); | 384 return_trace (coverage.sanitize (c, this) && sequence.sanitize (c, this)); |
| 385 } | 385 } |
| 386 | 386 |
| 387 protected: | 387 protected: |
| 388 USHORT format; /* Format identifier--format = 1 */ | 388 USHORT format; /* Format identifier--format = 1 */ |
| 389 OffsetTo<Coverage> | 389 OffsetTo<Coverage> |
| 390 coverage; /* Offset to Coverage table--from | 390 coverage; /* Offset to Coverage table--from |
| 391 * beginning of Substitution table */ | 391 * beginning of Substitution table */ |
| 392 OffsetArrayOf<Sequence> | 392 OffsetArrayOf<Sequence> |
| 393 sequence; /* Array of Sequence tables | 393 sequence; /* Array of Sequence tables |
| 394 * ordered by Coverage Index */ | 394 * ordered by Coverage Index */ |
| 395 public: | 395 public: |
| 396 DEFINE_SIZE_ARRAY (6, sequence); | 396 DEFINE_SIZE_ARRAY (6, sequence); |
| 397 }; | 397 }; |
| 398 | 398 |
| 399 struct MultipleSubst | 399 struct MultipleSubst |
| 400 { | 400 { |
| 401 inline bool serialize (hb_serialize_context_t *c, | 401 inline bool serialize (hb_serialize_context_t *c, |
| 402 Supplier<GlyphID> &glyphs, | 402 Supplier<GlyphID> &glyphs, |
| 403 Supplier<unsigned int> &substitute_len_list, | 403 Supplier<unsigned int> &substitute_len_list, |
| 404 unsigned int num_glyphs, | 404 unsigned int num_glyphs, |
| 405 Supplier<GlyphID> &substitute_glyphs_list) | 405 Supplier<GlyphID> &substitute_glyphs_list) |
| 406 { | 406 { |
| 407 TRACE_SERIALIZE (this); | 407 TRACE_SERIALIZE (this); |
| 408 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); | 408 if (unlikely (!c->extend_min (u.format))) return_trace (false); |
| 409 unsigned int format = 1; | 409 unsigned int format = 1; |
| 410 u.format.set (format); | 410 u.format.set (format); |
| 411 switch (u.format) { | 411 switch (u.format) { |
| 412 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, substitute_len_
list, num_glyphs, substitute_glyphs_list)); | 412 case 1: return_trace (u.format1.serialize (c, glyphs, substitute_len_list, n
um_glyphs, substitute_glyphs_list)); |
| 413 default:return TRACE_RETURN (false); | 413 default:return_trace (false); |
| 414 } | 414 } |
| 415 } | 415 } |
| 416 | 416 |
| 417 template <typename context_t> | 417 template <typename context_t> |
| 418 inline typename context_t::return_t dispatch (context_t *c) const | 418 inline typename context_t::return_t dispatch (context_t *c) const |
| 419 { | 419 { |
| 420 TRACE_DISPATCH (this, u.format); | 420 TRACE_DISPATCH (this, u.format); |
| 421 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); | 421 if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispa
tch_return_value ()); |
| 422 switch (u.format) { | 422 switch (u.format) { |
| 423 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 423 case 1: return_trace (c->dispatch (u.format1)); |
| 424 default:return TRACE_RETURN (c->default_return_value ()); | 424 default:return_trace (c->default_return_value ()); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 | 427 |
| 428 protected: | 428 protected: |
| 429 union { | 429 union { |
| 430 USHORT format; /* Format identifier */ | 430 USHORT format; /* Format identifier */ |
| 431 MultipleSubstFormat1 format1; | 431 MultipleSubstFormat1 format1; |
| 432 } u; | 432 } u; |
| 433 }; | 433 }; |
| 434 | 434 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 } | 466 } |
| 467 | 467 |
| 468 inline const Coverage &get_coverage (void) const | 468 inline const Coverage &get_coverage (void) const |
| 469 { | 469 { |
| 470 return this+coverage; | 470 return this+coverage; |
| 471 } | 471 } |
| 472 | 472 |
| 473 inline bool would_apply (hb_would_apply_context_t *c) const | 473 inline bool would_apply (hb_would_apply_context_t *c) const |
| 474 { | 474 { |
| 475 TRACE_WOULD_APPLY (this); | 475 TRACE_WOULD_APPLY (this); |
| 476 return TRACE_RETURN (c->len == 1 && (this+coverage).get_coverage (c->glyphs[
0]) != NOT_COVERED); | 476 return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) !=
NOT_COVERED); |
| 477 } | 477 } |
| 478 | 478 |
| 479 inline bool apply (hb_apply_context_t *c) const | 479 inline bool apply (hb_apply_context_t *c) const |
| 480 { | 480 { |
| 481 TRACE_APPLY (this); | 481 TRACE_APPLY (this); |
| 482 hb_codepoint_t glyph_id = c->buffer->cur().codepoint; | 482 hb_codepoint_t glyph_id = c->buffer->cur().codepoint; |
| 483 | 483 |
| 484 unsigned int index = (this+coverage).get_coverage (glyph_id); | 484 unsigned int index = (this+coverage).get_coverage (glyph_id); |
| 485 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 485 if (likely (index == NOT_COVERED)) return_trace (false); |
| 486 | 486 |
| 487 const AlternateSet &alt_set = this+alternateSet[index]; | 487 const AlternateSet &alt_set = this+alternateSet[index]; |
| 488 | 488 |
| 489 if (unlikely (!alt_set.len)) return TRACE_RETURN (false); | 489 if (unlikely (!alt_set.len)) return_trace (false); |
| 490 | 490 |
| 491 hb_mask_t glyph_mask = c->buffer->cur().mask; | 491 hb_mask_t glyph_mask = c->buffer->cur().mask; |
| 492 hb_mask_t lookup_mask = c->lookup_mask; | 492 hb_mask_t lookup_mask = c->lookup_mask; |
| 493 | 493 |
| 494 /* Note: This breaks badly if two features enabled this lookup together. */ | 494 /* Note: This breaks badly if two features enabled this lookup together. */ |
| 495 unsigned int shift = _hb_ctz (lookup_mask); | 495 unsigned int shift = _hb_ctz (lookup_mask); |
| 496 unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift); | 496 unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift); |
| 497 | 497 |
| 498 if (unlikely (alt_index > alt_set.len || alt_index == 0)) return TRACE_RETUR
N (false); | 498 if (unlikely (alt_index > alt_set.len || alt_index == 0)) return_trace (fals
e); |
| 499 | 499 |
| 500 glyph_id = alt_set[alt_index - 1]; | 500 glyph_id = alt_set[alt_index - 1]; |
| 501 | 501 |
| 502 c->replace_glyph (glyph_id); | 502 c->replace_glyph (glyph_id); |
| 503 | 503 |
| 504 return TRACE_RETURN (true); | 504 return_trace (true); |
| 505 } | 505 } |
| 506 | 506 |
| 507 inline bool serialize (hb_serialize_context_t *c, | 507 inline bool serialize (hb_serialize_context_t *c, |
| 508 Supplier<GlyphID> &glyphs, | 508 Supplier<GlyphID> &glyphs, |
| 509 Supplier<unsigned int> &alternate_len_list, | 509 Supplier<unsigned int> &alternate_len_list, |
| 510 unsigned int num_glyphs, | 510 unsigned int num_glyphs, |
| 511 Supplier<GlyphID> &alternate_glyphs_list) | 511 Supplier<GlyphID> &alternate_glyphs_list) |
| 512 { | 512 { |
| 513 TRACE_SERIALIZE (this); | 513 TRACE_SERIALIZE (this); |
| 514 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 514 if (unlikely (!c->extend_min (*this))) return_trace (false); |
| 515 if (unlikely (!alternateSet.serialize (c, num_glyphs))) return TRACE_RETURN
(false); | 515 if (unlikely (!alternateSet.serialize (c, num_glyphs))) return_trace (false)
; |
| 516 for (unsigned int i = 0; i < num_glyphs; i++) | 516 for (unsigned int i = 0; i < num_glyphs; i++) |
| 517 if (unlikely (!alternateSet[i].serialize (c, this).serialize (c, | 517 if (unlikely (!alternateSet[i].serialize (c, this).serialize (c, |
| 518 alternate_gl
yphs_list, | 518 alternate_gl
yphs_list, |
| 519 » » » » » » » » alternate_le
n_list[i]))) return TRACE_RETURN (false); | 519 » » » » » » » » alternate_le
n_list[i]))) return_trace (false); |
| 520 alternate_len_list.advance (num_glyphs); | 520 alternate_len_list.advance (num_glyphs); |
| 521 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); | 521 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return_trace (false); |
| 522 return TRACE_RETURN (true); | 522 return_trace (true); |
| 523 } | 523 } |
| 524 | 524 |
| 525 inline bool sanitize (hb_sanitize_context_t *c) const | 525 inline bool sanitize (hb_sanitize_context_t *c) const |
| 526 { | 526 { |
| 527 TRACE_SANITIZE (this); | 527 TRACE_SANITIZE (this); |
| 528 return TRACE_RETURN (coverage.sanitize (c, this) && alternateSet.sanitize (c
, this)); | 528 return_trace (coverage.sanitize (c, this) && alternateSet.sanitize (c, this)
); |
| 529 } | 529 } |
| 530 | 530 |
| 531 protected: | 531 protected: |
| 532 USHORT format; /* Format identifier--format = 1 */ | 532 USHORT format; /* Format identifier--format = 1 */ |
| 533 OffsetTo<Coverage> | 533 OffsetTo<Coverage> |
| 534 coverage; /* Offset to Coverage table--from | 534 coverage; /* Offset to Coverage table--from |
| 535 * beginning of Substitution table */ | 535 * beginning of Substitution table */ |
| 536 OffsetArrayOf<AlternateSet> | 536 OffsetArrayOf<AlternateSet> |
| 537 alternateSet; /* Array of AlternateSet tables | 537 alternateSet; /* Array of AlternateSet tables |
| 538 * ordered by Coverage Index */ | 538 * ordered by Coverage Index */ |
| 539 public: | 539 public: |
| 540 DEFINE_SIZE_ARRAY (6, alternateSet); | 540 DEFINE_SIZE_ARRAY (6, alternateSet); |
| 541 }; | 541 }; |
| 542 | 542 |
| 543 struct AlternateSubst | 543 struct AlternateSubst |
| 544 { | 544 { |
| 545 inline bool serialize (hb_serialize_context_t *c, | 545 inline bool serialize (hb_serialize_context_t *c, |
| 546 Supplier<GlyphID> &glyphs, | 546 Supplier<GlyphID> &glyphs, |
| 547 Supplier<unsigned int> &alternate_len_list, | 547 Supplier<unsigned int> &alternate_len_list, |
| 548 unsigned int num_glyphs, | 548 unsigned int num_glyphs, |
| 549 Supplier<GlyphID> &alternate_glyphs_list) | 549 Supplier<GlyphID> &alternate_glyphs_list) |
| 550 { | 550 { |
| 551 TRACE_SERIALIZE (this); | 551 TRACE_SERIALIZE (this); |
| 552 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); | 552 if (unlikely (!c->extend_min (u.format))) return_trace (false); |
| 553 unsigned int format = 1; | 553 unsigned int format = 1; |
| 554 u.format.set (format); | 554 u.format.set (format); |
| 555 switch (u.format) { | 555 switch (u.format) { |
| 556 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, alternate_len_l
ist, num_glyphs, alternate_glyphs_list)); | 556 case 1: return_trace (u.format1.serialize (c, glyphs, alternate_len_list, nu
m_glyphs, alternate_glyphs_list)); |
| 557 default:return TRACE_RETURN (false); | 557 default:return_trace (false); |
| 558 } | 558 } |
| 559 } | 559 } |
| 560 | 560 |
| 561 template <typename context_t> | 561 template <typename context_t> |
| 562 inline typename context_t::return_t dispatch (context_t *c) const | 562 inline typename context_t::return_t dispatch (context_t *c) const |
| 563 { | 563 { |
| 564 TRACE_DISPATCH (this, u.format); | 564 TRACE_DISPATCH (this, u.format); |
| 565 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); | 565 if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispa
tch_return_value ()); |
| 566 switch (u.format) { | 566 switch (u.format) { |
| 567 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 567 case 1: return_trace (c->dispatch (u.format1)); |
| 568 default:return TRACE_RETURN (c->default_return_value ()); | 568 default:return_trace (c->default_return_value ()); |
| 569 } | 569 } |
| 570 } | 570 } |
| 571 | 571 |
| 572 protected: | 572 protected: |
| 573 union { | 573 union { |
| 574 USHORT format; /* Format identifier */ | 574 USHORT format; /* Format identifier */ |
| 575 AlternateSubstFormat1 format1; | 575 AlternateSubstFormat1 format1; |
| 576 } u; | 576 } u; |
| 577 }; | 577 }; |
| 578 | 578 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 595 unsigned int count = component.len; | 595 unsigned int count = component.len; |
| 596 for (unsigned int i = 1; i < count; i++) | 596 for (unsigned int i = 1; i < count; i++) |
| 597 c->input->add (component[i]); | 597 c->input->add (component[i]); |
| 598 c->output->add (ligGlyph); | 598 c->output->add (ligGlyph); |
| 599 } | 599 } |
| 600 | 600 |
| 601 inline bool would_apply (hb_would_apply_context_t *c) const | 601 inline bool would_apply (hb_would_apply_context_t *c) const |
| 602 { | 602 { |
| 603 TRACE_WOULD_APPLY (this); | 603 TRACE_WOULD_APPLY (this); |
| 604 if (c->len != component.len) | 604 if (c->len != component.len) |
| 605 return TRACE_RETURN (false); | 605 return_trace (false); |
| 606 | 606 |
| 607 for (unsigned int i = 1; i < c->len; i++) | 607 for (unsigned int i = 1; i < c->len; i++) |
| 608 if (likely (c->glyphs[i] != component[i])) | 608 if (likely (c->glyphs[i] != component[i])) |
| 609 » return TRACE_RETURN (false); | 609 » return_trace (false); |
| 610 | 610 |
| 611 return TRACE_RETURN (true); | 611 return_trace (true); |
| 612 } | 612 } |
| 613 | 613 |
| 614 inline bool apply (hb_apply_context_t *c) const | 614 inline bool apply (hb_apply_context_t *c) const |
| 615 { | 615 { |
| 616 TRACE_APPLY (this); | 616 TRACE_APPLY (this); |
| 617 unsigned int count = component.len; | 617 unsigned int count = component.len; |
| 618 | 618 |
| 619 if (unlikely (!count)) return TRACE_RETURN (false); | 619 if (unlikely (!count)) return_trace (false); |
| 620 | 620 |
| 621 /* Special-case to make it in-place and not consider this | 621 /* Special-case to make it in-place and not consider this |
| 622 * as a "ligated" substitution. */ | 622 * as a "ligated" substitution. */ |
| 623 if (unlikely (count == 1)) | 623 if (unlikely (count == 1)) |
| 624 { | 624 { |
| 625 c->replace_glyph (ligGlyph); | 625 c->replace_glyph (ligGlyph); |
| 626 return TRACE_RETURN (true); | 626 return_trace (true); |
| 627 } | 627 } |
| 628 | 628 |
| 629 bool is_mark_ligature = false; | 629 bool is_mark_ligature = false; |
| 630 unsigned int total_component_count = 0; | 630 unsigned int total_component_count = 0; |
| 631 | 631 |
| 632 unsigned int match_length = 0; | 632 unsigned int match_length = 0; |
| 633 unsigned int match_positions[MAX_CONTEXT_LENGTH]; | 633 unsigned int match_positions[MAX_CONTEXT_LENGTH]; |
| 634 | 634 |
| 635 if (likely (!match_input (c, count, | 635 if (likely (!match_input (c, count, |
| 636 &component[1], | 636 &component[1], |
| 637 match_glyph, | 637 match_glyph, |
| 638 NULL, | 638 NULL, |
| 639 &match_length, | 639 &match_length, |
| 640 match_positions, | 640 match_positions, |
| 641 &is_mark_ligature, | 641 &is_mark_ligature, |
| 642 &total_component_count))) | 642 &total_component_count))) |
| 643 return TRACE_RETURN (false); | 643 return_trace (false); |
| 644 | 644 |
| 645 ligate_input (c, | 645 ligate_input (c, |
| 646 count, | 646 count, |
| 647 match_positions, | 647 match_positions, |
| 648 match_length, | 648 match_length, |
| 649 ligGlyph, | 649 ligGlyph, |
| 650 is_mark_ligature, | 650 is_mark_ligature, |
| 651 total_component_count); | 651 total_component_count); |
| 652 | 652 |
| 653 return TRACE_RETURN (true); | 653 return_trace (true); |
| 654 } | 654 } |
| 655 | 655 |
| 656 inline bool serialize (hb_serialize_context_t *c, | 656 inline bool serialize (hb_serialize_context_t *c, |
| 657 GlyphID ligature, | 657 GlyphID ligature, |
| 658 Supplier<GlyphID> &components, /* Starting from second
*/ | 658 Supplier<GlyphID> &components, /* Starting from second
*/ |
| 659 unsigned int num_components /* Including first componen
t */) | 659 unsigned int num_components /* Including first componen
t */) |
| 660 { | 660 { |
| 661 TRACE_SERIALIZE (this); | 661 TRACE_SERIALIZE (this); |
| 662 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 662 if (unlikely (!c->extend_min (*this))) return_trace (false); |
| 663 ligGlyph = ligature; | 663 ligGlyph = ligature; |
| 664 if (unlikely (!component.serialize (c, components, num_components))) return
TRACE_RETURN (false); | 664 if (unlikely (!component.serialize (c, components, num_components))) return_
trace (false); |
| 665 return TRACE_RETURN (true); | 665 return_trace (true); |
| 666 } | 666 } |
| 667 | 667 |
| 668 public: | 668 public: |
| 669 inline bool sanitize (hb_sanitize_context_t *c) const | 669 inline bool sanitize (hb_sanitize_context_t *c) const |
| 670 { | 670 { |
| 671 TRACE_SANITIZE (this); | 671 TRACE_SANITIZE (this); |
| 672 return TRACE_RETURN (ligGlyph.sanitize (c) && component.sanitize (c)); | 672 return_trace (ligGlyph.sanitize (c) && component.sanitize (c)); |
| 673 } | 673 } |
| 674 | 674 |
| 675 protected: | 675 protected: |
| 676 GlyphID ligGlyph; /* GlyphID of ligature to substitute */ | 676 GlyphID ligGlyph; /* GlyphID of ligature to substitute */ |
| 677 HeadlessArrayOf<GlyphID> | 677 HeadlessArrayOf<GlyphID> |
| 678 component; /* Array of component GlyphIDs--start | 678 component; /* Array of component GlyphIDs--start |
| 679 * with the second component--ordered | 679 * with the second component--ordered |
| 680 * in writing direction */ | 680 * in writing direction */ |
| 681 public: | 681 public: |
| 682 DEFINE_SIZE_ARRAY (4, component); | 682 DEFINE_SIZE_ARRAY (4, component); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 701 } | 701 } |
| 702 | 702 |
| 703 inline bool would_apply (hb_would_apply_context_t *c) const | 703 inline bool would_apply (hb_would_apply_context_t *c) const |
| 704 { | 704 { |
| 705 TRACE_WOULD_APPLY (this); | 705 TRACE_WOULD_APPLY (this); |
| 706 unsigned int num_ligs = ligature.len; | 706 unsigned int num_ligs = ligature.len; |
| 707 for (unsigned int i = 0; i < num_ligs; i++) | 707 for (unsigned int i = 0; i < num_ligs; i++) |
| 708 { | 708 { |
| 709 const Ligature &lig = this+ligature[i]; | 709 const Ligature &lig = this+ligature[i]; |
| 710 if (lig.would_apply (c)) | 710 if (lig.would_apply (c)) |
| 711 return TRACE_RETURN (true); | 711 return_trace (true); |
| 712 } | 712 } |
| 713 return TRACE_RETURN (false); | 713 return_trace (false); |
| 714 } | 714 } |
| 715 | 715 |
| 716 inline bool apply (hb_apply_context_t *c) const | 716 inline bool apply (hb_apply_context_t *c) const |
| 717 { | 717 { |
| 718 TRACE_APPLY (this); | 718 TRACE_APPLY (this); |
| 719 unsigned int num_ligs = ligature.len; | 719 unsigned int num_ligs = ligature.len; |
| 720 for (unsigned int i = 0; i < num_ligs; i++) | 720 for (unsigned int i = 0; i < num_ligs; i++) |
| 721 { | 721 { |
| 722 const Ligature &lig = this+ligature[i]; | 722 const Ligature &lig = this+ligature[i]; |
| 723 if (lig.apply (c)) return TRACE_RETURN (true); | 723 if (lig.apply (c)) return_trace (true); |
| 724 } | 724 } |
| 725 | 725 |
| 726 return TRACE_RETURN (false); | 726 return_trace (false); |
| 727 } | 727 } |
| 728 | 728 |
| 729 inline bool serialize (hb_serialize_context_t *c, | 729 inline bool serialize (hb_serialize_context_t *c, |
| 730 Supplier<GlyphID> &ligatures, | 730 Supplier<GlyphID> &ligatures, |
| 731 Supplier<unsigned int> &component_count_list, | 731 Supplier<unsigned int> &component_count_list, |
| 732 unsigned int num_ligatures, | 732 unsigned int num_ligatures, |
| 733 Supplier<GlyphID> &component_list /* Starting from seco
nd for each ligature */) | 733 Supplier<GlyphID> &component_list /* Starting from seco
nd for each ligature */) |
| 734 { | 734 { |
| 735 TRACE_SERIALIZE (this); | 735 TRACE_SERIALIZE (this); |
| 736 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 736 if (unlikely (!c->extend_min (*this))) return_trace (false); |
| 737 if (unlikely (!ligature.serialize (c, num_ligatures))) return TRACE_RETURN (
false); | 737 if (unlikely (!ligature.serialize (c, num_ligatures))) return_trace (false); |
| 738 for (unsigned int i = 0; i < num_ligatures; i++) | 738 for (unsigned int i = 0; i < num_ligatures; i++) |
| 739 if (unlikely (!ligature[i].serialize (c, this).serialize (c, | 739 if (unlikely (!ligature[i].serialize (c, this).serialize (c, |
| 740 ligatures[i], | 740 ligatures[i], |
| 741 component_list, | 741 component_list, |
| 742 » » » » » » » » component_count_
list[i]))) return TRACE_RETURN (false); | 742 » » » » » » » » component_count_
list[i]))) return_trace (false); |
| 743 ligatures.advance (num_ligatures); | 743 ligatures.advance (num_ligatures); |
| 744 component_count_list.advance (num_ligatures); | 744 component_count_list.advance (num_ligatures); |
| 745 return TRACE_RETURN (true); | 745 return_trace (true); |
| 746 } | 746 } |
| 747 | 747 |
| 748 inline bool sanitize (hb_sanitize_context_t *c) const | 748 inline bool sanitize (hb_sanitize_context_t *c) const |
| 749 { | 749 { |
| 750 TRACE_SANITIZE (this); | 750 TRACE_SANITIZE (this); |
| 751 return TRACE_RETURN (ligature.sanitize (c, this)); | 751 return_trace (ligature.sanitize (c, this)); |
| 752 } | 752 } |
| 753 | 753 |
| 754 protected: | 754 protected: |
| 755 OffsetArrayOf<Ligature> | 755 OffsetArrayOf<Ligature> |
| 756 ligature; /* Array LigatureSet tables | 756 ligature; /* Array LigatureSet tables |
| 757 * ordered by preference */ | 757 * ordered by preference */ |
| 758 public: | 758 public: |
| 759 DEFINE_SIZE_ARRAY (2, ligature); | 759 DEFINE_SIZE_ARRAY (2, ligature); |
| 760 }; | 760 }; |
| 761 | 761 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 783 | 783 |
| 784 inline const Coverage &get_coverage (void) const | 784 inline const Coverage &get_coverage (void) const |
| 785 { | 785 { |
| 786 return this+coverage; | 786 return this+coverage; |
| 787 } | 787 } |
| 788 | 788 |
| 789 inline bool would_apply (hb_would_apply_context_t *c) const | 789 inline bool would_apply (hb_would_apply_context_t *c) const |
| 790 { | 790 { |
| 791 TRACE_WOULD_APPLY (this); | 791 TRACE_WOULD_APPLY (this); |
| 792 unsigned int index = (this+coverage).get_coverage (c->glyphs[0]); | 792 unsigned int index = (this+coverage).get_coverage (c->glyphs[0]); |
| 793 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 793 if (likely (index == NOT_COVERED)) return_trace (false); |
| 794 | 794 |
| 795 const LigatureSet &lig_set = this+ligatureSet[index]; | 795 const LigatureSet &lig_set = this+ligatureSet[index]; |
| 796 return TRACE_RETURN (lig_set.would_apply (c)); | 796 return_trace (lig_set.would_apply (c)); |
| 797 } | 797 } |
| 798 | 798 |
| 799 inline bool apply (hb_apply_context_t *c) const | 799 inline bool apply (hb_apply_context_t *c) const |
| 800 { | 800 { |
| 801 TRACE_APPLY (this); | 801 TRACE_APPLY (this); |
| 802 hb_codepoint_t glyph_id = c->buffer->cur().codepoint; | 802 hb_codepoint_t glyph_id = c->buffer->cur().codepoint; |
| 803 | 803 |
| 804 unsigned int index = (this+coverage).get_coverage (glyph_id); | 804 unsigned int index = (this+coverage).get_coverage (glyph_id); |
| 805 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 805 if (likely (index == NOT_COVERED)) return_trace (false); |
| 806 | 806 |
| 807 const LigatureSet &lig_set = this+ligatureSet[index]; | 807 const LigatureSet &lig_set = this+ligatureSet[index]; |
| 808 return TRACE_RETURN (lig_set.apply (c)); | 808 return_trace (lig_set.apply (c)); |
| 809 } | 809 } |
| 810 | 810 |
| 811 inline bool serialize (hb_serialize_context_t *c, | 811 inline bool serialize (hb_serialize_context_t *c, |
| 812 Supplier<GlyphID> &first_glyphs, | 812 Supplier<GlyphID> &first_glyphs, |
| 813 Supplier<unsigned int> &ligature_per_first_glyph_count_
list, | 813 Supplier<unsigned int> &ligature_per_first_glyph_count_
list, |
| 814 unsigned int num_first_glyphs, | 814 unsigned int num_first_glyphs, |
| 815 Supplier<GlyphID> &ligatures_list, | 815 Supplier<GlyphID> &ligatures_list, |
| 816 Supplier<unsigned int> &component_count_list, | 816 Supplier<unsigned int> &component_count_list, |
| 817 Supplier<GlyphID> &component_list /* Starting from seco
nd for each ligature */) | 817 Supplier<GlyphID> &component_list /* Starting from seco
nd for each ligature */) |
| 818 { | 818 { |
| 819 TRACE_SERIALIZE (this); | 819 TRACE_SERIALIZE (this); |
| 820 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 820 if (unlikely (!c->extend_min (*this))) return_trace (false); |
| 821 if (unlikely (!ligatureSet.serialize (c, num_first_glyphs))) return TRACE_RE
TURN (false); | 821 if (unlikely (!ligatureSet.serialize (c, num_first_glyphs))) return_trace (f
alse); |
| 822 for (unsigned int i = 0; i < num_first_glyphs; i++) | 822 for (unsigned int i = 0; i < num_first_glyphs; i++) |
| 823 if (unlikely (!ligatureSet[i].serialize (c, this).serialize (c, | 823 if (unlikely (!ligatureSet[i].serialize (c, this).serialize (c, |
| 824 ligatures_lis
t, | 824 ligatures_lis
t, |
| 825 component_cou
nt_list, | 825 component_cou
nt_list, |
| 826 ligature_per_
first_glyph_count_list[i], | 826 ligature_per_
first_glyph_count_list[i], |
| 827 » » » » » » » » component_lis
t))) return TRACE_RETURN (false); | 827 » » » » » » » » component_lis
t))) return_trace (false); |
| 828 ligature_per_first_glyph_count_list.advance (num_first_glyphs); | 828 ligature_per_first_glyph_count_list.advance (num_first_glyphs); |
| 829 if (unlikely (!coverage.serialize (c, this).serialize (c, first_glyphs, num_
first_glyphs))) return TRACE_RETURN (false); | 829 if (unlikely (!coverage.serialize (c, this).serialize (c, first_glyphs, num_
first_glyphs))) return_trace (false); |
| 830 return TRACE_RETURN (true); | 830 return_trace (true); |
| 831 } | 831 } |
| 832 | 832 |
| 833 inline bool sanitize (hb_sanitize_context_t *c) const | 833 inline bool sanitize (hb_sanitize_context_t *c) const |
| 834 { | 834 { |
| 835 TRACE_SANITIZE (this); | 835 TRACE_SANITIZE (this); |
| 836 return TRACE_RETURN (coverage.sanitize (c, this) && ligatureSet.sanitize (c,
this)); | 836 return_trace (coverage.sanitize (c, this) && ligatureSet.sanitize (c, this))
; |
| 837 } | 837 } |
| 838 | 838 |
| 839 protected: | 839 protected: |
| 840 USHORT format; /* Format identifier--format = 1 */ | 840 USHORT format; /* Format identifier--format = 1 */ |
| 841 OffsetTo<Coverage> | 841 OffsetTo<Coverage> |
| 842 coverage; /* Offset to Coverage table--from | 842 coverage; /* Offset to Coverage table--from |
| 843 * beginning of Substitution table */ | 843 * beginning of Substitution table */ |
| 844 OffsetArrayOf<LigatureSet> | 844 OffsetArrayOf<LigatureSet> |
| 845 ligatureSet; /* Array LigatureSet tables | 845 ligatureSet; /* Array LigatureSet tables |
| 846 * ordered by Coverage Index */ | 846 * ordered by Coverage Index */ |
| 847 public: | 847 public: |
| 848 DEFINE_SIZE_ARRAY (6, ligatureSet); | 848 DEFINE_SIZE_ARRAY (6, ligatureSet); |
| 849 }; | 849 }; |
| 850 | 850 |
| 851 struct LigatureSubst | 851 struct LigatureSubst |
| 852 { | 852 { |
| 853 inline bool serialize (hb_serialize_context_t *c, | 853 inline bool serialize (hb_serialize_context_t *c, |
| 854 Supplier<GlyphID> &first_glyphs, | 854 Supplier<GlyphID> &first_glyphs, |
| 855 Supplier<unsigned int> &ligature_per_first_glyph_count_
list, | 855 Supplier<unsigned int> &ligature_per_first_glyph_count_
list, |
| 856 unsigned int num_first_glyphs, | 856 unsigned int num_first_glyphs, |
| 857 Supplier<GlyphID> &ligatures_list, | 857 Supplier<GlyphID> &ligatures_list, |
| 858 Supplier<unsigned int> &component_count_list, | 858 Supplier<unsigned int> &component_count_list, |
| 859 Supplier<GlyphID> &component_list /* Starting from seco
nd for each ligature */) | 859 Supplier<GlyphID> &component_list /* Starting from seco
nd for each ligature */) |
| 860 { | 860 { |
| 861 TRACE_SERIALIZE (this); | 861 TRACE_SERIALIZE (this); |
| 862 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); | 862 if (unlikely (!c->extend_min (u.format))) return_trace (false); |
| 863 unsigned int format = 1; | 863 unsigned int format = 1; |
| 864 u.format.set (format); | 864 u.format.set (format); |
| 865 switch (u.format) { | 865 switch (u.format) { |
| 866 case 1: return TRACE_RETURN (u.format1.serialize (c, first_glyphs, ligature_
per_first_glyph_count_list, num_first_glyphs, | 866 case 1: return_trace (u.format1.serialize (c, |
| 867 » » » » » » ligatures_list, component_
count_list, component_list)); | 867 » » » » » first_glyphs, |
| 868 default:return TRACE_RETURN (false); | 868 » » » » » ligature_per_first_glyph_count_li
st, |
| 869 » » » » » num_first_glyphs, |
| 870 » » » » » ligatures_list, |
| 871 » » » » » component_count_list, |
| 872 » » » » » component_list)); |
| 873 default:return_trace (false); |
| 869 } | 874 } |
| 870 } | 875 } |
| 871 | 876 |
| 872 template <typename context_t> | 877 template <typename context_t> |
| 873 inline typename context_t::return_t dispatch (context_t *c) const | 878 inline typename context_t::return_t dispatch (context_t *c) const |
| 874 { | 879 { |
| 875 TRACE_DISPATCH (this, u.format); | 880 TRACE_DISPATCH (this, u.format); |
| 876 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); | 881 if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispa
tch_return_value ()); |
| 877 switch (u.format) { | 882 switch (u.format) { |
| 878 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 883 case 1: return_trace (c->dispatch (u.format1)); |
| 879 default:return TRACE_RETURN (c->default_return_value ()); | 884 default:return_trace (c->default_return_value ()); |
| 880 } | 885 } |
| 881 } | 886 } |
| 882 | 887 |
| 883 protected: | 888 protected: |
| 884 union { | 889 union { |
| 885 USHORT format; /* Format identifier */ | 890 USHORT format; /* Format identifier */ |
| 886 LigatureSubstFormat1 format1; | 891 LigatureSubstFormat1 format1; |
| 887 } u; | 892 } u; |
| 888 }; | 893 }; |
| 889 | 894 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 } | 957 } |
| 953 | 958 |
| 954 inline const Coverage &get_coverage (void) const | 959 inline const Coverage &get_coverage (void) const |
| 955 { | 960 { |
| 956 return this+coverage; | 961 return this+coverage; |
| 957 } | 962 } |
| 958 | 963 |
| 959 inline bool would_apply (hb_would_apply_context_t *c) const | 964 inline bool would_apply (hb_would_apply_context_t *c) const |
| 960 { | 965 { |
| 961 TRACE_WOULD_APPLY (this); | 966 TRACE_WOULD_APPLY (this); |
| 962 return TRACE_RETURN (c->len == 1 && (this+coverage).get_coverage (c->glyphs[
0]) != NOT_COVERED); | 967 return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) !=
NOT_COVERED); |
| 963 } | 968 } |
| 964 | 969 |
| 965 inline bool apply (hb_apply_context_t *c) const | 970 inline bool apply (hb_apply_context_t *c) const |
| 966 { | 971 { |
| 967 TRACE_APPLY (this); | 972 TRACE_APPLY (this); |
| 968 if (unlikely (c->nesting_level_left != MAX_NESTING_LEVEL)) | 973 if (unlikely (c->nesting_level_left != MAX_NESTING_LEVEL)) |
| 969 return TRACE_RETURN (false); /* No chaining to this type */ | 974 return_trace (false); /* No chaining to this type */ |
| 970 | 975 |
| 971 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); | 976 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); |
| 972 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 977 if (likely (index == NOT_COVERED)) return_trace (false); |
| 973 | 978 |
| 974 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverag
e> > (backtrack); | 979 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverag
e> > (backtrack); |
| 975 const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahe
ad); | 980 const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahe
ad); |
| 976 | 981 |
| 977 if (match_backtrack (c, | 982 if (match_backtrack (c, |
| 978 backtrack.len, (USHORT *) backtrack.array, | 983 backtrack.len, (USHORT *) backtrack.array, |
| 979 match_coverage, this) && | 984 match_coverage, this) && |
| 980 match_lookahead (c, | 985 match_lookahead (c, |
| 981 lookahead.len, (USHORT *) lookahead.array, | 986 lookahead.len, (USHORT *) lookahead.array, |
| 982 match_coverage, this, | 987 match_coverage, this, |
| 983 1)) | 988 1)) |
| 984 { | 989 { |
| 985 c->replace_glyph_inplace (substitute[index]); | 990 c->replace_glyph_inplace (substitute[index]); |
| 986 /* Note: We DON'T decrease buffer->idx. The main loop does it | 991 /* Note: We DON'T decrease buffer->idx. The main loop does it |
| 987 * for us. This is useful for preventing surprises if someone | 992 * for us. This is useful for preventing surprises if someone |
| 988 * calls us through a Context lookup. */ | 993 * calls us through a Context lookup. */ |
| 989 return TRACE_RETURN (true); | 994 return_trace (true); |
| 990 } | 995 } |
| 991 | 996 |
| 992 return TRACE_RETURN (false); | 997 return_trace (false); |
| 993 } | 998 } |
| 994 | 999 |
| 995 inline bool sanitize (hb_sanitize_context_t *c) const | 1000 inline bool sanitize (hb_sanitize_context_t *c) const |
| 996 { | 1001 { |
| 997 TRACE_SANITIZE (this); | 1002 TRACE_SANITIZE (this); |
| 998 if (!(coverage.sanitize (c, this) && backtrack.sanitize (c, this))) | 1003 if (!(coverage.sanitize (c, this) && backtrack.sanitize (c, this))) |
| 999 return TRACE_RETURN (false); | 1004 return_trace (false); |
| 1000 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverag
e> > (backtrack); | 1005 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverag
e> > (backtrack); |
| 1001 if (!lookahead.sanitize (c, this)) | 1006 if (!lookahead.sanitize (c, this)) |
| 1002 return TRACE_RETURN (false); | 1007 return_trace (false); |
| 1003 const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahe
ad); | 1008 const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahe
ad); |
| 1004 return TRACE_RETURN (substitute.sanitize (c)); | 1009 return_trace (substitute.sanitize (c)); |
| 1005 } | 1010 } |
| 1006 | 1011 |
| 1007 protected: | 1012 protected: |
| 1008 USHORT format; /* Format identifier--format = 1 */ | 1013 USHORT format; /* Format identifier--format = 1 */ |
| 1009 OffsetTo<Coverage> | 1014 OffsetTo<Coverage> |
| 1010 coverage; /* Offset to Coverage table--from | 1015 coverage; /* Offset to Coverage table--from |
| 1011 * beginning of table */ | 1016 * beginning of table */ |
| 1012 OffsetArrayOf<Coverage> | 1017 OffsetArrayOf<Coverage> |
| 1013 backtrack; /* Array of coverage tables | 1018 backtrack; /* Array of coverage tables |
| 1014 * in backtracking sequence, in glyph | 1019 * in backtracking sequence, in glyph |
| 1015 * sequence order */ | 1020 * sequence order */ |
| 1016 OffsetArrayOf<Coverage> | 1021 OffsetArrayOf<Coverage> |
| 1017 lookaheadX; /* Array of coverage tables | 1022 lookaheadX; /* Array of coverage tables |
| 1018 * in lookahead sequence, in glyph | 1023 * in lookahead sequence, in glyph |
| 1019 * sequence order */ | 1024 * sequence order */ |
| 1020 ArrayOf<GlyphID> | 1025 ArrayOf<GlyphID> |
| 1021 substituteX; /* Array of substitute | 1026 substituteX; /* Array of substitute |
| 1022 * GlyphIDs--ordered by Coverage Index *
/ | 1027 * GlyphIDs--ordered by Coverage Index *
/ |
| 1023 public: | 1028 public: |
| 1024 DEFINE_SIZE_MIN (10); | 1029 DEFINE_SIZE_MIN (10); |
| 1025 }; | 1030 }; |
| 1026 | 1031 |
| 1027 struct ReverseChainSingleSubst | 1032 struct ReverseChainSingleSubst |
| 1028 { | 1033 { |
| 1029 template <typename context_t> | 1034 template <typename context_t> |
| 1030 inline typename context_t::return_t dispatch (context_t *c) const | 1035 inline typename context_t::return_t dispatch (context_t *c) const |
| 1031 { | 1036 { |
| 1032 TRACE_DISPATCH (this, u.format); | 1037 TRACE_DISPATCH (this, u.format); |
| 1033 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); | 1038 if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispa
tch_return_value ()); |
| 1034 switch (u.format) { | 1039 switch (u.format) { |
| 1035 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 1040 case 1: return_trace (c->dispatch (u.format1)); |
| 1036 default:return TRACE_RETURN (c->default_return_value ()); | 1041 default:return_trace (c->default_return_value ()); |
| 1037 } | 1042 } |
| 1038 } | 1043 } |
| 1039 | 1044 |
| 1040 protected: | 1045 protected: |
| 1041 union { | 1046 union { |
| 1042 USHORT format; /* Format identifier */ | 1047 USHORT format; /* Format identifier */ |
| 1043 ReverseChainSingleSubstFormat1 format1; | 1048 ReverseChainSingleSubstFormat1 format1; |
| 1044 } u; | 1049 } u; |
| 1045 }; | 1050 }; |
| 1046 | 1051 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1062 Context = 5, | 1067 Context = 5, |
| 1063 ChainContext = 6, | 1068 ChainContext = 6, |
| 1064 Extension = 7, | 1069 Extension = 7, |
| 1065 ReverseChainSingle = 8 | 1070 ReverseChainSingle = 8 |
| 1066 }; | 1071 }; |
| 1067 | 1072 |
| 1068 template <typename context_t> | 1073 template <typename context_t> |
| 1069 inline typename context_t::return_t dispatch (context_t *c, unsigned int looku
p_type) const | 1074 inline typename context_t::return_t dispatch (context_t *c, unsigned int looku
p_type) const |
| 1070 { | 1075 { |
| 1071 TRACE_DISPATCH (this, lookup_type); | 1076 TRACE_DISPATCH (this, lookup_type); |
| 1072 /* The sub_format passed to may_dispatch is unnecessary but harmless. */ | 1077 if (unlikely (!c->may_dispatch (this, &u.sub_format))) return_trace (c->no_d
ispatch_return_value ()); |
| 1073 if (unlikely (!c->may_dispatch (this, &u.sub_format))) TRACE_RETURN (c->defa
ult_return_value ()); | |
| 1074 switch (lookup_type) { | 1078 switch (lookup_type) { |
| 1075 case Single:» » return TRACE_RETURN (u.single.dispatch (c)); | 1079 case Single:» » return_trace (u.single.dispatch (c)); |
| 1076 case Multiple:» » return TRACE_RETURN (u.multiple.dispatch (c)); | 1080 case Multiple:» » return_trace (u.multiple.dispatch (c)); |
| 1077 case Alternate:» » return TRACE_RETURN (u.alternate.dispatch (c)); | 1081 case Alternate:» » return_trace (u.alternate.dispatch (c)); |
| 1078 case Ligature:» » return TRACE_RETURN (u.ligature.dispatch (c)); | 1082 case Ligature:» » return_trace (u.ligature.dispatch (c)); |
| 1079 case Context:» » return TRACE_RETURN (u.context.dispatch (c)); | 1083 case Context:» » return_trace (u.context.dispatch (c)); |
| 1080 case ChainContext:» » return TRACE_RETURN (u.chainContext.dispatch (c)
); | 1084 case ChainContext:» » return_trace (u.chainContext.dispatch (c)); |
| 1081 case Extension:» » return TRACE_RETURN (u.extension.dispatch (c)); | 1085 case Extension:» » return_trace (u.extension.dispatch (c)); |
| 1082 case ReverseChainSingle:» return TRACE_RETURN (u.reverseChainContextSingle
.dispatch (c)); | 1086 case ReverseChainSingle:» return_trace (u.reverseChainContextSingle.dispat
ch (c)); |
| 1083 default:» » » return TRACE_RETURN (c->default_return_value ())
; | 1087 default:» » » return_trace (c->default_return_value ()); |
| 1084 } | 1088 } |
| 1085 } | 1089 } |
| 1086 | 1090 |
| 1087 protected: | 1091 protected: |
| 1088 union { | 1092 union { |
| 1089 USHORT sub_format; | 1093 USHORT sub_format; |
| 1090 SingleSubst single; | 1094 SingleSubst single; |
| 1091 MultipleSubst multiple; | 1095 MultipleSubst multiple; |
| 1092 AlternateSubst alternate; | 1096 AlternateSubst alternate; |
| 1093 LigatureSubst ligature; | 1097 LigatureSubst ligature; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1113 { | 1117 { |
| 1114 unsigned int type = get_type (); | 1118 unsigned int type = get_type (); |
| 1115 if (unlikely (type == SubstLookupSubTable::Extension)) | 1119 if (unlikely (type == SubstLookupSubTable::Extension)) |
| 1116 return CastR<ExtensionSubst> (get_subtable(0)).is_reverse (); | 1120 return CastR<ExtensionSubst> (get_subtable(0)).is_reverse (); |
| 1117 return lookup_type_is_reverse (type); | 1121 return lookup_type_is_reverse (type); |
| 1118 } | 1122 } |
| 1119 | 1123 |
| 1120 inline bool apply (hb_apply_context_t *c) const | 1124 inline bool apply (hb_apply_context_t *c) const |
| 1121 { | 1125 { |
| 1122 TRACE_APPLY (this); | 1126 TRACE_APPLY (this); |
| 1123 return TRACE_RETURN (dispatch (c)); | 1127 return_trace (dispatch (c)); |
| 1124 } | 1128 } |
| 1125 | 1129 |
| 1126 inline hb_closure_context_t::return_t closure (hb_closure_context_t *c) const | 1130 inline hb_closure_context_t::return_t closure (hb_closure_context_t *c) const |
| 1127 { | 1131 { |
| 1128 TRACE_CLOSURE (this); | 1132 TRACE_CLOSURE (this); |
| 1129 c->set_recurse_func (dispatch_recurse_func<hb_closure_context_t>); | 1133 c->set_recurse_func (dispatch_recurse_func<hb_closure_context_t>); |
| 1130 return TRACE_RETURN (dispatch (c)); | 1134 return_trace (dispatch (c)); |
| 1131 } | 1135 } |
| 1132 | 1136 |
| 1133 inline hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs
_context_t *c) const | 1137 inline hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs
_context_t *c) const |
| 1134 { | 1138 { |
| 1135 TRACE_COLLECT_GLYPHS (this); | 1139 TRACE_COLLECT_GLYPHS (this); |
| 1136 c->set_recurse_func (dispatch_recurse_func<hb_collect_glyphs_context_t>); | 1140 c->set_recurse_func (dispatch_recurse_func<hb_collect_glyphs_context_t>); |
| 1137 return TRACE_RETURN (dispatch (c)); | 1141 return_trace (dispatch (c)); |
| 1138 } | 1142 } |
| 1139 | 1143 |
| 1140 template <typename set_t> | 1144 template <typename set_t> |
| 1141 inline void add_coverage (set_t *glyphs) const | 1145 inline void add_coverage (set_t *glyphs) const |
| 1142 { | 1146 { |
| 1143 hb_add_coverage_context_t<set_t> c (glyphs); | 1147 hb_add_coverage_context_t<set_t> c (glyphs); |
| 1144 dispatch (&c); | 1148 dispatch (&c); |
| 1145 } | 1149 } |
| 1146 | 1150 |
| 1147 inline bool would_apply (hb_would_apply_context_t *c, | 1151 inline bool would_apply (hb_would_apply_context_t *c, |
| 1148 const hb_ot_layout_lookup_accelerator_t *accel) const | 1152 const hb_ot_layout_lookup_accelerator_t *accel) const |
| 1149 { | 1153 { |
| 1150 TRACE_WOULD_APPLY (this); | 1154 TRACE_WOULD_APPLY (this); |
| 1151 if (unlikely (!c->len)) return TRACE_RETURN (false); | 1155 if (unlikely (!c->len)) return_trace (false); |
| 1152 if (!accel->may_have (c->glyphs[0])) return TRACE_RETURN (false); | 1156 if (!accel->may_have (c->glyphs[0])) return_trace (false); |
| 1153 return TRACE_RETURN (dispatch (c)); | 1157 return_trace (dispatch (c)); |
| 1154 } | 1158 } |
| 1155 | 1159 |
| 1156 static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_ind
ex); | 1160 static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_ind
ex); |
| 1157 | 1161 |
| 1158 inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c, | 1162 inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c, |
| 1159 unsigned int i) | 1163 unsigned int i) |
| 1160 { return get_subtables<SubstLookupSubTable> ()[i].serialize (c, this); } | 1164 { return get_subtables<SubstLookupSubTable> ()[i].serialize (c, this); } |
| 1161 | 1165 |
| 1162 inline bool serialize_single (hb_serialize_context_t *c, | 1166 inline bool serialize_single (hb_serialize_context_t *c, |
| 1163 uint32_t lookup_props, | 1167 uint32_t lookup_props, |
| 1164 Supplier<GlyphID> &glyphs, | 1168 Supplier<GlyphID> &glyphs, |
| 1165 Supplier<GlyphID> &substitutes, | 1169 Supplier<GlyphID> &substitutes, |
| 1166 unsigned int num_glyphs) | 1170 unsigned int num_glyphs) |
| 1167 { | 1171 { |
| 1168 TRACE_SERIALIZE (this); | 1172 TRACE_SERIALIZE (this); |
| 1169 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Single, lookup_pro
ps, 1))) return TRACE_RETURN (false); | 1173 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Single, lookup_pro
ps, 1))) return_trace (false); |
| 1170 return TRACE_RETURN (serialize_subtable (c, 0).u.single.serialize (c, glyphs
, substitutes, num_glyphs)); | 1174 return_trace (serialize_subtable (c, 0).u.single.serialize (c, glyphs, subst
itutes, num_glyphs)); |
| 1171 } | 1175 } |
| 1172 | 1176 |
| 1173 inline bool serialize_multiple (hb_serialize_context_t *c, | 1177 inline bool serialize_multiple (hb_serialize_context_t *c, |
| 1174 uint32_t lookup_props, | 1178 uint32_t lookup_props, |
| 1175 Supplier<GlyphID> &glyphs, | 1179 Supplier<GlyphID> &glyphs, |
| 1176 Supplier<unsigned int> &substitute_len_list, | 1180 Supplier<unsigned int> &substitute_len_list, |
| 1177 unsigned int num_glyphs, | 1181 unsigned int num_glyphs, |
| 1178 Supplier<GlyphID> &substitute_glyphs_list) | 1182 Supplier<GlyphID> &substitute_glyphs_list) |
| 1179 { | 1183 { |
| 1180 TRACE_SERIALIZE (this); | 1184 TRACE_SERIALIZE (this); |
| 1181 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Multiple, lookup_p
rops, 1))) return TRACE_RETURN (false); | 1185 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Multiple, lookup_p
rops, 1))) return_trace (false); |
| 1182 return TRACE_RETURN (serialize_subtable (c, 0).u.multiple.serialize (c, glyp
hs, substitute_len_list, num_glyphs, | 1186 return_trace (serialize_subtable (c, 0).u.multiple.serialize (c, |
| 1183 » » » » » » » » » substit
ute_glyphs_list)); | 1187 » » » » » » » » glyphs, |
| 1188 » » » » » » » » substitute_len
_list, |
| 1189 » » » » » » » » num_glyphs, |
| 1190 » » » » » » » » substitute_gly
phs_list)); |
| 1184 } | 1191 } |
| 1185 | 1192 |
| 1186 inline bool serialize_alternate (hb_serialize_context_t *c, | 1193 inline bool serialize_alternate (hb_serialize_context_t *c, |
| 1187 uint32_t lookup_props, | 1194 uint32_t lookup_props, |
| 1188 Supplier<GlyphID> &glyphs, | 1195 Supplier<GlyphID> &glyphs, |
| 1189 Supplier<unsigned int> &alternate_len_list, | 1196 Supplier<unsigned int> &alternate_len_list, |
| 1190 unsigned int num_glyphs, | 1197 unsigned int num_glyphs, |
| 1191 Supplier<GlyphID> &alternate_glyphs_list) | 1198 Supplier<GlyphID> &alternate_glyphs_list) |
| 1192 { | 1199 { |
| 1193 TRACE_SERIALIZE (this); | 1200 TRACE_SERIALIZE (this); |
| 1194 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Alternate, lookup_
props, 1))) return TRACE_RETURN (false); | 1201 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Alternate, lookup_
props, 1))) return_trace (false); |
| 1195 return TRACE_RETURN (serialize_subtable (c, 0).u.alternate.serialize (c, gly
phs, alternate_len_list, num_glyphs, | 1202 return_trace (serialize_subtable (c, 0).u.alternate.serialize (c, |
| 1196 » » » » » » » » » altern
ate_glyphs_list)); | 1203 » » » » » » » » glyphs, |
| 1204 » » » » » » » » alternate_len
_list, |
| 1205 » » » » » » » » num_glyphs, |
| 1206 » » » » » » » » alternate_gly
phs_list)); |
| 1197 } | 1207 } |
| 1198 | 1208 |
| 1199 inline bool serialize_ligature (hb_serialize_context_t *c, | 1209 inline bool serialize_ligature (hb_serialize_context_t *c, |
| 1200 uint32_t lookup_props, | 1210 uint32_t lookup_props, |
| 1201 Supplier<GlyphID> &first_glyphs, | 1211 Supplier<GlyphID> &first_glyphs, |
| 1202 Supplier<unsigned int> &ligature_per_first_gly
ph_count_list, | 1212 Supplier<unsigned int> &ligature_per_first_gly
ph_count_list, |
| 1203 unsigned int num_first_glyphs, | 1213 unsigned int num_first_glyphs, |
| 1204 Supplier<GlyphID> &ligatures_list, | 1214 Supplier<GlyphID> &ligatures_list, |
| 1205 Supplier<unsigned int> &component_count_list, | 1215 Supplier<unsigned int> &component_count_list, |
| 1206 Supplier<GlyphID> &component_list /* Starting
from second for each ligature */) | 1216 Supplier<GlyphID> &component_list /* Starting
from second for each ligature */) |
| 1207 { | 1217 { |
| 1208 TRACE_SERIALIZE (this); | 1218 TRACE_SERIALIZE (this); |
| 1209 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Ligature, lookup_p
rops, 1))) return TRACE_RETURN (false); | 1219 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Ligature, lookup_p
rops, 1))) return_trace (false); |
| 1210 return TRACE_RETURN (serialize_subtable (c, 0).u.ligature.serialize (c, firs
t_glyphs, ligature_per_first_glyph_count_list, num_first_glyphs, | 1220 return_trace (serialize_subtable (c, 0).u.ligature.serialize (c, |
| 1211 » » » » » » » » » ligatur
es_list, component_count_list, component_list)); | 1221 » » » » » » » » first_glyphs, |
| 1222 » » » » » » » » ligature_per_f
irst_glyph_count_list, |
| 1223 » » » » » » » » num_first_glyp
hs, |
| 1224 » » » » » » » » ligatures_list
, |
| 1225 » » » » » » » » component_coun
t_list, |
| 1226 » » » » » » » » component_list
)); |
| 1212 } | 1227 } |
| 1213 | 1228 |
| 1214 template <typename context_t> | 1229 template <typename context_t> |
| 1215 static inline typename context_t::return_t dispatch_recurse_func (context_t *c
, unsigned int lookup_index); | 1230 static inline typename context_t::return_t dispatch_recurse_func (context_t *c
, unsigned int lookup_index); |
| 1216 | 1231 |
| 1217 template <typename context_t> | 1232 template <typename context_t> |
| 1218 inline typename context_t::return_t dispatch (context_t *c) const | 1233 inline typename context_t::return_t dispatch (context_t *c) const |
| 1219 { return Lookup::dispatch<SubstLookupSubTable> (c); } | 1234 { return Lookup::dispatch<SubstLookupSubTable> (c); } |
| 1220 | 1235 |
| 1221 inline bool sanitize (hb_sanitize_context_t *c) const | 1236 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1222 { | 1237 { |
| 1223 TRACE_SANITIZE (this); | 1238 TRACE_SANITIZE (this); |
| 1224 if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false); | 1239 if (unlikely (!Lookup::sanitize (c))) return_trace (false); |
| 1225 if (unlikely (!dispatch (c))) return TRACE_RETURN (false); | 1240 if (unlikely (!dispatch (c))) return_trace (false); |
| 1226 | 1241 |
| 1227 if (unlikely (get_type () == SubstLookupSubTable::Extension)) | 1242 if (unlikely (get_type () == SubstLookupSubTable::Extension)) |
| 1228 { | 1243 { |
| 1229 /* The spec says all subtables of an Extension lookup should | 1244 /* The spec says all subtables of an Extension lookup should |
| 1230 * have the same type. This is specially important if one has | 1245 * have the same type. This is specially important if one has |
| 1231 * a reverse type! */ | 1246 * a reverse type! */ |
| 1232 unsigned int type = get_subtable (0).u.extension.get_type (); | 1247 unsigned int type = get_subtable (0).u.extension.get_type (); |
| 1233 unsigned int count = get_subtable_count (); | 1248 unsigned int count = get_subtable_count (); |
| 1234 for (unsigned int i = 1; i < count; i++) | 1249 for (unsigned int i = 1; i < count; i++) |
| 1235 if (get_subtable (i).u.extension.get_type () != type) | 1250 if (get_subtable (i).u.extension.get_type () != type) |
| 1236 » return TRACE_RETURN (false); | 1251 » return_trace (false); |
| 1237 } | 1252 } |
| 1238 return TRACE_RETURN (true); | 1253 return_trace (true); |
| 1239 } | 1254 } |
| 1240 }; | 1255 }; |
| 1241 | 1256 |
| 1242 typedef OffsetListOf<SubstLookup> SubstLookupList; | 1257 typedef OffsetListOf<SubstLookup> SubstLookupList; |
| 1243 | 1258 |
| 1244 /* | 1259 /* |
| 1245 * GSUB -- The Glyph Substitution Table | 1260 * GSUB -- The Glyph Substitution Table |
| 1246 */ | 1261 */ |
| 1247 | 1262 |
| 1248 struct GSUB : GSUBGPOS | 1263 struct GSUB : GSUBGPOS |
| 1249 { | 1264 { |
| 1250 static const hb_tag_t tableTag = HB_OT_TAG_GSUB; | 1265 static const hb_tag_t tableTag = HB_OT_TAG_GSUB; |
| 1251 | 1266 |
| 1252 inline const SubstLookup& get_lookup (unsigned int i) const | 1267 inline const SubstLookup& get_lookup (unsigned int i) const |
| 1253 { return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); } | 1268 { return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); } |
| 1254 | 1269 |
| 1255 static inline void substitute_start (hb_font_t *font, hb_buffer_t *buffer); | 1270 static inline void substitute_start (hb_font_t *font, hb_buffer_t *buffer); |
| 1256 static inline void substitute_finish (hb_font_t *font, hb_buffer_t *buffer); | 1271 static inline void substitute_finish (hb_font_t *font, hb_buffer_t *buffer); |
| 1257 | 1272 |
| 1258 inline bool sanitize (hb_sanitize_context_t *c) const | 1273 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1259 { | 1274 { |
| 1260 TRACE_SANITIZE (this); | 1275 TRACE_SANITIZE (this); |
| 1261 if (unlikely (!GSUBGPOS::sanitize (c))) return TRACE_RETURN (false); | 1276 if (unlikely (!GSUBGPOS::sanitize (c))) return_trace (false); |
| 1262 const OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (l
ookupList); | 1277 const OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (l
ookupList); |
| 1263 return TRACE_RETURN (list.sanitize (c, this)); | 1278 return_trace (list.sanitize (c, this)); |
| 1264 } | 1279 } |
| 1265 public: | 1280 public: |
| 1266 DEFINE_SIZE_STATIC (10); | 1281 DEFINE_SIZE_STATIC (10); |
| 1267 }; | 1282 }; |
| 1268 | 1283 |
| 1269 | 1284 |
| 1270 void | 1285 void |
| 1271 GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) | 1286 GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) |
| 1272 { | 1287 { |
| 1273 _hb_buffer_assert_gsubgpos_vars (buffer); | 1288 _hb_buffer_assert_gsubgpos_vars (buffer); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 c->set_lookup_index (saved_lookup_index); | 1333 c->set_lookup_index (saved_lookup_index); |
| 1319 c->set_lookup_props (saved_lookup_props); | 1334 c->set_lookup_props (saved_lookup_props); |
| 1320 return ret; | 1335 return ret; |
| 1321 } | 1336 } |
| 1322 | 1337 |
| 1323 | 1338 |
| 1324 } /* namespace OT */ | 1339 } /* namespace OT */ |
| 1325 | 1340 |
| 1326 | 1341 |
| 1327 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ | 1342 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ |
| OLD | NEW |