From baptiste.auguie at googlemail.com  Sat Apr 30 01:58:40 2011
From: baptiste.auguie at googlemail.com (baptiste auguie)
Date: Sat, 30 Apr 2011 11:58:40 +1200
Subject: [Rd] grid stringHeight
In-Reply-To: <BANLkTik0dL-oC8GzAqAJsNanZDF7LpndsA@mail.gmail.com>
References: <BANLkTik0dL-oC8GzAqAJsNanZDF7LpndsA@mail.gmail.com>
Message-ID: <BANLkTi=s04Ft8oVV077x8kLWW+hSuTLC+w@mail.gmail.com>

On 27 April 2011 11:06, baptiste auguie <baptiste.auguie at googlemail.com> wrote:
> Dear all,
>
> I'm puzzled by the behavior of stringHeight in the grid package.
> Consider the following test,
>
> library(grid)
>
> test <- function(lab="dog", ...){
> ?g1 <- textGrob(lab)
> ?g2 <- rectGrob(height=grobHeight(g1), width=grobWidth(g1))
> ?gg <- gTree(children=gList(g1,g2), ...)
>
> ?print(c("height:", convertUnit(stringHeight(lab), "mm", "y")))
> ?grid.draw(gg)
> }
>
> grid.newpage()
> test()
> test(expression(dog), vp=viewport(x=0.6))
> ## notice how the dog's tail is being cut off, where
> ## expression yields a snug cage
>
> grid.newpage()
> test("aoc")
> test(expression(aoc), vp=viewport(x=0.6))
>
> It appears that stringHeight correctly calculates the height for an
> expression, but not for a basic string. I think it used to produce the
> same output for both.
>
> Best regards,
>
> baptiste
>
> sessionInfo()
> R version 2.13.0 alpha (2011-03-27 r55076)
> Platform: i386-apple-darwin9.8.0 (32-bit)
>
> locale:
> [1] C
>
> attached base packages:
> [1] stats ? ? graphics ?grDevices utils ? ? datasets ?grid ? ? ?methods
> [8] base
>

I have now filed a bug report for this issue, though I could only
confirm it on one operating system.

https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14566

Best regards,

baptiste



[Rd] grid stringHeight
baptiste auguie