Re: [Rd] documentation error par("cin") and par("cra") (PR#7227)

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 15 Sep 2004 - 01:06:50 EST


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

______________________________________________
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Sep 15 01:28:50 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:15 EST