]> granicus.if.org Git - graphviz/commitdiff
simplify textpara_t
authorJohn Ellson <ellson@research.att.com>
Wed, 6 Nov 2013 01:46:50 +0000 (20:46 -0500)
committerJohn Ellson <ellson@research.att.com>
Wed, 6 Nov 2013 01:46:50 +0000 (20:46 -0500)
17 files changed:
lib/common/emit.c
lib/common/fontmetrics.c
lib/common/htmltable.c
lib/common/labels.c
lib/common/textpara.h
plugin/core/gvrender_core_dia.c
plugin/core/gvrender_core_dot.c
plugin/core/gvrender_core_pic.c
plugin/core/gvrender_core_pov.c
plugin/core/gvrender_core_ps.c
plugin/core/gvrender_core_vml.c
plugin/gd/gvrender_gd.c
plugin/gd/gvrender_gd_vrml.c
plugin/gd/gvtextlayout_gd.c
plugin/lasi/gvrender_lasi.cpp
plugin/pango/gvrender_pango.c
plugin/pango/gvtextlayout_pango.c

index e4839ac8c53dc3d8a6396904e27e12a1aef035b4..3789b8cf077dccc0f35669599e02cbebda630488 100644 (file)
@@ -2882,25 +2882,24 @@ static boxf
 textBB (double x, double y, textpara_t* para)
 {
     boxf bb;
-    double wd = para->width;
-    double ht = para->height;
+    pointf sz = para->size;
 
     switch (para->just) {
     case 'l':
        bb.LL.x = x;
-       bb.UR.x = bb.LL.x + wd;
+       bb.UR.x = bb.LL.x + sz.x;
        break; 
     case 'n':
-       bb.LL.x = x - wd/2.0; 
-       bb.UR.x = x + wd/2.0; 
+       bb.LL.x = x - sz.x / 2.0; 
+       bb.UR.x = x + sz.x / 2.0; 
        break; 
     case 'r':
        bb.UR.x = x; 
-       bb.LL.x = bb.UR.x - wd;
+       bb.LL.x = bb.UR.x - sz.x;
        break; 
     }
     bb.UR.y = y + para->yoffset_layout;
-    bb.LL.y = bb.UR.y - ht;
+    bb.LL.y = bb.UR.y - sz.y;
     return bb;
 }
 
index c37ebe1dc5b1bfd346d9dc703a01fb2343a0428d..8cb914f75b50a791c868535503c56a2b889eb3a4 100644 (file)
@@ -131,8 +131,8 @@ estimate_textlayout(textpara_t * para, char **fontpath)
     fontname = para->font->name;
     fontsize = para->font->size;
 
-    para->width = 0.0;
-    para->height = fontsize * LINESPACING;
+    para->size.x = 0.0;
+    para->size.y = fontsize * LINESPACING;
     para->yoffset_layout = 0.0;
     para->yoffset_centerline = 0.1 * fontsize;
     para->layout = NULL;
@@ -153,8 +153,8 @@ estimate_textlayout(textpara_t * para, char **fontpath)
        *fontpath = fpp;
     if ((p = para->str)) {
        while ((c = *p++))
-           para->width += Fontwidth[(unsigned char) c];
-       para->width *= fontsize;
+           para->size.x += Fontwidth[(unsigned char) c];
+       para->size.x *= fontsize;
     }
 }
 
@@ -193,7 +193,6 @@ static PostscriptAlias* translate_postscript_fontname(char* fontname)
 pointf textsize(GVC_t *gvc, textpara_t * para, char *fontname, double fontsize)
 {
     char **fpp = NULL, *fontpath = NULL;
-    pointf size;
     htmlfont_t *font;
 
     font = NEW(htmlfont_t);
@@ -219,7 +218,5 @@ pointf textsize(GVC_t *gvc, textpara_t * para, char *fontname, double fontsize)
            fprintf(stderr, "fontname: unable to resolve \"%s\"\n", fontname);
     }
 
-    size.x = para->width;
-    size.y = para->height;
-    return size;
+    return para->size;
 }
index bf6f060f8968d4d41dcdaeeefd217e3b2ae5dca3..a80fb5ea6b159badb2e5b62363d122f07e7c8909 100644 (file)
@@ -174,13 +174,13 @@ emit_htextparas(GVJ_t * job, int nparas, htextpara_t * paras, pointf p,
                tl.yoffset_centerline = 1;
            tl.postscript_alias = ti->postscript_alias;
            tl.layout = ti->layout;
-           tl.width = ti->size;
-           tl.height = paras[i].lfsize;
+           tl.size.x = ti->size.x;
+           tl.size.y = paras[i].lfsize;
            tl.just = 'l';
 
            p_.x = p.x;
            gvrender_textpara(job, p_, &tl);
-           p.x += ti->size;
+           p.x += ti->size.x;
            ti++;
        }
     }
