comparison src/shape_stext.c @ 437:e73b3644d802

Fix bug of compute extents of sh_stext. Full extents sh_stext_t::extents should be initialized with extents of first style block if existed. But, it was not. So, it is fixed, now.
author Thinker K.F. Li <thinker@branda.to>
date Thu, 30 Jul 2009 15:42:43 +0800
parents c02d2aa2c45e
children 2437047b8bb8
comparison
equal deleted inserted replaced
436:c02d2aa2c45e 437:e73b3644d802
476 * blocks should be computed separated, collected, and aggreagated 476 * blocks should be computed separated, collected, and aggreagated
477 * into a full extents. 477 * into a full extents.
478 */ 478 */
479 static 479 static
480 void extent_extents(mb_text_extents_t *full, mb_text_extents_t *sub) { 480 void extent_extents(mb_text_extents_t *full, mb_text_extents_t *sub) {
481 co_aix f_rbx, f_rby; /* rb stands for right button */ 481 co_aix f_rbx, f_rby; /* rb stands for right bottom */
482 co_aix s_rbx, s_rby; 482 co_aix s_rbx, s_rby;
483 co_aix s_xbr, s_ybr; 483 co_aix s_xbr, s_ybr;
484 co_aix new_x_adv, new_y_adv; 484 co_aix new_x_adv, new_y_adv;
485 485
486 f_rbx = MBE_GET_X_BEARING(full) + MBE_GET_WIDTH(full); 486 f_rbx = MBE_GET_X_BEARING(full) + MBE_GET_WIDTH(full);
538 scaled_fonts_lst_t *scaled_fonts; 538 scaled_fonts_lst_t *scaled_fonts;
539 extents_lst_t *sub_exts; 539 extents_lst_t *sub_exts;
540 mb_text_extents_t *sub; 540 mb_text_extents_t *sub;
541 char *txt, saved; 541 char *txt, saved;
542 int i, nscaled; 542 int i, nscaled;
543
544 memset(&txt_o->extents, sizeof(mb_text_extents_t), 0);
545 543
546 scaled_fonts = &txt_o->scaled_fonts; 544 scaled_fonts = &txt_o->scaled_fonts;
547 for(i = 0; i < scaled_fonts->num; i++) 545 for(i = 0; i < scaled_fonts->num; i++)
548 scaled_font_free(scaled_fonts->ds[i]); 546 scaled_font_free(scaled_fonts->ds[i]);
549 DARRAY_CLEAN(scaled_fonts); 547 DARRAY_CLEAN(scaled_fonts);
569 saved = txt[blk_txt_len]; 567 saved = txt[blk_txt_len];
570 txt[blk_txt_len] = 0; 568 txt[blk_txt_len] = 0;
571 compute_text_extents(scaled, txt, sub); 569 compute_text_extents(scaled, txt, sub);
572 txt[blk_txt_len] = saved; 570 txt[blk_txt_len] = saved;
573 571
574 extent_extents(&txt_o->extents, sub);
575
576 blk++; 572 blk++;
577 txt += blk_txt_len; 573 txt += blk_txt_len;
578 } 574 }
575
576 if(style_blks->num > 0) {
577 sub = sub_exts->ds;
578 memcpy(&txt_o->extents, sub, sizeof(mb_text_extents_t));
579 for(i = 1; i < style_blks->num; i++) {
580 sub = sub_exts->ds + i;
581 extent_extents(&txt_o->extents, sub);
582 }
583 } else
584 memset(&txt_o->extents, sizeof(mb_text_extents_t), 0);
579 } 585 }
580 586
581 /* 587 /*
582 * What we have to do in sh_stext_transform() is 588 * What we have to do in sh_stext_transform() is
583 * - computing bounding box for the text, 589 * - computing bounding box for the text,