| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 { | 344 { |
| 345 for (unsigned int j = 0; j < clusters[i].num_glyphs; ++j) | 345 for (unsigned int j = 0; j < clusters[i].num_glyphs; ++j) |
| 346 { | 346 { |
| 347 hb_glyph_info_t *info = &buffer->info[clusters[i].base_glyph + j]; | 347 hb_glyph_info_t *info = &buffer->info[clusters[i].base_glyph + j]; |
| 348 info->codepoint = gids[clusters[i].base_glyph + j]; | 348 info->codepoint = gids[clusters[i].base_glyph + j]; |
| 349 info->cluster = clusters[i].cluster; | 349 info->cluster = clusters[i].cluster; |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 buffer->len = glyph_count; | 352 buffer->len = glyph_count; |
| 353 | 353 |
| 354 float yscale = font->y_scale / font->x_scale; |
| 354 /* Positioning. */ | 355 /* Positioning. */ |
| 355 if (!HB_DIRECTION_IS_BACKWARD(buffer->props.direction)) | 356 if (!HB_DIRECTION_IS_BACKWARD(buffer->props.direction)) |
| 356 { | 357 { |
| 357 hb_glyph_position_t *pPos; | 358 hb_glyph_position_t *pPos; |
| 358 for (pPos = hb_buffer_get_glyph_positions (buffer, NULL), is = gr_seg_first_
slot (seg); | 359 for (pPos = hb_buffer_get_glyph_positions (buffer, NULL), is = gr_seg_first_
slot (seg); |
| 359 is; pPos++, is = gr_slot_next_in_segment (is)) | 360 is; pPos++, is = gr_slot_next_in_segment (is)) |
| 360 { | 361 { |
| 361 pPos->x_offset = gr_slot_origin_X (is) - curradvx; | 362 pPos->x_offset = gr_slot_origin_X (is) - curradvx; |
| 362 pPos->y_offset = gr_slot_origin_Y (is) - curradvy; | 363 pPos->y_offset = gr_slot_origin_Y (is) * yscale - curradvy; |
| 363 pPos->x_advance = gr_slot_advance_X (is, grface, grfont); | 364 pPos->x_advance = gr_slot_advance_X (is, grface, grfont); |
| 364 pPos->y_advance = gr_slot_advance_Y (is, grface, grfont); | 365 pPos->y_advance = gr_slot_advance_Y (is, grface, grfont) * yscale; |
| 365 curradvx += pPos->x_advance; | 366 curradvx += pPos->x_advance; |
| 366 curradvy += pPos->y_advance; | 367 curradvy += pPos->y_advance; |
| 367 } | 368 } |
| 368 pPos[-1].x_advance += gr_seg_advance_X(seg) - curradvx; | 369 pPos[-1].x_advance += gr_seg_advance_X(seg) - curradvx; |
| 369 } | 370 } |
| 370 else | 371 else |
| 371 { | 372 { |
| 372 hb_glyph_position_t *pPos = hb_buffer_get_glyph_positions (buffer, NULL) + b
uffer->len - 1; | 373 hb_glyph_position_t *pPos = hb_buffer_get_glyph_positions (buffer, NULL) + b
uffer->len - 1; |
| 373 const hb_glyph_info_t *info = buffer->info + buffer->len - 1; | 374 const hb_glyph_info_t *info = buffer->info + buffer->len - 1; |
| 374 const hb_glyph_info_t *tinfo; | 375 const hb_glyph_info_t *tinfo; |
| 375 const gr_slot *tis; | 376 const gr_slot *tis; |
| 376 int currclus = -1; | 377 int currclus = -1; |
| 377 float clusx = 0., clusy = 0.; | 378 float clusx = 0., clusy = 0.; |
| 378 for (is = gr_seg_last_slot (seg); is; pPos--, info--, is = gr_slot_prev_in_s
egment (is)) | 379 for (is = gr_seg_last_slot (seg); is; pPos--, info--, is = gr_slot_prev_in_s
egment (is)) |
| 379 { | 380 { |
| 380 if (info->cluster != currclus) | 381 if (info->cluster != currclus) |
| 381 { | 382 { |
| 382 curradvx += clusx; | 383 curradvx += clusx; |
| 383 curradvy += clusy; | 384 curradvy += clusy; |
| 384 currclus = info->cluster; | 385 currclus = info->cluster; |
| 385 clusx = 0.; | 386 clusx = 0.; |
| 386 clusy = 0.; | 387 clusy = 0.; |
| 387 for (tis = is, tinfo = info; tis && tinfo->cluster == currclus; tis = gr
_slot_prev_in_segment (tis), tinfo--) | 388 for (tis = is, tinfo = info; tis && tinfo->cluster == currclus; tis = gr
_slot_prev_in_segment (tis), tinfo--) |
| 388 { | 389 { |
| 389 clusx += gr_slot_advance_X (tis, grface, grfont); | 390 clusx += gr_slot_advance_X (tis, grface, grfont); |
| 390 clusy += gr_slot_advance_Y (tis, grface, grfont); | 391 clusy += gr_slot_advance_Y (tis, grface, grfont) * yscale; |
| 391 } | 392 } |
| 392 curradvx += clusx; | 393 curradvx += clusx; |
| 393 curradvy += clusy; | 394 curradvy += clusy; |
| 394 } | 395 } |
| 395 pPos->x_advance = gr_slot_advance_X (is, grface, grfont); | 396 pPos->x_advance = gr_slot_advance_X (is, grface, grfont); |
| 396 pPos->y_advance = gr_slot_advance_Y (is, grface, grfont); | 397 pPos->y_advance = gr_slot_advance_Y (is, grface, grfont) * yscale; |
| 397 curradvx -= pPos->x_advance; | 398 curradvx -= pPos->x_advance; |
| 398 curradvy -= pPos->y_advance; | 399 curradvy -= pPos->y_advance; |
| 399 pPos->x_offset = gr_slot_origin_X (is) - curradvx; | 400 pPos->x_offset = gr_slot_origin_X (is) - curradvx; |
| 400 pPos->y_offset = gr_slot_origin_Y (is) - curradvy; | 401 pPos->y_offset = gr_slot_origin_Y (is) * yscale - curradvy; |
| 401 } | 402 } |
| 402 hb_buffer_reverse_clusters (buffer); | 403 hb_buffer_reverse_clusters (buffer); |
| 403 } | 404 } |
| 404 | 405 |
| 405 if (feats) gr_featureval_destroy (feats); | 406 if (feats) gr_featureval_destroy (feats); |
| 406 gr_seg_destroy (seg); | 407 gr_seg_destroy (seg); |
| 407 | 408 |
| 408 return true; | 409 return true; |
| 409 } | 410 } |
| OLD | NEW |