[Tikzdevice-bugs] metapost device: problem with calculating font space?
Charlie Sharpsteen
chuck at sharpsteen.net
Tue Apr 26 01:37:49 CEST 2011
On Thu, Apr 21, 2011 at 10:09 PM, Charlie Sharpsteen
<chuck at sharpsteen.net>wrote:
> On Thu, Apr 21, 2011 at 2:57 AM, Matthieu Stigler <
> matthieu.stigler at gmail.com> wrote:
>
>> Hi
>>
>> This metapost() is really nice, thanks again Charlie and Cameron!!
>>
>> I'm encountering a problem that arises typically with metapost but not
>> tikz(): when legend is horinzontal, there is a problem of spacing, as well
>> as tick mark below the text. Can you confirm?
>>
>> library(tikzDevice)
>>
>> metapost("~/temp/regimes.tex")
>> plot(runif(100))
>> legend(0,1, lty=1, leg=c("High regime probability","Future prices") ,
>> bty="n", horiz=TRUE, lwd=1, bg="white")
>> dev.off()
>>
>
> This is most likely due to the fact that I did not implement any metric
> calculations for the Metapost device---it simply uses the results by
> computed by LaTeX for TikZ which are not correct but better than nothing.
>
>
> Also, do you think you would extend the font size calculation for
>> metapost() too soon? Would be so useful!!
>>
>
> I pushed some changes that should help although a complete solution will
> be difficult to do in a short period of time. One place where MetaPost
> is decidedly worse than TikZ is access to font info. With TIkZ we can
> extract all sorts of useful information such as the ascent and descent of
> characters. With MetaPost, the only clear parameter that can be clearly
> extracted is the overall height of the text box. So, text may not
> vertically center exactly as it should---but things like legends will at
> least look passable.
>
I just pushed an update that enables proper font metric calculation with
both ascent and descent being returned. Also, I found that MetaPost has
an inherent "label offset" that was causing text to be placed a short
distance away from where R wanted it to be. I turned this off so legend
titles should no longer be smashed up against the top of their boxes and
text should be vertically centered. Things are still slightly off as I
cannot find a good way in MetaPost to anchor strings at their baselines
rather than the bottom of their bounding boxes.
If you have a permanent metrics dictionary, you will need to delete it so
that the tikzDevice will re-calculate these new values.
-Charlie
More information about the Tikzdevice-bugs
mailing list