@@ -1058,7 +1058,7 @@ static int size_html_txt(graph_t * g, htmltxt_t * ftxt, htmlenv_t * env)
            sz = textsize(GD_gvc(g), &lp, fname, fsize);
            free(ftxt->paras[i].items[j].str);
            ftxt->paras[i].items[j].str = lp.str;
-           ftxt->paras[i].items[j].size = sz.x;
+           ftxt->paras[i].items[j].size.x = sz.x;
            ftxt->paras[i].items[j].yoffset_layout = lp.yoffset_layout;
            ftxt->paras[i].items[j].yoffset_centerline = lp.yoffset_centerline;
            ftxt->paras[i].items[j].postscript_alias = lp.postscript_alias;
index 1f703b52cb9270450534cda3425a430e29b64dd2..d09d70461307773c3062b31ddc42d99bdb52cb4a 100644 (file)
@@ -32,7 +32,7 @@ static void storeline(GVC_t *gvc, textlabel_t *lp, char *line, char terminator)
         size = textsize(gvc, para, lp->fontname, lp->fontsize);
     else {
        size.x = 0.0;
-       para->height = size.y = (int)(lp->fontsize * LINESPACING);
+       para->size.y = size.y = (int)(lp->fontsize * LINESPACING);
     }
 
     lp->u.txt.nparas++;
@@ -268,7 +268,7 @@ void emit_label(GVJ_t * job, emit_state_t emit_state, textlabel_t * lp)
        gvrender_textpara(job, p, &(lp->u.txt.para[i]));
 
        /* UL position for next para */
-       p.y -= lp->u.txt.para[i].height;
+       p.y -= lp->u.txt.para[i].size.y;
     }
 
     gvrender_end_label(job);
index 389f1201257e143999112486a421effda58d2eda..e1c1150cfab69da025950870929dc73690d01d58 100644 (file)
@@ -57,8 +57,8 @@ extern "C" {
        void *layout;
        void (*free_layout) (void *layout);   /* FIXME - this is ugly */
        htmlfont_t *font;
-       double size, yoffset_layout, yoffset_centerline;
-       double width, height; /* FIXME */
+       double yoffset_layout, yoffset_centerline;
+       pointf size;
        char just;      /* 'l' 'n' 'r' */ /* FIXME */
     } textpara_t;
 
index 1702b3ef6e1bf57820b6dda81779731c463de2e2..5adf915dd6b2258d807c0fe6c5e8377c4dd718b4 100644 (file)
@@ -543,8 +543,8 @@ static void dia_textpara(GVJ_t * job, pointf p, textpara_t * para)
 #if 0
     gvputs(job, "      <dia:attribute name=\"obj_bb\">\n");
     gvprintf(job, "        <dia:rectangle val=\"%g,%g;%g,%g\"/>\n",
-              p.x - (Scale * (para->width) / 2.), p.y - 0.4,
-              p.x + (Scale * (para->width) / 2.), p.y + 0.4);
+              p.x - (Scale * (para->size.x) / 2.), p.y - 0.4,
+              p.x + (Scale * (para->size.x) / 2.), p.y + 0.4);
     gvputs(job, "      </dia:attribute>\n");
 #endif
     gvputs(job, "    </dia:object>\n");
index b00c9aead20d58fabe22dfd2e3d70bdc28beb6bd..d46cdb59629639554e5caa952793c1234dd16521 100644 (file)
@@ -579,7 +579,7 @@ static void xdot_textpara(GVJ_t * job, pointf p, textpara_t * para)
     xdot_point(xbufs[emit_state], p);
     sprintf(buf, "%d ", j);
     agxbput(xbufs[emit_state], buf);
-    xdot_fmt_num (buf, para->width);
+    xdot_fmt_num (buf, para->size.x);
     agxbput(xbufs[emit_state], buf);
     xdot_str (job, "", para->str);
 }
index 28939fdf14f6543e53177eb6307de1a3c8928b6e..16c613ee131941c7806fde3fb31286a2f9a7f1f4 100644 (file)
@@ -435,16 +435,16 @@ static void pic_textpara(GVJ_t * job, pointf p, textpara_t * para)
     case 'l': 
         break;
     case 'r': 
