Skip to content

R CMD check and postscript fonts

6 messages · Brian Ripley, Johannes Graumann

#
Hello,
I came across this by using R cmd check - otherwise I would probably not have
noticed.
One of my functions does something like this:
# postscript()
# plot(1, xlim = c(0, 10), ylim = c(0, 4), type = "n", ann = FALSE, axes = FALSE)
# text(1:10, 2, c("a","b"), cex = seqcex, family="mono",font=2)

Which results in the error:
Error in text.default(1:10, 2, c("a", "b"), cex = seqcex, family = "mono",  : 
  family 'mono' not included in PostScript device

'mono' is perfectly fine for my x11 device and 
# postscriptFonts()$mono

gives me:
$family
[1] "Courier"

$metrics
[1] "Courier.afm"             "Courier-Bold.afm"       
[3] "Courier-Oblique.afm"     "Courier-BoldOblique.afm"
[5] "Symbol.afm"             

$encoding
[1] "default"

attr(,"class")
[1] "Type1Font"

That looks all right to me no? How to remedy this?

Thanks for your patience, Joh
#
On Thu, 24 Jan 2008, Johannes Graumann wrote:

            
Use the 'fonts' argument to postscript():

    fonts: a character vector specifying additional R graphics font
           family names for font families whose declarations will be
           included in the PostScript file and are available for use
           with the device. See Details.

  
    
#
Prof Brian Ripley <ripley <at> stats.ox.ac.uk> writes:
FALSE)
Hmmm, my actual function contains this bit ... any idea on how to solve this as
generic as possible? I do not want to make this require or prevent postscript as
the dev, but make the test (postscript) pass and enable future use of postscript
... where to put the 'fonts' unobtrusively, so that other devs will still work?

Joh

vectorsequence <- c("A","B")
xreq <- length(vectorsequence)

par(mar=c(1, 1, 1, 1) + 0.1)
plot(1, xlim = c(0, xreq), ylim = c(0, 4), type = "n", ann = FALSE, axes = FALSE)
text(1:xreq, 2, vectorsequence, cex = 2.5, family="mono",font=2)
#
On Thu, 24 Jan 2008, Johannes Graumann wrote:

            
It is device-specific.

  
    
#
Prof Brian Ripley wrote:

            
For now I'm going with 

if(names(dev.list())[length(dev.list())]=="postscript"){
  text(1:xreq, 2, vectorsequence, cex = seqcex, fonts="mono",font=2)
} else {
  text(1:xreq, 2, vectorsequence, cex = seqcex, family="mono",font=2)
}

and will extend as I eun into trouble with more devices. Thanks for your
help.

Joh
#
Johannes Graumann wrote:

            
This just gives me issues if someone wants to plot to a on-screen device
(like windows or x11) and uses the gui to export to postscript: the plot
was produced with the 'family' option, but the postscript device it is now
piped to will not take it. Is there any way I could code around this
generally?

Thanks, Joh