[Rd] Fixed width graphics font?

Paul Murrell p.murrell at auckland.ac.nz
Sat Feb 14 20:19:06 MET 2004


Hi


Simon Urbanek wrote:
> 
> On Feb 13, 2004, at 11:46 AM, Peter Dalgaard wrote:
> 
>> Duncan Murdoch <dmurdoch at pair.com> writes:
>>
>>> On Thu, 12 Feb 2004 20:50:38 -0500, you wrote:
>>>
>>>>
>>>> Is there any way to get a fixed width plot in graphs?  I want to put 
>>>> a text
>>>> matrix into a plot and this would make it easy.
>>>
>>>
>>> In the Windows device, fonts 10 and 11 are fixed width "Courier New".
>>> In general graphics devices don't have to supply such a font.
>>
>>
>> In particular, I don't think it is possible in the postscript and x11
>> devices (unless you switch the basic fonts in postscript). It
>> shouldn't be hard to add, though -- basically just add a Courier font
>> at font positions 6, and maybe continue with bold and oblique
>> variants. However, I wouldn't know whether any of what Paul has been
>> up to involves a more radical solution to font handling in general.
> 
> 
> The current R-devel graphics device API supports font family name - I 
> just didn't check yet which parameter is used to set it (fontfamily?).


I have added fontfamily to the "graphics context" information that can 
be passed from the graphics engine to graphics devices.  Two rather 
important things remain to be done:

(i) the devices need to do something with this information.  As Duncan 
Murdoch pointed out, Windows already allows something similar via a 
device-specific approach to the existing font parameter.  I have 
suggested (but not yet tried to implement) a more device-independent 
approach in http://www.stat.auckland.ac.nz/~paul/R/gpars.html (linked 
off the "R Developer" web page).  I haven't really had feedback on this 
suggestion yet and I intended to elicit more before hacking any code.

(ii) the graphics systems (base and grid) need to allow the user to set 
this information.  grid has a fontfamily gpar, but base has nothing yet. 
  Again a suggested implementation is in 
http://www.stat.auckland.ac.nz/~paul/R/gpars.html and there is a bit 
more in http://www.stat.auckland.ac.nz/~paul/R/fonts.html

Going back to the original question, for Windows, postscript, and pdf at 
least, if you have a mono-spaced font on your system you should be able 
  to use it, but the way in which you specify it will differ (see the 
docs for each device).  In future versions this should become as simple 
as specifying the appropriate font name as a par() for all devices.

Paul
-- 
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-devel mailing list