timjencar / mscgen

Automatically exported from code.google.com/p/mscgen
GNU General Public License v2.0
0 stars 0 forks source link

boxes with double-line labels do not size correctly #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
msc {
  one,two,three;

  |||;
  one rbox one [label = "this is the\n first entity" ];
  |||;
  |||;
}

What is the expected output? What do you see instead?

I expect the box to resize vertically to accommodate the multi-line text.

It works for 3 or more lines, but not for two. The second text line is
crossed by the bottom line of the box.

What version of the product are you using? On what operating system?

0.17, Windows XP SP2

Please provide any additional information below, including sample input
file:

Original issue reported on code.google.com by magei...@googlemail.com on 2 Nov 2009 at 8:55

Attachments:

GoogleCodeExporter commented 9 years ago
Issue 39 has been merged into this issue.

Original comment by NThykier@gmail.com on 18 Apr 2010 at 7:50

GoogleCodeExporter commented 9 years ago
Hi

I had a look at the code (r108) and noticed a couple of statements like this:

  const unsigned int arcLabelLines = arcLabel ? countLines(arcLabel) : 1;

followed a bit later by:

  if(arcLabelLines > 2)
  {
      ymax += ((arcLabelLines - 2) * drw.textHeight(&drw));
  }

When I read the countLines code, I noticed that it the number of "\n" in the 
string
and not the "lines" in it. Which means that a label like "a\nb" will have the 
same
ymax as the label "a".
  This may be the intended behaviour, but it looks a bit odd.

The documentation for countLines is also a bit "self-conflicting":

/** Count the number of lines in some string.
 * This counts line breaks that are written as a litteral '\n' in the line.
 * ...
 * \retuns       The count of lines that should be output for the given string.
 */

The first line and the \returns claims it returns the number of lines, whereas 
the
second line suggest it just counts "\n". If the latter is true and the intended
behaviour, some of the code using countLines should be updated to add 1 to the 
result.
  Also \returns and literal appears to be misspelled.

~Niels

Original comment by NThykier@gmail.com on 18 Apr 2010 at 8:16

GoogleCodeExporter commented 9 years ago
Hi

I have played a bit with it and I have been able to create a patch that fixes 
the
"out of bounds" for box labels with 2 lines. I have attached it, my test case 
and the
results with the current mscgen (from trunk) and the ones with my patch (called 
+1).

mscgen handles 1 lined labels just fine in either case; but multi-line labels 
loses
their padding. This problem becomes much more apparent with my patch (since I 
could
not figure out how to use the extra space for padding).

Alternatively, you could alter the code slightly so that 1 lined labels are 
given a
few extra pixels and then I think it would render the bottom line okay. That 
being
said, I personally think it would look better if multi-lined labels were padded 
the
same way as single line labels.

Finally, I tried to make "countLines" return the number of lines (and not the 
number
of "\\n" in the label); unfortunately it makes mscgen repeat the last line and I
cannot figure out why (but I did not look too hard either).

~Niels

Original comment by NThykier@gmail.com on 28 Apr 2010 at 7:22

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by Michael....@gmail.com on 4 May 2010 at 11:53

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r111.

Original comment by Michael....@gmail.com on 16 Aug 2010 at 8:59