Re: Metapost - text alignment



On Mon, 2007-01-29 at 08:36 -0800, Rob McDonald wrote: 
On 1/29/07, Lars Clausen <lars raeder dk> wrote:
As I see it, there's two possible situations:  Either the text is plain
text or it's a LaTeX formula (of some kind).  The formulas we have no
chance to fit correctly until a separate LaTeXObject is introduced (which
could start out as a clone of TextObject) which the MetaPost renderer can
handle specially.  Plain text we actually have a chance to not just
position right, but also have a reasonable width of -- which is used in
the diagram, for sizing boxes etc.  If we always leave the size to
LaTeX/MP, the output is 99% guaranteed to be different from what you see
in Dia.  If we give LaTeX/MP the size (width!), any plain text will be
just as in Dia, but formulas will need fixing.

For the plain text case:

Your plan works if you are perfectly exact in calculating the width of
the text.  However, if you get a slightly different result from the
text rendered in LaTeX, you will wreak havoc.  Lets say you can
predict the text width within 1%.  If you use my MetaPost macro to
force the text to fit your estimated width, you will end up with
inconsistent results.  Some text, you underpredict its width, so the
macro shrinks it slightly.  Some text, you overpredict its width, so
the macro grows it slightly.  What you end up with is subtle (random)
variations in the font size throughout the document.

Rather than changing font size (which we have had bad experiences with),
can't we just have each text line be fitted in a LaTeX box of the
appropriate size?  Then we can make use of LaTeX's fine kerning
abilities to get the width right, and font size wouldn't suffer.

On the other hand, if you leave things the way they are...  You can
use your 1% error estimate of text width within DIA to calculate
position, box size, etc.  You can output these diagrams and let
MP/LaTeX handle the text sizing.  All text will have exactly the same
(deterministic) font size.  However, things like the margins in a box
drawn around text will be subtlety wrong.  When I do a flowchart, I
usually pick a box size big enough to surround all of my text.  I then
use a consistent box size, even if sometimes it means the margins are
larger than others.  So, for me, slight variations in the margins are
unimportant.

Unfortunately, 1% is when we're lucky.  I've seen many cases of 10%
difference or more.  I'll show you samples as soon as I get the metapost
thing to work.

Of course, for truly complex LaTeX text, we don't have any hope of
calculating the size inside of DIA until we integrate a LaTeX renderer
into DIA in some way.

Indeed.

-Lars




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