-        p.x -= para->width;
+        p.x -= para->size.x;
         break;
     default:
     case 'n': 
-        p.x -= para->width / 2;
+        p.x -= para->size.x / 2;
         break;
     }
     /* Why on earth would we do this. But it works. SCN 2/26/2002 */
     p.y += para->font->size / (3.0 * POINTS_PER_INCH);
-    p.x += para->width / (2.0 * POINTS_PER_INCH);
+    p.x += para->size.x / (2.0 * POINTS_PER_INCH);
 
     if (para->font->name && (!(lastname) || strcmp(lastname, para->font->name))) {
         gvprintf(job, ".ft %s\n", picfontname(para->font->name));
index f0544f77ce42aee7ba2d32c34c549fb2c29cf158..85fa9cd323b36faa27d70b5a3501597394862fa5 100644 (file)
@@ -601,11 +601,11 @@ static void pov_textpara(GVJ_t * job, pointf c, textpara_t * para)
        case 'l':               //left justified
                break;
        case 'r':               //right justified
-               c.x = c.x - para->width;
+               c.x = c.x - para->size.x;
                break;
        default:
        case 'n':               //centered
-               c.x = c.x - para->width / 2.0;
+               c.x = c.x - para->size.x / 2.0;
                break;
        }
 
index 521533aefd574c0e0a92a3895fdfffe0cb346fe7..9bd95e6e445c2b57b0efc2a9054b215784f18c83 100644 (file)
@@ -284,20 +284,20 @@ static void psgen_textpara(GVJ_t * job, pointf p, textpara_t * para)
     str = ps_string(para->str,isLatin1);
     switch (para->just) {
     case 'r':
-        p.x -= para->width;
+        p.x -= para->size.x;
         break;
     case 'l':
         p.x -= 0.0;
         break;
     case 'n':
     default:
-        p.x -= para->width / 2.0;
+        p.x -= para->size.x / 2.0;
         break;
     }
     p.y += para->yoffset_centerline;
     gvprintpointf(job, p);
     gvputs(job, " moveto ");
-    gvprintdouble(job, para->width);
+    gvprintdouble(job, para->size.x);
     gvprintf(job, " %s alignedtext\n", str);
 }
 
index bd42cdf5e128b748953d5df7e2a411a336d9e43a..de5843673c94de54cb92335880896a89c94359b7 100644 (file)
@@ -378,22 +378,22 @@ static void vml_textpara(GVJ_t * job, pointf p, textpara_t * para)
        p1.x=p.x;
        break;
     case 'r':
-       p1.x=p.x-para->width;
+       p1.x=p.x-para->size.x;
        break;
     default:
     case 'n':
-       p1.x=p.x-(para->width/2);
+       p1.x=p.x-(para->size.x/2);
        break;
     }
-    p2.x=p1.x+para->width;
-    if (para->height <  para->font->size){
-      para->height = 1 + (1.1*para->font->size);
+    p2.x=p1.x+para->size.x;
+    if (para->size.y <  para->font->size){
+      para->size.y = 1 + (1.1*para->font->size);
     }
 
     p1.x-=8; /* vml textbox margin fudge factor */
     p2.x+=8; /* vml textbox margin fudge factor */
     p2.y=graphHeight-(p.y);
-    p1.y=(p2.y-para->height);
+    p1.y=(p2.y-para->size.y);
     /* text "y" was too high
      * Graphviz uses "baseline", VML seems to use bottom of descenders - so we fudge a little
      * (heuristics - based on eyeballs)  */
index f0d00024a323e820d9dd9b846ff5e87f60c7371d..2f62c0402a89dad4d6fca915fe3c09b6757c5725 100644 (file)
@@ -366,7 +366,7 @@ static void gdgen_textpara(GVJ_t * job, pointf p, textpara_t * para)
 {
     gdImagePtr im = (gdImagePtr) job->context;
     pointf spf, epf;
-    double parawidth = para->width * job->zoom * job->dpi.x / POINTS_PER_INCH;
+    double parawidth = para->size.x * job->zoom * job->dpi.x / POINTS_PER_INCH;
     char* fontname;
 
     if (!im)
index 8ee0980439ff5403b682f9bd1476ea60cb18aa05..6f6cf59616b6e9b25f596272763d0523508e2b5e 100644 (file)
@@ -342,14 +342,14 @@ static void vrml_textpara(GVJ_t *job, pointf p, textpara_t * para)
     case 'l':
        break;
     case 'r':
-       p.x -= para->width;
+       p.x -= para->size.x;
        break;
     default:
     case 'n':
-       p.x -= para->width / 2;
+       p.x -= para->size.x / 2;
        break;
     }
-    q.x = p.x + para->width;
+    q.x = p.x + para->size.x;
     q.y = p.y;
 
     spf = vrml_node_point(job, obj->u.n, p);
index f63c87a37fc76587f7af0e2e6f1c703989dbb8ee..74c866552222fe0c24a948b8a2bf610157de4187 100644 (file)
@@ -138,8 +138,8 @@ static boolean gd_textlayout(textpara_t * para, char **fontpath)
     else
        strex.flags |= gdFTEX_FONTCONFIG;
 
-    para->width = 0.0;
-    para->height = 0.0;
+    para->size.x = 0.0;
+    para->size.y = 0.0;
     para->yoffset_layout = 0.0;
 
     para->layout = NULL;
@@ -181,11 +181,11 @@ static boolean gd_textlayout(textpara_t * para, char **fontpath)
 
        if (para->str && para->str[0]) {
            /* can't use brect on some archtectures if strlen 0 */
-           para->width = (double) (brect[4] - brect[0]);
+           para->size.x = (double) (brect[4] - brect[0]);
            /* 1.2 specifies how much extra space to leave between lines;
              * see LINESPACING in const.h.
              */
-           para->height = (int)(fontsize * 1.2);
+           para->size.y = (int)(fontsize * 1.2);
        }
     }
     return TRUE;
