From ripley at stats.ox.ac.uk  Tue Feb 26 08:00:47 2008
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue, 26 Feb 2008 07:00:47 +0000 (GMT)
Subject: [Rd] New version of X11, png and jpeg
In-Reply-To: <509e0620802251736q6427b796ycdc4068d1d849b5a@mail.gmail.com>
References: <alpine.LFD.1.00.0802201933470.25534@gannet.stats.ox.ac.uk>
	<509e0620802251736q6427b796ycdc4068d1d849b5a@mail.gmail.com>
Message-ID: <alpine.LFD.1.00.0802260624460.22361@gannet.stats.ox.ac.uk>

Michael,

> Would it be at all feasible to make the cairo backend available on
> all platforms and have it provide a public API through which an
> arbitrary cairo context could be passed as the drawing target?

Offering an API is something I have considered for the TODO for 2.8.0. 
However, we are at the stage of finding out how widely this can be got to 
work and how well it works.

Simon and I are working on MacOS X, and should have this working via a 
static cairo build (without pango) shortly.  I don't think cairo on 
Windows works well enough: e.g. your Cairo() device has more than half the 
glyphs missing in the symbol font.

Brian


On Mon, 25 Feb 2008, Michael Lawrence wrote:

> On Mon, Feb 25, 2008 at 10:56 AM, Prof Brian Ripley <ripley at stats.ox.ac.uk>
> wrote:
>
>> R-devel has new versions of the X11(), png() and jpeg() devices on
>> Unix-alikes.  The intention is that these are used identically to the
>> previous versions (which remain available) but will produce higher-quality
>> output with more features.
>>
>> Pros:
>>
>> Antialiasing of text and lines (can be turned off) but no blurring of
>> fills.
>>
>> Buffering of the X11 display and fast repainting from a backing image.
>> (The intention is to emulate the timer-based buffering of the windows()
>> device in due course, but not for 2.7.0.)
>>
>> Ability to use translucent colours, including backgrounds, and produce
>> partially transparent PNG files.
>>
>> Scalable text, including to sizes like 4.5 pt. This allows more accurate
>> sizing on non-standard screen sizes (e.g. my home machine has a 90dpi
>> 1650x1024 display whereas standard X11 fonts are set up for 75 or 100
>> dpi).
>>
>> Full support for UTF-8, so on systems with suitable fonts you can plot in
>> many languages on a single figure (and this will work even in non-UTF-8
>> locales).  The output should be locale-independent (unlike the current
>> devices where even English text is rendered slightly differently in
>> Latin-1 and UTF-8 locales).
>>
>> A utility function savePlot() to make a PNG/JPEG/TIFF copy of the current
>> plot.
>>
>> The new png() and jpeg() devices do not require an X server to be running.
>>
>> Cons:
>>
>> Needs more software installed - cairo, pango and support packages
>
>
> Would it be at all feasible to make the cairo backend available on all
> platforms and have it provide a public API through which an arbitrary cairo
> context could be passed as the drawing target? That would allow e.g.
> cairoDevice to be a much simpler module that draws the cairo context to a
> GTK+ window and manages the window and events. In that case, it would need
> to be renamed to 'gtkDevice2' or something.
>
> Michael
>
> (which
>> on all the systems we have looked at are pulled in by the packages checked
>> for).  You will see something like
>>
>>   Additional capabilities:   PNG, JPEG, iconv, MBCS, NLS, cairo
>>                                                           ^^^^^
>> if configure finds the software we are looking for.
>>
>> Slower under some circumstances (although on the test systems much faster
>> than packages Cairo and cairoDevice).  This will be particularly true for
>> X11() with a slow connection between the machine running R and the X
>> server.
>>
>> The additional software might not work correctly.
>>
>>
>> The new versions are not currently the default, but can be made so by
>> setting X11.options(type="Cairo"), e.g. as a load hook for package
>> grDevices.  I am using
>>
>> setHook(packageEvent("grDevices", "onLoad"),
>>     function(...) {
>>         grDevices::ps.options(horizontal=FALSE)
>>         if(getRversion() >= '2.7.0') grDevices::X11.options(type="Cairo")
>>     })
>>
>>
>> Please try these out and let us know how you get on.  As a check, try the
>> TestChars() examples in ?points - on one Solaris 10 system a few of the
>> symbol font characters were incorrect.  It worked on an FC5 system with
>>
>> auk% pkg-config --modversion pango
>> 1.12.4
>> auk% pkg-config --modversion cairo
>> 1.0.4
>>
>> so the versions required are not all recent.
>>
>> Although these devices would in principle work on Mac OS X, neither cairo
>> nor pango is readily available.  We are working on other versions for
>> Mac OS (X11 based on cairo/freetype, png/jpeg based on Quartz).
>>
>> There are also new svg() and tiff() devices.
>>
>> --
>> Brian D. Ripley,                  ripley at stats.ox.ac.uk
>> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/<http://www.stats.ox.ac.uk/%7Eripley/>
>> University of Oxford,             Tel:  +44 1865 272861 (self)
>> 1 South Parks Road,                     +44 1865 272866 (PA)
>> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>

-- 
Brian D. Ripley,                  ripley at 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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] New version of X11, png and jpeg
Prof Brian Ripley