changeset 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 1ee11bab38fa
files src/shape_stext.c
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/shape_stext.c	Thu Jul 30 12:11:27 2009 +0800
+++ b/src/shape_stext.c	Thu Jul 30 15:42:43 2009 +0800
@@ -478,7 +478,7 @@
  */
 static
 void extent_extents(mb_text_extents_t *full, mb_text_extents_t *sub) {
-    co_aix f_rbx, f_rby;	/* rb stands for right button */
+    co_aix f_rbx, f_rby;	/* rb stands for right bottom */
     co_aix s_rbx, s_rby;
     co_aix s_xbr, s_ybr;
     co_aix new_x_adv, new_y_adv;
@@ -541,8 +541,6 @@
     char *txt, saved;
     int i, nscaled;
     
-    memset(&txt_o->extents, sizeof(mb_text_extents_t), 0);
-    
     scaled_fonts = &txt_o->scaled_fonts;
     for(i = 0; i < scaled_fonts->num; i++)
 	scaled_font_free(scaled_fonts->ds[i]);
@@ -571,11 +569,19 @@
 	compute_text_extents(scaled, txt, sub);
 	txt[blk_txt_len] = saved;
 
-	extent_extents(&txt_o->extents, sub);
-
 	blk++;
 	txt += blk_txt_len;
-    }    
+    }
+    
+    if(style_blks->num > 0) {
+	sub = sub_exts->ds;
+	memcpy(&txt_o->extents, sub, sizeof(mb_text_extents_t));
+	for(i = 1; i < style_blks->num; i++) {
+	    sub = sub_exts->ds + i;
+	    extent_extents(&txt_o->extents, sub);
+	}
+    } else
+	memset(&txt_o->extents, sizeof(mb_text_extents_t), 0);    
 }
 
 /*