OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2011 Martin Hosken | 2 * Copyright © 2011 Martin Hosken |
3 * Copyright © 2011 SIL International | 3 * Copyright © 2011 SIL International |
4 * Copyright © 2011,2012 Google, Inc. | 4 * Copyright © 2011,2012 Google, Inc. |
5 * | 5 * |
6 * This is part of HarfBuzz, a text shaping library. | 6 * This is part of HarfBuzz, a text shaping library. |
7 * | 7 * |
8 * Permission is hereby granted, without written agreement and without | 8 * Permission is hereby granted, without written agreement and without |
9 * license or royalty fees, to use, copy, modify, and distribute this | 9 * license or royalty fees, to use, copy, modify, and distribute this |
10 * software and its documentation for any purpose, provided that the | 10 * software and its documentation for any purpose, provided that the |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 202 |
203 /* | 203 /* |
204 * shaper | 204 * shaper |
205 */ | 205 */ |
206 | 206 |
207 struct hb_graphite2_cluster_t { | 207 struct hb_graphite2_cluster_t { |
208 unsigned int base_char; | 208 unsigned int base_char; |
209 unsigned int num_chars; | 209 unsigned int num_chars; |
210 unsigned int base_glyph; | 210 unsigned int base_glyph; |
211 unsigned int num_glyphs; | 211 unsigned int num_glyphs; |
| 212 unsigned int cluster; |
212 }; | 213 }; |
213 | 214 |
214 hb_bool_t | 215 hb_bool_t |
215 _hb_graphite2_shape (hb_shape_plan_t *shape_plan, | 216 _hb_graphite2_shape (hb_shape_plan_t *shape_plan, |
216 hb_font_t *font, | 217 hb_font_t *font, |
217 hb_buffer_t *buffer, | 218 hb_buffer_t *buffer, |
218 const hb_feature_t *features, | 219 const hb_feature_t *features, |
219 unsigned int num_features) | 220 unsigned int num_features) |
220 { | 221 { |
221 hb_face_t *face = font->face; | 222 hb_face_t *face = font->face; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 293 } |
293 | 294 |
294 ALLOCATE_ARRAY (hb_graphite2_cluster_t, clusters, buffer->len); | 295 ALLOCATE_ARRAY (hb_graphite2_cluster_t, clusters, buffer->len); |
295 ALLOCATE_ARRAY (hb_codepoint_t, gids, glyph_count); | 296 ALLOCATE_ARRAY (hb_codepoint_t, gids, glyph_count); |
296 | 297 |
297 #undef ALLOCATE_ARRAY | 298 #undef ALLOCATE_ARRAY |
298 | 299 |
299 memset (clusters, 0, sizeof (clusters[0]) * buffer->len); | 300 memset (clusters, 0, sizeof (clusters[0]) * buffer->len); |
300 | 301 |
301 hb_codepoint_t *pg = gids; | 302 hb_codepoint_t *pg = gids; |
| 303 clusters[0].cluster = buffer->info[0].cluster; |
302 for (is = gr_seg_first_slot (seg), ic = 0; is; is = gr_slot_next_in_segment (i
s), ic++) | 304 for (is = gr_seg_first_slot (seg), ic = 0; is; is = gr_slot_next_in_segment (i
s), ic++) |
303 { | 305 { |
304 unsigned int before = gr_slot_before (is); | 306 unsigned int before = gr_slot_before (is); |
305 unsigned int after = gr_slot_after (is); | 307 unsigned int after = gr_slot_after (is); |
306 *pg = gr_slot_gid (is); | 308 *pg = gr_slot_gid (is); |
307 pg++; | 309 pg++; |
308 while (clusters[ci].base_char > before && ci) | 310 while (clusters[ci].base_char > before && ci) |
309 { | 311 { |
310 clusters[ci-1].num_chars += clusters[ci].num_chars; | 312 clusters[ci-1].num_chars += clusters[ci].num_chars; |
311 clusters[ci-1].num_glyphs += clusters[ci].num_glyphs; | 313 clusters[ci-1].num_glyphs += clusters[ci].num_glyphs; |
312 ci--; | 314 ci--; |
313 } | 315 } |
314 | 316 |
315 if (gr_slot_can_insert_before (is) && clusters[ci].num_chars && before >= cl
usters[ci].base_char + clusters[ci].num_chars) | 317 if (gr_slot_can_insert_before (is) && clusters[ci].num_chars && before >= cl
usters[ci].base_char + clusters[ci].num_chars) |
316 { | 318 { |
317 hb_graphite2_cluster_t *c = clusters + ci + 1; | 319 hb_graphite2_cluster_t *c = clusters + ci + 1; |
318 c->base_char = clusters[ci].base_char + clusters[ci].num_chars; | 320 c->base_char = clusters[ci].base_char + clusters[ci].num_chars; |
| 321 c->cluster = buffer->info[c->base_char].cluster; |
319 c->num_chars = before - c->base_char; | 322 c->num_chars = before - c->base_char; |
320 c->base_glyph = ic; | 323 c->base_glyph = ic; |
321 c->num_glyphs = 0; | 324 c->num_glyphs = 0; |
322 ci++; | 325 ci++; |
323 } | 326 } |
324 clusters[ci].num_glyphs++; | 327 clusters[ci].num_glyphs++; |
325 | 328 |
326 if (clusters[ci].base_char + clusters[ci].num_chars < after + 1) | 329 if (clusters[ci].base_char + clusters[ci].num_chars < after + 1) |
327 clusters[ci].num_chars = after + 1 - clusters[ci].base_char; | 330 clusters[ci].num_chars = after + 1 - clusters[ci].base_char; |
328 } | 331 } |
329 ci++; | 332 ci++; |
330 | 333 |
331 //buffer->clear_output (); | 334 //buffer->clear_output (); |
332 for (unsigned int i = 0; i < ci; ++i) | 335 for (unsigned int i = 0; i < ci; ++i) |
333 { | 336 { |
334 for (unsigned int j = 0; j < clusters[i].num_glyphs; ++j) | 337 for (unsigned int j = 0; j < clusters[i].num_glyphs; ++j) |
335 { | 338 { |
336 hb_glyph_info_t *info = &buffer->info[clusters[i].base_glyph + j]; | 339 hb_glyph_info_t *info = &buffer->info[clusters[i].base_glyph + j]; |
337 info->codepoint = gids[clusters[i].base_glyph + j]; | 340 info->codepoint = gids[clusters[i].base_glyph + j]; |
338 info->cluster = gr_cinfo_base(gr_seg_cinfo(seg, clusters[i].base_char)); | 341 info->cluster = clusters[i].cluster; |
339 } | 342 } |
340 } | 343 } |
341 buffer->len = glyph_count; | 344 buffer->len = glyph_count; |
342 //buffer->swap_buffers (); | 345 //buffer->swap_buffers (); |
343 | 346 |
344 if (HB_DIRECTION_IS_BACKWARD(buffer->props.direction)) | 347 if (HB_DIRECTION_IS_BACKWARD(buffer->props.direction)) |
345 curradvx = gr_seg_advance_X(seg); | 348 curradvx = gr_seg_advance_X(seg); |
346 | 349 |
347 hb_glyph_position_t *pPos; | 350 hb_glyph_position_t *pPos; |
348 for (pPos = hb_buffer_get_glyph_positions (buffer, NULL), is = gr_seg_first_sl
ot (seg); | 351 for (pPos = hb_buffer_get_glyph_positions (buffer, NULL), is = gr_seg_first_sl
ot (seg); |
(...skipping 15 matching lines...) Expand all Loading... |
364 pPos[-1].x_advance += gr_seg_advance_X(seg) - curradvx; | 367 pPos[-1].x_advance += gr_seg_advance_X(seg) - curradvx; |
365 | 368 |
366 if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) | 369 if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) |
367 hb_buffer_reverse_clusters (buffer); | 370 hb_buffer_reverse_clusters (buffer); |
368 | 371 |
369 if (feats) gr_featureval_destroy (feats); | 372 if (feats) gr_featureval_destroy (feats); |
370 gr_seg_destroy (seg); | 373 gr_seg_destroy (seg); |
371 | 374 |
372 return true; | 375 return true; |
373 } | 376 } |
OLD | NEW |