| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2011,2012 Google, Inc. | 2 * Copyright © 2011,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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 if (likely (b)) { | 164 if (likely (b)) { |
| 165 output_char (buffer, b, b_glyph); | 165 output_char (buffer, b, b_glyph); |
| 166 return 2; | 166 return 2; |
| 167 } | 167 } |
| 168 return 1; | 168 return 1; |
| 169 } | 169 } |
| 170 | 170 |
| 171 return 0; | 171 return 0; |
| 172 } | 172 } |
| 173 | 173 |
| 174 /* Returns 0 if didn't decompose, number of resulting characters otherwise. */ |
| 175 static inline unsigned int |
| 176 decompose_compatibility (const hb_ot_shape_normalize_context_t *c, hb_codepoint_
t u) |
| 177 { |
| 178 unsigned int len, i; |
| 179 hb_codepoint_t decomposed[HB_UNICODE_MAX_DECOMPOSITION_LEN]; |
| 180 hb_codepoint_t glyphs[HB_UNICODE_MAX_DECOMPOSITION_LEN]; |
| 181 |
| 182 len = c->buffer->unicode->decompose_compatibility (u, decomposed); |
| 183 if (!len) |
| 184 return 0; |
| 185 |
| 186 for (i = 0; i < len; i++) |
| 187 if (!c->font->get_glyph (decomposed[i], 0, &glyphs[i])) |
| 188 return 0; |
| 189 |
| 190 for (i = 0; i < len; i++) |
| 191 output_char (c->buffer, decomposed[i], glyphs[i]); |
| 192 |
| 193 return len; |
| 194 } |
| 195 |
| 174 static inline void | 196 static inline void |
| 175 decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor
test) | 197 decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor
test) |
| 176 { | 198 { |
| 177 hb_buffer_t * const buffer = c->buffer; | 199 hb_buffer_t * const buffer = c->buffer; |
| 178 hb_codepoint_t u = buffer->cur().codepoint; | 200 hb_codepoint_t u = buffer->cur().codepoint; |
| 179 hb_codepoint_t glyph; | 201 hb_codepoint_t glyph; |
| 180 | 202 |
| 181 /* Kind of a cute waterfall here... */ | 203 /* Kind of a cute waterfall here... */ |
| 182 if (shortest && c->font->get_glyph (u, 0, &glyph)) | 204 if (shortest && c->font->get_glyph (u, 0, &glyph)) |
| 183 next_char (buffer, glyph); | 205 next_char (buffer, glyph); |
| 184 else if (decompose (c, shortest, u)) | 206 else if (decompose (c, shortest, u)) |
| 185 skip_char (buffer); | 207 skip_char (buffer); |
| 186 else if (!shortest && c->font->get_glyph (u, 0, &glyph)) | 208 else if (!shortest && c->font->get_glyph (u, 0, &glyph)) |
| 187 next_char (buffer, glyph); | 209 next_char (buffer, glyph); |
| 210 else if (decompose_compatibility (c, u)) |
| 211 skip_char (buffer); |
| 188 else | 212 else |
| 189 next_char (buffer, glyph); /* glyph is initialized in earlier branches. */ | 213 next_char (buffer, glyph); /* glyph is initialized in earlier branches. */ |
| 190 } | 214 } |
| 191 | 215 |
| 192 static inline void | 216 static inline void |
| 193 handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, uns
igned int end, bool short_circuit) | 217 handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, uns
igned int end, bool short_circuit) |
| 194 { | 218 { |
| 195 /* TODO Currently if there's a variation-selector we give-up, it's just too ha
rd. */ | 219 /* TODO Currently if there's a variation-selector we give-up, it's just too ha
rd. */ |
| 196 hb_buffer_t * const buffer = c->buffer; | 220 hb_buffer_t * const buffer = c->buffer; |
| 197 hb_font_t * const font = c->font; | 221 hb_font_t * const font = c->font; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 | 407 |
| 384 /* Blocked, or doesn't compose. */ | 408 /* Blocked, or doesn't compose. */ |
| 385 buffer->next_glyph (); | 409 buffer->next_glyph (); |
| 386 | 410 |
| 387 if (_hb_glyph_info_get_modified_combining_class (&buffer->prev()) == 0) | 411 if (_hb_glyph_info_get_modified_combining_class (&buffer->prev()) == 0) |
| 388 starter = buffer->out_len - 1; | 412 starter = buffer->out_len - 1; |
| 389 } | 413 } |
| 390 buffer->swap_buffers (); | 414 buffer->swap_buffers (); |
| 391 | 415 |
| 392 } | 416 } |
| OLD | NEW |