[R] Mix font families in a single label?

Paul Murrell p.murrell at auckland.ac.nz
Thu Aug 20 05:26:31 CEST 2009


Hi

I can't necessarily do elegant, but see
https://stat.ethz.ch/pipermail/r-help/2009-August/208092.html
(Solution 4) for an example of setting up two different fonts within a 
single font "family" on PDF (PostScript is very similar) and using 
plotmath to produce text that uses the two different fonts.

Paul


Marc Chiarini (Tufts) wrote:
> Dear R-help community:
> 
> I have been searching for an elegant solution to the question posed in
> my subject.  I would like to be able to use any of the R functions like
> text() or mtext() to display some text with mixed font families.  For
> example, a label like "huge-class background load", where the word
> "huge" is in Courier and the rest is in the default family (or any other
> family for that matter).  I will ultimately be saving to EPS files, so I
> know the correct families need to be included when I open the device. 
> So far I have fiddled with plotmath to no avail.  I also know that I can
> place the first and remaining words with separate calls to a text
> function and something like strwidth() for proper positioning, but I
> never quite seem to get that right.  I suppose that the family needs to
> be taken into account to compute the string width, and that doesn't seem
> to happen.  Is there an easier way that does the calculations automatically?
> 
> Any help is much appreciated.
> 
> Regards,
> Marc
> 
> 

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




More information about the R-help mailing list