[R] Grid unit width and font face

Sébastien Bihorel pomchip at free.fr
Fri Aug 12 21:27:16 CEST 2011


Dear R-users,

When one defines a grid unit object using the 'strwidth' dimension, it
seems that the default plain font is assumed as the following example
illustrates. Is there a way to either make use of a font option when
creating a unit object or to know the factor that exists between the
width of the same text printed in plain and in bold? This might be
dependent on the font, though...

require(grid)

grid.rect(width=unit(1,'strwidth','Some text'),draw=T)

grid.text('Some text',draw=T)                                   # fits
nicely in the box
grid.text('Some text',y=0.4,gp=gpar(font=2),draw=T)  # partially outside the box

Thank you in advance for your input on this issue.

Sebastien



More information about the R-help mailing list