[Rd] Sweave, cairo_pdf, CJK, ghostscript
hintak_leung at yahoo.co.uk
Fri Oct 28 23:35:55 CEST 2011
Reading ?RWeaveLatex more carefully, I worked out that the outcome I want could be achieved without patching R, by having this towards the beginning:
cairo <- function(name, width, height, ...)
grDevices::cairo_pdf(file = paste(name, "pdf", sep = "."),
width = width, height = height)
Then declaring grdevice= like this:
grid.text("\u4F60\u597D", y=2/3, gp=gpar(fontfamily="CNS1"))
So all is well. is there any chance of either updating ?RWeaveLatex with this actual use-case example, or make it easier with the attached patch (and updated version of what I did, just adding the corresponding documentation)? I thought there might be a a use for cairo_ps() as well, but then most people who can do latex could do pdflatex, especially those who has cairo installed.
FWIW, besides Chinese, I am doing Tibetan and Arabic as well - needed/wanted those two for Sichuan (south-western China) and Ningxia (northern western, just south of Mongolia).
--- On Sun, 23/10/11, Hin-Tak Leung <htl10 at users.sourceforge.net> wrote:
> --- On Sat, 22/10/11, Prof Brian
> Ripley <ripley at stats.ox.ac.uk>
> > On Sat, 22 Oct 2011, Duncan Murdoch
> > wrote:
> > > On 11-10-21 8:57 PM, Hin-Tak Leung wrote:
> > >> I have had some fun in the last few days
> trying to
> > put together an annotated map of China with R and
> > public GIS data:
> > >>
> > >> http://sourceforge.net/projects/outmodedbonsai/files/snpMatrix%20next/126.96.36.199/China_Choropleth_Maps.pdf/download
> > >>
> > >> It is done, and rather nice... there are a
> > issues:
> > >>
> > >> - the default pdf() device cannot do CJK
> > embedded fonts - and cairo_pdf() is not hooked up to
> > yet. I have had a quick look, and it does not look
> > complicated, other than the fact that cairo_pdf() is
> > mutually exclusive with pdf(); and the jpeg/png are
> new to
> > 2.13 so it is probably just nobody has gotten round to
> > (and cairo_pdf() also behaves differently with the
> > option). I guess I am almost saying I might get my
> > dirty or help somebody else who wants to. So it is
> > best to start some discussion.
> > >
> > > It is not hard to write your own device
> > especially in 2.14.0. See rgl::rgl.Sweave for an
> > example.
> > And guess what the example in the Sweave manual
> > cairo_pdf() ...
> I don't want a new device - I just wanted cairo_pdf() to be
> hooked up to Sweave as an alternative to the default pdf().
> See my later post with the patch against R trunk and
> the worked examples.
> It looks like cairo_pdf() is just using my current
> fontconfig settings.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3261 bytes
Desc: not available
More information about the R-devel