| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2012 Google, Inc. | 2 * Copyright © 2012 Google, Inc. |
| 3 * | 3 * |
| 4 * This is part of HarfBuzz, a text shaping library. | 4 * This is part of HarfBuzz, a text shaping library. |
| 5 * | 5 * |
| 6 * Permission is hereby granted, without written agreement and without | 6 * Permission is hereby granted, without written agreement and without |
| 7 * license or royalty fees, to use, copy, modify, and distribute this | 7 * license or royalty fees, to use, copy, modify, and distribute this |
| 8 * software and its documentation for any purpose, provided that the | 8 * software and its documentation for any purpose, provided that the |
| 9 * above copyright notice and the following two paragraphs appear in | 9 * above copyright notice and the following two paragraphs appear in |
| 10 * all copies of this software. | 10 * all copies of this software. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 glyphs[num_glyphs].set (u_glyph); | 69 glyphs[num_glyphs].set (u_glyph); |
| 70 substitutes[num_glyphs].set (s_glyph); | 70 substitutes[num_glyphs].set (s_glyph); |
| 71 | 71 |
| 72 num_glyphs++; | 72 num_glyphs++; |
| 73 } | 73 } |
| 74 | 74 |
| 75 if (!num_glyphs) | 75 if (!num_glyphs) |
| 76 return NULL; | 76 return NULL; |
| 77 | 77 |
| 78 /* Bubble-sort! | 78 /* Bubble-sort or something equally good! |
| 79 * May not be good-enough for presidential candidate interviews, but good-enou
gh for us... */ | 79 * May not be good-enough for presidential candidate interviews, but good-enou
gh for us... */ |
| 80 hb_bubble_sort (&glyphs[0], num_glyphs, OT::GlyphID::cmp, &substitutes[0]); | 80 hb_stable_sort (&glyphs[0], num_glyphs, OT::GlyphID::cmp, &substitutes[0]); |
| 81 | 81 |
| 82 OT::Supplier<OT::GlyphID> glyphs_supplier (glyphs, num_glyphs); | 82 OT::Supplier<OT::GlyphID> glyphs_supplier (glyphs, num_glyphs); |
| 83 OT::Supplier<OT::GlyphID> substitutes_supplier (substitutes, num_glyphs); | 83 OT::Supplier<OT::GlyphID> substitutes_supplier (substitutes, num_glyphs); |
| 84 | 84 |
| 85 /* Each glyph takes four bytes max, and there's some overhead. */ | 85 /* Each glyph takes four bytes max, and there's some overhead. */ |
| 86 char buf[(SHAPING_TABLE_LAST - SHAPING_TABLE_FIRST + 1) * 4 + 128]; | 86 char buf[(SHAPING_TABLE_LAST - SHAPING_TABLE_FIRST + 1) * 4 + 128]; |
| 87 OT::hb_serialize_context_t c (buf, sizeof (buf)); | 87 OT::hb_serialize_context_t c (buf, sizeof (buf)); |
| 88 OT::SubstLookup *lookup = c.start_serialize<OT::SubstLookup> (); | 88 OT::SubstLookup *lookup = c.start_serialize<OT::SubstLookup> (); |
| 89 bool ret = lookup->serialize_single (&c, | 89 bool ret = lookup->serialize_single (&c, |
| 90 OT::LookupFlag::IgnoreMarks, | 90 OT::LookupFlag::IgnoreMarks, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 119 { | 119 { |
| 120 hb_codepoint_t first_u = ligature_table[first_glyph_idx].first; | 120 hb_codepoint_t first_u = ligature_table[first_glyph_idx].first; |
| 121 hb_codepoint_t first_glyph; | 121 hb_codepoint_t first_glyph; |
| 122 if (!hb_font_get_glyph (font, first_u, 0, &first_glyph)) | 122 if (!hb_font_get_glyph (font, first_u, 0, &first_glyph)) |
| 123 continue; | 123 continue; |
| 124 first_glyphs[num_first_glyphs].set (first_glyph); | 124 first_glyphs[num_first_glyphs].set (first_glyph); |
| 125 ligature_per_first_glyph_count_list[num_first_glyphs] = 0; | 125 ligature_per_first_glyph_count_list[num_first_glyphs] = 0; |
| 126 first_glyphs_indirection[num_first_glyphs] = first_glyph_idx; | 126 first_glyphs_indirection[num_first_glyphs] = first_glyph_idx; |
| 127 num_first_glyphs++; | 127 num_first_glyphs++; |
| 128 } | 128 } |
| 129 hb_bubble_sort (&first_glyphs[0], num_first_glyphs, OT::GlyphID::cmp, &first_g
lyphs_indirection[0]); | 129 hb_stable_sort (&first_glyphs[0], num_first_glyphs, OT::GlyphID::cmp, &first_g
lyphs_indirection[0]); |
| 130 | 130 |
| 131 /* Now that the first-glyphs are sorted, walk again, populate ligatures. */ | 131 /* Now that the first-glyphs are sorted, walk again, populate ligatures. */ |
| 132 for (unsigned int i = 0; i < num_first_glyphs; i++) | 132 for (unsigned int i = 0; i < num_first_glyphs; i++) |
| 133 { | 133 { |
| 134 unsigned int first_glyph_idx = first_glyphs_indirection[i]; | 134 unsigned int first_glyph_idx = first_glyphs_indirection[i]; |
| 135 | 135 |
| 136 for (unsigned int second_glyph_idx = 0; second_glyph_idx < ARRAY_LENGTH (lig
ature_table[0].ligatures); second_glyph_idx++) | 136 for (unsigned int second_glyph_idx = 0; second_glyph_idx < ARRAY_LENGTH (lig
ature_table[0].ligatures); second_glyph_idx++) |
| 137 { | 137 { |
| 138 hb_codepoint_t second_u = ligature_table[first_glyph_idx].ligatures[seco
nd_glyph_idx].second; | 138 hb_codepoint_t second_u = ligature_table[first_glyph_idx].ligatures[seco
nd_glyph_idx].second; |
| 139 hb_codepoint_t ligature_u = ligature_table[first_glyph_idx].ligatures[seco
nd_glyph_idx].ligature; | 139 hb_codepoint_t ligature_u = ligature_table[first_glyph_idx].ligatures[seco
nd_glyph_idx].ligature; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 if (fallback_plan->lookup_array[i]) { | 345 if (fallback_plan->lookup_array[i]) { |
| 346 c.set_lookup_mask (fallback_plan->mask_array[i]); | 346 c.set_lookup_mask (fallback_plan->mask_array[i]); |
| 347 hb_ot_layout_substitute_lookup (&c, | 347 hb_ot_layout_substitute_lookup (&c, |
| 348 *fallback_plan->lookup_array[i], | 348 *fallback_plan->lookup_array[i], |
| 349 fallback_plan->accel_array[i]); | 349 fallback_plan->accel_array[i]); |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 | 352 |
| 353 | 353 |
| 354 #endif /* HB_OT_SHAPE_COMPLEX_ARABIC_FALLBACK_HH */ | 354 #endif /* HB_OT_SHAPE_COMPLEX_ARABIC_FALLBACK_HH */ |
| OLD | NEW |