]> granicus.if.org Git - graphviz/commitdiff
Fix # 1300 - add support for labelloc=[t|c|b] in nodes
authorellson <devnull@localhost>
Mon, 3 Mar 2008 19:23:44 +0000 (19:23 +0000)
committerellson <devnull@localhost>
Mon, 3 Mar 2008 19:23:44 +0000 (19:23 +0000)
lib/common/labels.c
lib/common/shapes.c

index a87142c9b0ace196f6219ea7574f2e271deaf617..caa58443ffb6288c7e46eee268bdcd3c81ec96f6 100644 (file)
@@ -203,7 +203,7 @@ void emit_label(GVJ_t * job, emit_state_t emit_state, textlabel_t * lp)
     right_x = center_x + halfwidth_x;
 
     /* position for first para */
-    p.y += lp->dimen.y / 2. - lp->fontsize;
+    p.y += (lp->dimen.y + lp->d.y) / 2.0 - lp->fontsize;
 
     gvrender_begin_context(job);
     gvrender_set_pencolor(job, lp->fontcolor);
index 021ef3f673e10e475d26112f69c3d4c5306820c8..59a84167a2f22e082794578e2c509dbc2076a261 100644 (file)
@@ -855,9 +855,16 @@ static void poly_init(node_t * n)
     /* adjust text justification */
     if (!mapbool(late_string(n, N_nojustify, "false"))) {
        if (width > bb.x)
-               ND_label(n)->d.x = width - bb.x;
-       if (height > bb.y)
+           ND_label(n)->d.x = width - bb.x;
+       if (height > bb.y) {
+           p = agget(n, "labelloc");
+            if (p && (p[0] == 'b'))
+               ND_label(n)->d.y = -(height - bb.y);
+           else if (p && (p[0] == 't'))
                ND_label(n)->d.y = height - bb.y;
+           else
+               ND_label(n)->d.y = 0;
+       }
     }
 
     /* increase node size to width/height if needed */