xfig device (was [Rd] Re: [R] MetaPost device?)

Prof Brian D Ripley ripley@stats.ox.ac.uk
Tue, 11 Apr 2000 07:25:50 +0100 (BST)

On Tue, 11 Apr 2000, Telford Tendys wrote:

> > Even to plot "threshold" centred you need to know its width and height and
> > depth: see GText.
> In xfig you can choose for a string to be centered and then give it
> the string and the centre-point and it figures out the rest, it also
> outputs this correctly centred despite font variations.

Eh?  R allows proportional centring (adj can be between 0 and 1) and my
point was that the R driver model *requires* the knowledge. As I said, see
the code for GText.

> Admittedly, just being able to centre-justify a string doesn't solve
> the problem of plotting an equation but it might help in a few cases...
> Also, there is a ghostscript operator for getting the width of a string:
> stringwidth
>      * USAGE:   str stringwidth
>      * RESULTS   x y
>      calculates the change in the current point which would occur using
>      "show", but doesn't actually draw the string
> [http://www.colorado.edu/ITS/docs/scientific/gs/GSO.html]
> Running up gs in the background in order to do font calculations
> seems a bit messy but it would be easy to achieve and it kind of fits
> with the unix philosophy of each program does it's own job well and
> doesn't try to overlap its neighbour. Maybe it is fair to presume that
> the win-32 users don't want xfig output? They probably want ms-draw or
> something...

It's not fair, and they also want postscript and the code for this in
postscript is already internal to R (less kerning, it seems).

My point, which you seem to have missed, is that existing code for font
metric information could be used in an xfig driver.

> > As I understand it plotmath computes the locations of the pieces ("alpha"
> > and "threshold" and "i" in the example) and outputs them as separate
> > strings.  And as far as I can see plotmath does not use kerning information
> > (look at RenderStr in plotmath.c) to find the string's bounding box, even
> > though the postscript renderer will.  Similar, the GStrWidth for the 
> > postscript device just adds up the character widths and so ignores kerning.
> Yeah, I've noticed that some of the R outputs don't look quite as good as
> latex but they still look better than just about any other plotter. Sometimes
> I get latex to splat the formulas down onto the diagrams which is a dirty
> trick but the reader of the printed copy only sees the end result not the
> method.
> > Finding char info from tfm files is easy: there is lots of example code.
> > 
> > For an xfig device one could (at least initially) use the existing 
> > information on postscript fonts, and only allow those to be used in the
> > device.  I think the same applies to a metapost device.
> Which would make the xfig-device depend on having tex installed which seems
> kind of illogical but no worse than insisting that gs in installed. Most
> people who use xfig also use both tex and gs. Perhaps R could look around
> for tfm files, use them if it finds them, and resort to counting the
> characters if it can't think of anything better to do (i.e. some output
> with small kerning errors is better than no output at all).

Eh? If we restrict to postscript fonts we can use the afms which we already
have. There would be no need for tex at all.

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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch