Re: Metapost - text alignment

>It would be an excellent idea to implement draw_text_line.
>You should then be able to drop draw_text entirely and have
>draw_string call draw_text_line like in diagdkrenderer.

OK, I've taken more of a look. From my reading of DiaRenderer.c,
draw_text calls draw_text_line for each line. This is where the metapost
output becomes a problem - if I am rendering $A_{BC}$ in metapost,
centre aligned, then draw_text subtracts half the length
(text_line_get_alignment_adjustment) and tells render_metapost.c (via
either draw_text_line or draw_string) that it's left aligned at the
aligned_pos - then metapost renders the text in the wrong position
because the length correction was not really correct.

Am I reading the code correctly? Should I implement draw_text in
render_metapost.c so that I get to control the text positioning in the
metapost output? I'm in the "let the export renderer control the text
positioning" camp, if that makes more sense? I note that svg export also
effectively removes the alignment on export.

Unless DIA goes so far as to have some tight integration with a TeX
renderer, it will never be able to properly calculate the size of
$A_{BC}$, which makes proper centering impossible.

MetaPost has two commands for positioning text.   or   draw

The label command will do the left right positioning correctly, but it
is based on the bounding box, not the baseline, so it will not get the
vertical positioning correct.

The draw command is based on the left hand end of the baseline.
Vertical positioning will be correct, but unless you can calculate
text width, you won't get horizontal positioning right.

I am of the opinion that draw is the better way to go.  Most text will
not have special characters or formulas, so I think it is most
important to get the common case right (rather than none of them).  If
a user is using lots of special LaTeX formatting, then manually
adjusting the horizontal positioning isn't that big of a deal.

I'm sorry if I'm way off base as to your question.


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