[Rd] Bug using X11 on mac osx (for jpeg or png creation) (PR#10800)

Hin-Tak Leung hin-tak.leung at cimr.cam.ac.uk
Wed Feb 20 23:33:47 CET 2008


That being documented behavior, I still find the documented behavior
somewhat inconvenient: the fact that some code I interactively tested
does not run in the same way in batch mode.

My own solution involves running a separate semi-permanent Xvfb process
and let R CMD BATCH uses the virtual X server; but I do wish that
jpeg()/png() would work the same way - or at least in a similiar way
transparently with or without X11. I know of the bitmap(), but my wish
would be to *using the exact same functions* in interactive/batch mode.
bitmap() doesn't quite work the same as jpeg()/png(), nor is Xvfb
gives identical result to the console X server (due to resolution/dpi 
configuation differences). The thing is, WYSIWYG, matching font sizes
relative to plots, etc, can only be done visually, and then everything
changes in batch mode... so in the end, I do pdf's in interactive 
sessions and look at them with a separate viewer (pdf/ps not dependent 
on X11), and if there are too many dots, etc I rasterize it through 
ghostscript to keep the file size down. None of these are too convenient.

Prof Brian Ripley wrote:
> On Tue, 19 Feb 2008, Benilton Carvalho wrote:
> 
>> It's not a bug and it is my understanding that it's documented.
>>
>> From the man page on jpeg:
>>
>>   They may not be usable unless the X11 display is available to the owner of 
>> the R process.
>>
>> and later:
>>
>>    'bitmap' provides an alternative way to generate PNG and JPEG
>>    plots that does not depend on accessing the X11 display but does
>>    depend on having GhostScript installed.  (Devices 'GDD' in CRAN
>>    package 'GDD' and 'CairoJPEG' / 'CairoPNG' in CRAN package 'Cairo'
>>    are alternatives using several other additional pieces of
>>    software.)
>>
>> So, the idea is to replace your jpeg() call by bitmap() (with the appropriate 
>> "type" argument.
> 
> He may have a slightly different version: he seems to have access to X11 
> but no fonts available.  That is not an R bug: it may well be an Apple 
> bug (we've seen similar things on Ubuntu, and there are lots of known 
> issues with Apple's X11).
> 
> [BTW: it is better to report the exact French messages: we can look them 
> up in the translations database.  Or even better, start R with LANGUAGE=en 
> and report the English message.  I suspect this one is
> 
>      could not find any X11 fonts\nCheck that the Font Path is correct.
> 
> as that seems the closest match.  And if so the advice in that English 
> message is the key to solving this.]
> 
>> b
>>
>> On Feb 19, 2008, at 8:25 AM, bonneaud at enib.fr wrote:
>>
>>> Full_Name: Stephane Bonneaud
>>> Version: 2.6.2
>>> OS: OSX - Leopard 10.5.2
>>> Submission from: (NULL) (195.221.233.130)
>>>
>>>
>>> Hello,
>>>
>>> I have a R code file containing the following code:
>>>
>>> -------
>>> # This code is in r2jpg.r
>>> # myData is filled here with some data from a file
>>> jpeg(filename="test.jpg",width=960,height=720,pointsize=16,quality=100)
>>> plot(myData,xlab="anything", ylab="whatever",type="b",col="red", lwd=4)
>>> dev.off()
>>> -------
>>>
>>> I executed this code within both the R GUI and the command line. When 
>>> launched
>>> through the R GUI (Mac OS X Cocoa GUI - GUI 1.22-devel (4844) (4844)),
>>> everything works just fine. The JPEG file is generated just I want. Great!
>>> The problem is when I try to execute the code through the command line in
>>> Terminal (OSX).
>>> I execute my code using the following command :
>>> cat r2jpg.r | R --silent --no-restore --no-save
>>>
>>> And I get the following error:
>>>
>>>> jpeg(filename="test.jpg",width=960,height=720,pointsize=16,quality=100)
>>> can't find X11 font
>>> Error in X11(paste("jpeg::", quality, ":", filename, sep = ""), width,  :
>>> impossible to start the peripheral JPEG
>>> Calls: jpeg
>>>
>>> (Sorry, I translated the error messages from french so it might be a little
>>> different in english. If needed I can print it in english though)
>>>
>>> I saw that several persons had this problem, but did not find any proper
>>> solution. Therefore, I tried to launch my command from xterm (still in OSX) 
>>> and
>>> not in Terminal, and it worked. There is definitely an issue with R getting 
>>> the
>>> proper environment variables for X11 or something like that when launched 
>>> from
>>> the command line in Terminal.
>>> When you launch the GUI, OSX detects it will need X11 (or something like 
>>> this
>>> :b), therefore all proper env variables are charged. From xterm, obviously 
>>> the
>>> proper env variables are set.
>>>
>>> How could R tell OSX to link with X11 when launched from command line in
>>> Terminal?
>>>
>>> PS: sorry, it might be a leopard bug, but I thought somebody could be 
>>> interested
>>> in the R community. And maybe R developers might actually be able to do
>>> something.
>>>
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list