Graphviz Issue Tracker
Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001224graphvizDotpublic2007-12-23 06:002011-04-28 04:03
ReporterPander 
Assigned Toellson 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOS*-*-OS Version
Summary0001224: Left align of node labels incorrect when fixedsize=true
Description



Left align of node labels when using \l is incorrect when fixedsize=true, without fixedsize=true there is no problem.



Below is code for reproducing the problem. The result is that label of node b is aligned left but the center of the label is aligned with the left side of the node, not the centre of the node. Please fix this.
Steps To Reproduce

digraph "test" {
    a [label="a\lmm\li\l" height=1 ]
    b [label="b\lmm\li\l" height=1 fixedsize=true ]
}
Additional Information

[ellson] This is reproducible in the latest code, but it looks like a very old bug.


The error in label position is introduced at lib/common/shapes.c:791
commenting out this entire "if" clause corrects the position for this test case,
but I don't understand the nojustify logic enough to understand if this is the right fix?
<CD>
   /* adjust text justification */
   if (!mapbool(late_string(n, N_nojustify, "false"))) {
       ND_label(n)->d.x = bb.x - dimen.x;
       ND_label(n)->d.y = bb.y - dimen.y;
   }
</CD>

d.x is used in just one place that I could find, lib/common/labels.c:199

<CD>
   /* dimensions of box for label, no padding, adjusted for resizing */
   halfwidth_x = (lp->dimen.x + lp->d.x) / 2.0;
</CD>

[ellson] I've put a fix into CVS that I think fixes this.


Emden,

The fix is in "cvs diff -r 1.81 lib/common/shapes.c"

Do you have a regression test for "nojustify" that you can run against this
to make sure I haven't broken it?

[pander] It works, thanks. Also the version in CVS. However, now the size of the
node has grown compared to the situation before the bugfix. Is this
intended or a unwanted side effect?

[ellson] The size of the node is right, given fixedsize=true, but the position of the label is different between the two nodes.

I'm not sure that this is wrong. With fixedsize=true there are no guarantees that the text will fit inside
the node shape, so using the node left/right boundaries for text justification would have some strange effects, e.g. if a text
block contained lines wider than the node and both \l and \r justification. The current behavior, with fixedsize=true,
is that the justified text block is centered on the node without considering its width.

With the default fixedsize=false, we make an effort to align the left/right justification with the node width.
TagsNo tags attached.
AUXILLARY-FILES
DATE-FIXED
FIX-COMMENT
FORMER-ID1255
INPUT-FILE
OUTPUT-FILE
STATUS-COMMENTFixed (24 Dec 2007)
VERSION     2.12
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2011-04-28 04:03 user1 New Issue
2011-04-28 04:03 user1 Assigned To => user695


MantisBT 1.2.5[^]
Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker