Re: More MetaPost text positioning....




Hans,

I'm not sure what final solution you settled on for #331491, but wouldn't
you know it, things seem more nasty than I had thought.... (you probably
came to this conclusion yourself.)

When I try to use a UML diagram, because each of the lines in the middle
box
are positioned separately, they end up not being spaced evenly.

It turns out that MetaPost positions text based on the bounding box of
that
particular text element.  So, the left, right, top, bottom, etc. commands
are difficult to apply correctly.  I.E. if you position the words: dog cat
sea This puny.  And you try to align them by their tops, bottoms, or
middles, you'll get a zigzag of words.  Some poke down, some poke up, some
do both, and some do neither....

To me this is lousy design of MetaPost, so I'm going to ask for a
workaround
in comp.text.tex (If you want to follow any discussion).

If we come to some sort of answer, I'll let you know.  The only solution I
see right now would be to typeset all 'related' text in one shot, that way
it is properly aligned from the start.  Then, it would need to be
positioned
all at once.  I'm not a fan of this approach because of its obvious lack
of
robustness and general hackish nature.

Ok, I got an answer from the good people at comp.text.tex .  Would you like
me to append this to the previous bug, or open a new one, or what?

As the label command (and all its variants) are based on positioning text by
the coordinates of its bounding box, it is impossible to get precisely
controlled text layout (using that command) in MetaPost.

Instead, you have to use the (less powerful) draw command...  It is less
powerful because draw won't take care of left, right, center positioning for
you.  You'll have to calculate that yourself...

For an example of a list of attributes in a UML diagram.

So, instead of this:

label.urt(btex {\usefont{OT1}{cmr}{m}{n} dog} etex scaled 1.0,
(0.0x,0.00y));
label.urt(btex {\usefont{OT1}{cmr}{m}{n} cat} etex scaled 1.0,
(0.0x,0.35y));
label.urt(btex {\usefont{OT1}{cmr}{m}{n} sea} etex scaled 1.0,
(0.0x,0.70y));
label.urt(btex {\usefont{OT1}{cmr}{m}{n} This} etex scaled 1.0,
(0.0x,1.05y));
label.urt(btex {\usefont{OT1}{cmr}{m}{n} puny} etex scaled 1.0,
(0.0x,1.40y));

We need to do this...

draw btex {\usefont{OT1}{cmr}{m}{n} dog} etex scaled 1.0 shifted
(5.0x,0.00y);
draw btex {\usefont{OT1}{cmr}{m}{n} cat} etex scaled 1.0 shifted (5.0x,
0.35y);
draw btex {\usefont{OT1}{cmr}{m}{n} sea} etex scaled 1.0 shifted
(5.0x,0.70y);
draw btex {\usefont{OT1}{cmr}{m}{n} This} etex scaled 1.0 shifted
(5.0x,1.05y);
draw btex {\usefont{OT1}{cmr}{m}{n} puny} etex scaled 1.0 shifted
(5.0x,1.40y);

The 'x' coordinate difference is just to separate the two columns of text.
The 'y' values are separated by 0.35cm (the font size).  Using the draw
command with the shifted transformation, you position text by the left end
of the baseline.

Using the label.??? command, you position text such that its bounding box is
positioned ??? relative to the coordinate point.  In this case, label.urt
means the bounding box is up and to the right of the specified coordinates.

While left-right-center will take some special handling (although Dia must
do this someplace already), this should be an answer once and for all...
There were some hackish fixes suggested where you insert an invisible
character that reaches to the top of the tallest and the bottom of the
lowest character.

Thanks,

             Rob




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]