[Rd] Postscript font bugs (and a suggestion) (PR#914)

dmurdoch@pair.com dmurdoch@pair.com
Sat, 14 Apr 2001 02:39:56 +0200 (MET DST)


Documentation and other bugs with postscript():

1.  This code crashes R (it asks for a font that isn't there):

 postscript()
 plot(0:1,0:1)
 text(0.5,0.5,'crash',font=6)


The bug appears to be in the FixupFont routine in plot.c; on line 236,
it checks that the font number is in the range 1..32.  Later this
crashes PostScriptStringWidth in devPS.c, because only fonts numbered
1..5 are actually defined.  I don't know how to fix it.


2.  The ?postscript help topic refers to .ps.profile; the actual
variable name is .ps.prolog.  The C source in main/devPS.c has this
on lines 606-608, with the incorrect name in the error message:

    prolog = findVar(install(".ps.prolog"), R_GlobalEnv);
    if(!isString(prolog))
	error("Object .ps.profile is not a character vector");


3.  And this is a suggestion, not a bug:  I'd like to change the font 
definitions by changing the .ps.prolog instructions, but devPS.c puts
the     

   PSEncodeFont(fp, encoding);

line after the place where .ps.prolog is written to the file.  If
.ps.prolog were last, then it could override any standard setting.
This would mean that the font metrics would not be quite right, but it
would be useful for experimenting.

This patch addresses items 2 and 3 in src/main/devPS.c:

606,608c606,609
<     prolog = findVar(install(".ps.prolog"), R_GlobalEnv);
<     if(!isString(prolog))
< 	error("Object .ps.profile is not a character vector");
---
>     PSEncodeFont(fp, encoding);
>     prolog = findVar(install(".ps.prolog"), R_GlobalEnv);
>     if(!isString(prolog))
> 	error("Object .ps.prolog is not a character vector");
613d614
<     PSEncodeFont(fp, encoding);

and this addresses item 2 in src/library/base/postscript.Rd:

116c116
<   vector \code{.ps.profile}.  This is marked in the output, and can
be
---
>   vector \code{.ps.prolog}.  This is marked in the output, and can be



--please do not edit the information below--

Version:
 platform = i386-pc-mingw32
 arch = x86
 os = Win32
 system = x86, Win32
 status = 
 major = 1
 minor = 2.2
 year = 2001
 month = 02
 day = 26
 language = R

Windows 9x 4.0 (build 1111)  B

Search Path:
 .GlobalEnv, package:ctest, Autoloads, package:base


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._