joehl@gmx.de
2004-Sep-14 16:10 UTC
[Rd] documentation error par("cin") and par("cra") (PR#7227)
Dear all, the help of par() claims that cin and cra are c(width, height) but it appears to be rather c(height, width) Best regards Jens Oehlschl?gel> plot.new() > strheight("W", unit="inches")[1] 0.1354167> par("cin")[1] 0.1354167 0.1875000> version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 9.1 year 2004 month 06 day 21 language R --
Prof Brian Ripley
2004-Sep-14 17:07 UTC
[Rd] documentation error par("cin") and par("cra") (PR#7227)
On Tue, 14 Sep 2004 joehl@gmx.de wrote:> the help of par() claims that > cin and cra are > c(width, height)That is the design intention.> but it appears to be rather > c(height, width)On what evidence? W has no descenders, so its height is less than the typical box. It's coincidence, BTW, that the numbers are the same: I get> par("cin")[1] 0.15 0.20> strheight("W", unit="inches")[1] 0.1196667 and characters are on average taller than they are wide. strheight reports the same for all characters, but strwidth does not. Here is the code (in par.c) else if (streql(what, "cin")) { value = allocVector(REALSXP, 2); REAL(value)[0] = Rf_dpptr(dd)->cra[0]*Rf_dpptr(dd)->ipr[0]; REAL(value)[1] = Rf_dpptr(dd)->cra[1]*Rf_dpptr(dd)->ipr[1]; } cra is set in the driver, and postscript has dd->cra[0] = 0.9 * pointsize; dd->cra[1] = 1.2 * pointsize; whereas windows() has gcharmetric(xd->gawin, xd->font, -1, &a, &d, &w); dd->cra[0] = w * xd->rescale_factor; dd->cra[1] = (a + d) * xd->rescale_factor; so it really is (width, height). OTOH, strheight doesn't look at the character, just the height of "M" (no descenders). See the comment /* cra is based on the font pointsize at the * time the device was created. * Adjust for potentially different current pointsize * This is a crude calculation that might be better * performed using a device call that responds with * the current font pointsize in device coordinates. */ /* Add in the ascent of the font, if available */ -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595