Re: PyDia and Metapost



On Wed, 2006-02-15 at 12:55 -0500, Rob McDonald wrote:
However, the vertical positioning still seems to be off by about the
height
of a lower case letter.  Baseline vs. character center.

             Rob

In render_metapost.c , in the function draw_string , there is a switch based
on Dia's alignment parameter.  The comment says

/* We use the "top" modifier to MetaPost's alignment because Dia draws
 * text _above_ the point at which the text is "located".  */

(sorry I don't have a line number, I'm browsing source in the online CVS.)

Consequently, the code uses the MetaPost commands

label.urt
label.top
label.ulft

For right, center, and left aligned text.  This would appear to be the right
thing to do.

However, when you position text in a box, it comes out wrong.  Manually
editing the *.mp file and replacing the above strings with

label.rt
label
label.lft

Gives the behavior I'd like to see (very close to where it appears on the
Dia screen.)

It's close, but not quite there, as text in Dia is rendered (from a
renderer point of view) at the baseline of the text, not the center, top
or bottom.  You can see in lib/diagdkrenderer.c how we get the text
ascent (unfortunately not a simple operation for raw text) and adjust
the y-pos for that to get the rendered rectangle.  I hope to get around
to doing a draw_text_line for metapost.

-Lars




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