dmurdoch@pair.com
2001-Apr-14 00:39 UTC
[Rd] Postscript font bugs (and a suggestion) (PR#914)
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian D Ripley
2001-Apr-14 06:33 UTC
[Rd] Postscript font bugs (and a suggestion) (PR#914)
On Sat, 14 Apr 2001 dmurdoch@pair.com wrote:> 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)Only on Windows, I think. This works fine on Unix.> 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(1..32 on Windows, 1..4 elsewhere.)> crashes PostScriptStringWidth in devPS.c, because only fonts numbered > 1..5 are actually defined. I don't know how to fix it.I've added a range check in PS_StrWidth.> 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");Done.> 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.Why not use the way which is supported, to supply a user-specifed family? For experimenting the easiest way surely is to edit the postscript file. -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._