Mark Van De Vyver
2004-Mar-16 06:41 UTC
[Rd] Changing ComputerModern in postscript(...): A first attempt at contributing....
Hi First off, thanks to all the various R developers, your package is very impressive. I'm not sure what the protocols are for contributing, and I've not done this before, so please excuse nay obvious errors or oversights... Also I'm by no means an R,TeX/LaTeX, or typesetting expert, I have largely stumbled my way to this point. Objective: I'd like to get R postscript(...) to generate output that has the TeX italic font when I use italic(...) in an R graphic. I found out that the R postscript(..font="ComputerModern") outputs slanted text when the R function italic(..) is used in a graphic. I think the text should use the italic font. For a quick overview of italic vs. slant vs. oblique see http://www.eyewire.com/magazine/columns/robin/italic/ A response from Brian Ripley pointed me to the src/main/devPS.c file, and I traced this behaviour to the use of the slanted/oblique afm font files, rather than the italic afm font files. Anyway, I did some homework and realised that making the change may not be too difficult, except for needing the Computer Modern afm font files - not included in MikTeX (on my machine at least). Fortunately the Latin Modern fonts do include the afm files and are supposed to be an improvement over Computer Modern, so I thought to make both changes; update/replace Computer Modern with Latin Modern, and change the font used when italic text is output. I read on one OpenSource project that they prefer patches generated from "diff -u4". I couldn't see explicit instructions on the R web site so I've attached a "diff -u4" file. Adopting this patch would require adding the following Latin Modern afm font files to the R afm fonts folder: lmr10.afm lmbx10.afm lmri10.afm lmbxi10.afm These fonts are available in the Latin Modern Fonts package. To find out about Latin Modern see http://www.tex.ac.uk/cgi-bin/texfaq2html?label=uselmfonts Note, I had to leave the CM_symbol_10 file since I'm not sure that there is a Latin Modern replacement? Unfortunately I wasn't able to build R using Cygwin (configure works OK but make fails), so I have not been able to test the changes. I'll keep looking into getting R to build, but in the mean time I thought someone may be interested in the changes? I think the change I made means that font="ComputerModern" still works but outputs Latin Modern fonts and this is misleading, so perhaps drop "ComputerModern" in favour of "LatinModern" and/or obtain Computer Modern italic afm font files and update CM_italic_10.afm and CM_boldx_italic_10.afm. I'm not a font pro but it seems that converting between different font files is not so straight forward, but the Computer Modern italic afm files may be available to someone? HTH Mark Mark Van De Vyver B.Bus(Hons), PhD(Dist) Lecturer Finance Discipline School of Business Faculty of Economics and Business Economics & Business Building H69 The University of Sydney Sydney NSW 2006 Australia Telephone: +61 2 9351-6452 Fax: +61 2 9351-6461 Mobile: 0428 281407 mailto:mvdv@spamcop.net http:\\www.econ.usyd.edu.au
Prof Brian Ripley
2004-Mar-16 08:52 UTC
[Rd] Changing ComputerModern in postscript(...): A first attempt at contributing....
We don't in general add things like this, and you can just use the family= mechanism to set things up as you like. We added Computer Modern as several people wanted fonts to match the standard TeX fonts. We don't want to change that. (I believe we did so before we had a general mechanism to use a user-specified family.) Note that the `italic' font is principally intended to set whole titles in italic (via font=) and most people prefer oblique for that -- R's standard graphics font, Helevetica, uses oblique not italic. To reiterate: all you need to do is prepare suitable .afm fonts and specify family= as a five-path character string. Professor Ripley On Tue, 16 Mar 2004, Mark Van De Vyver wrote:> Hi > First off, thanks to all the various R developers, your package is very > impressive. > > I'm not sure what the protocols are for contributing, and I've not done this > before, so please excuse nay obvious errors or oversights... Also I'm by no > means an R,TeX/LaTeX, or typesetting expert, I have largely stumbled my way > to this point. > > Objective: I'd like to get R postscript(...) to generate output that has the > TeX italic font when I use italic(...) in an R graphic.All you need to do is to set the family= argument.> I found out that the R postscript(..font="ComputerModern") outputs slanted > text when the R function italic(..) is used in a graphic. I think the text > should use the italic font. > For a quick overview of italic vs. slant vs. oblique see > http://www.eyewire.com/magazine/columns/robin/italic/ > > A response from Brian Ripley pointed me to the src/main/devPS.c file, and I > traced this behaviour to the use of the slanted/oblique afm font files, > rather than the italic afm font files.That's what *I* said, so your tracing should have amounted to reading my email! It's not quite correct either: R uses the afm file to know what font name to insert in the postscript file.> Anyway, I did some homework and realised that making the change may not > be too difficult, except for needing the Computer Modern afm font files > - not included in MikTeX (on my machine at least).They are on CTAN.> Fortunately the Latin Modern fonts do include the afm files and > are supposed to be an improvement over Computer Modern, so I thought to make > both changes; update/replace Computer Modern with Latin Modern, and change > the font used when italic text is output. > > I read on one OpenSource project that they prefer patches generated from > "diff -u4". I couldn't see explicit instructions on the R web site so I've > attached a "diff -u4" file. > > Adopting this patch would require adding the following Latin Modern afm font > files to the R afm fonts folder: > lmr10.afm > lmbx10.afm > lmri10.afm > lmbxi10.afm > > These fonts are available in the Latin Modern Fonts package. To find out > about Latin Modern see > http://www.tex.ac.uk/cgi-bin/texfaq2html?label=uselmfonts > Note, I had to leave the CM_symbol_10 file since I'm not sure that there is > a Latin Modern replacement?It would also require re-encoding them as they are not in a standard encoding. That's why the CM*.afm files there have different names. (The symbol font is in a completely different encoding.)> Unfortunately I wasn't able to build R using Cygwin (configure works OK but > make fails),R cannot be built under Cygwin -- please do RTFM.> so I have not been able to test the changes. I'll keep looking > into getting R to build, but in the mean time I thought someone may be > interested in the changes?Which you haven't tested, I gather?> I think the change I made means that font="ComputerModern" still works but > outputs Latin Modern fonts and this is misleading, so perhaps drop > "ComputerModern" in favour of "LatinModern" and/or obtain Computer Modern > italic afm font files and update CM_italic_10.afm and > CM_boldx_italic_10.afm. I'm not a font pro but it seems that converting > between different font files is not so straight forward, but the Computer > Modern italic afm files may be available to someone?They are available to everyone. -- Brian D. Ripley, ripley@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