Re: [R] problem with Hershey fonts

From: Paul Murrell <p.murrell_at_auckland.ac.nz>
Date: Wed 27 Jul 2005 - 09:14:21 EST

Hi

Ray Brownrigg wrote:
> This was reported to me by a colleague in China, so I may not be
> reproducing exactly what they are seeing (which I suspect is rw2011), but
> this is what I see:
>

>>version

>
> _
> platform i386--netbsdelf
> arch i386
> os netbsdelf
> system i386, netbsdelf
> status
> major 2
> minor 1.1
> year 2005
> month 06
> day 20
> language R
>
>>help(Hershey)

>
> :
> :
> If the 'vfont' argument to one of the text-drawing functions
> ('text', 'mtext', 'title', 'axis', and 'contour') is a character
> vector of length 2, Hershey vector fonts are used to render the
> text.
> :
> The other useful escape sequences all begin with '\\'. These
> are described below. Remember that backslashes have to be
> doubled in R character strings, so they need to be entered
> with _four_ backslashes.
> :
> :
>
>>plot(runif(100)) # to get something on the screen >>text(0, 1, '\\Re', vfont=c('serif', 'plain')) # works >>title(main = '\\Re', vfont=c('serif','plain')) # doesn't work, and...

>
> Warning message:
> parameter "vfont" could not be set in high-level plot() function
>
>>mtext('\\Re', 2, vfont=c('serif','plain'))	# doesn't work, but...

>
> Warning message:
> Hershey fonts not yet implemented for mtext() in: mtext(text, side, line, outer, at, adj, padj, cex, col, font,
>
>>axis(3, at=50, tick=F, labels='\\Re', vfont=c('serif','plain'))	# doesn't work 

>
>
> Now at least mtext() 'redeems' itself with its Warning, but title()
> contradicts the help(Hershey), and axis() just gets it wrong by printing
> the characters "\Re" (or "\\Re" when the string is specified as
> '\\\\Re' as alluded to in the Hershey documentation - but somewhat
> contradicted by the success of the text() call above).
>
> Now perhaps the problem is just with the Hershey documentation (or my
> reading of it), but I don't know what is supposed to work. Or is there
> some combination that I haven't tried?

The problem with title() has been reported before (PR#7031), but thanks for pointing out the extension to axis() and mtext() as well.

The "good" news is that the 'vfont' argument has been superseded. It was a horrible way of incorporating Hershey fonts (I should know, I did it) and a much better way now exists via par(family=). The following modification of your example should work:

plot(runif(100)) # to get something on the screen oldf <- par(family="HersheySerif")
text(0, 1, '\\Re')
title(main = '\\Re')
mtext('\\Re', 2)
axis(3, at=50, tick=F, labels='\\Re')
par(oldf)

The bad news is that, as you point out, the documentation is lacking. I will make some updates so that this solution is easier to find in future.

Paul

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Jul 27 09:17:51 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:34:02 EST