]> granicus.if.org Git - graphviz/commitdiff
Fix bug in emitting a sequence of text chunks with different font attributes.
authorerg <devnull@localhost>
Wed, 25 Jun 2008 20:37:41 +0000 (20:37 +0000)
committererg <devnull@localhost>
Wed, 25 Jun 2008 20:37:41 +0000 (20:37 +0000)
lib/common/htmltable.c
lib/common/htmltable.h

index f1215d9a068fab0a6ec0f7367e994b5e65441969..c2cd187cd079fa3aab312ed574db795f27a4b092 100644 (file)
@@ -115,7 +115,6 @@ emit_htextparas(GVJ_t* job, int nparas, htextpara_t* paras, pointf p,
 {
     int i,j;
     double tmp, center_x, left_x, right_x, fsize_;
-    double offset;
     char *fname_ , *fcolor_;
     textpara_t tl;
     pointf p_ = {0.0, 0.0};
@@ -134,25 +133,22 @@ emit_htextparas(GVJ_t* job, int nparas, htextpara_t* paras, pointf p,
 
     gvrender_begin_context(job);
     for(i=0; i<nparas; i++) {
+       /* set p.x to leftmost point where the line of text begins */
        switch (paras[i].just) {
        case 'l':
-           p_.x = left_x;
            p.x = left_x;
            break;
        case 'r':
-           p_.x = right_x;
-           p.x = right_x;              
+           p.x = right_x - paras[i].size;
            break;
        default:
        case 'n':
-           p_.x = center_x;
-           p.x = center_x;
+           p.x = center_x - paras[i].size/2.0;
            break;
        }
        p_.y -= paras[i].lfsize;  /* move to current base line */
 
        ti = paras[i].items;
-       offset = 0.0;
        for(j=0; j<paras[i].nitems; j++) {
            if (ti->font && (ti->font->size > 0))
                fsize_ = ti->font->size;
@@ -177,13 +173,18 @@ emit_htextparas(GVJ_t* job, int nparas, htextpara_t* paras, pointf p,
            tl.yoffset_centerline = ti->yoffset_centerline;
            tl.postscript_alias = ti->postscript_alias;
            tl.layout = ti->layout;
-           tl.width = paras[i].size;
+           tl.width = ti->size;
            tl.height = paras[i].lfsize;
-           tl.just = paras[i].just;
 
+           tl.just = 'l';
+           p_.x = p.x;
+#if 0
+/* or */
+           tl.just = 'c';
+           p_.x = p.x + (ti->size/2.0);
+#endif
            gvrender_textpara(job, p_, &tl);
-           offset += ti->size;
-           p_.x = p.x + offset;
+           p.x += ti->size;
             ti++;
        }
     }
index 5c64a19749603b8bd0eb5ff09fe49e5479654841..dd7ffc407c6dfe5c653530a3327a2a16914ffbe9 100644 (file)
@@ -62,6 +62,7 @@ extern "C" {
     } htmltxt_t;
 #endif
        
+       /* atomic unit of text emitted using a single htmlfont_t */
     typedef struct {
        char *str;
        char *xshow;
@@ -72,6 +73,7 @@ extern "C" {
        double size, yoffset_layout, yoffset_centerline;
     } textitem_t;
        
+       /* line of textitems_t */
     typedef struct {
        textitem_t *items;
        short nitems;