index 68668f0ac24e0d34c7c15b3ca7ce842d836d3460..0ddffc11d6ad9bb91a01b0b1ac0cfecc47bc92f0 100644 (file)
@@ -400,20 +400,20 @@ static void lasi_textpara(GVJ_t * job, pointf p, textpara_t * para)
     doc->osBody() << setFont(font, style, weight, variant, stretch) << setFontSize(para->font->size) << endl;
     switch (para->just) {
     case 'r':
-        p.x -= para->width;
+        p.x -= para->size.x;
         break;
     case 'l':
         p.x -= 0.0;
         break;
     case 'n':
     default:
-        p.x -= para->width / 2.0;
+        p.x -= para->size.x / 2.0;
         break;
     }
     p.y += para->yoffset_centerline;
     gvprintpointf(job, p);
     gvputs(job, " moveto ");
-//    gvprintdouble(job, para->width);
+//    gvprintdouble(job, para->size.x);
 //    str = ps_string(para->str,isLatin1);
 //    gvprintf(job, " %s alignedtext\n", str);
     doc->osBody() << show(para->str) << endl;
index 174d1ef7ab707407eec9d17f772ba59bf76ab21f..164ecd712cbcd297f922360b4cfd9544c49c59e8 100644 (file)
@@ -229,14 +229,14 @@ static void cairogen_textpara(GVJ_t * job, pointf p, textpara_t * para)
 
     switch (para->just) {
     case 'r':
-       p.x -= para->width;
+       p.x -= para->size.x;
        break;
     case 'l':
        p.x -= 0.0;
        break;
     case 'n':
     default:
-       p.x -= para->width / 2.0;
+       p.x -= para->size.x / 2.0;
        break;
     }
     p.y += para->yoffset_centerline + para->yoffset_layout;
index b69563b0348e46c8d5a2b4f9b7914f4a325ead35..1ee2936337f2a2d8c6e01584fdbf50fbf12d130b 100644 (file)
@@ -240,8 +240,8 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
        logical_rect.height = 0;
 
     textlayout_scale = POINTS_PER_INCH / (FONT_DPI * PANGO_SCALE);
-    para->width = (int)(logical_rect.width * textlayout_scale + 1);    /* round up so that width/height are never too small */
-    para->height = (int)(logical_rect.height * textlayout_scale + 1);
+    para->size.x = (int)(logical_rect.width * textlayout_scale + 1);    /* round up so that width/height are never too small */
+    para->size.y = (int)(logical_rect.height * textlayout_scale + 1);
 
     /* FIXME  -- Horrible kluge !!! */
 
@@ -250,7 +250,7 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
      * Use an assumed height based on the point size.
      */
 
-    para->height = (int)(para->font->size * 1.1 + .5);
+    para->size.y = (int)(para->font->size * 1.1 + .5);
 
     /* The y offset from baseline to 0,0 of the bitmap representation */
 #if defined PANGO_VERSION_MAJOR && (PANGO_VERSION_MAJOR >= 1)