Skip to content

Problems using Computer Modern fonts

4 messages · Martin Maechler, Brian D'Urso

#
I have completed some work which allows fairly complete use of Computer
Modern fonts in R.

First, I have a quick bug fix to devPS.c: If an afm file could not be
loaded, R gives a "cannot read afm file" which should be followed by the
name of the file, but instead it is followed by garbage. Here is a patch
to devPS.c that fixes it:

1150c1150
< 	    warning("cannot read afm file %s", buf);
---
1156c1156
< 	warning("cannot read afm file %s", buf);
---
my system is:
platform i686-pc-linux-gnu
arch     i686
os       linux-gnu
system   i686, linux-gnu
status
major    1
minor    3.0
year     2001
month    06
day      22
language R

I think there may be similar problems with the error messages of the xfig
and pdf drivers, but I have not tried to understand them.

Before I send the pathches which allow use of CM fonts, I would like to
see whether there is interest in them or whether the changes I made would
be considered unacceptable. These changes allow CM fonts in
straight postscript output only. The basic idea is:

1) Extend the family option in the postscript driver to take a list of
five afm files instead of four. The fifth is for the symbol afm file. The
code changes for this are fairly clear.

2) Manipulate the CM fonts in the postscript file, merging them into new
fonts which are encoded with ISOLatin1 or Symbol encoding. This I
currently implemented by adding two new global variables like .ps.prolog.
One adds additional comments to the postscript file to allow the user
to request more resources in the postscript file, the second allows
the user to add commands to manipulate the fonts. When the second
variable is used, the default font reencoding is not used. This is not
very elegant and it leaves a lot up to the user, but the CM fonts are
really a special case and perhaps a function could be provided which sets
up the system for the CM fonts. The advantage is that this requires very
few changes to the original code.

3) Construct new afm files for the CM fonts which reflect the merged state
of the fonts that exist in the postscript file. I have done this, and
although it is not great to have to distribute customized afms, it is
simple to use now that it is done.

Currently I have this all working, although part (1) breaks old code that
doesn't specify a fifth afm file. This could of course be fixed by making
symbol added on if only four afms are given. Also changes reqired for (1)
may or may not break the other postscript related drivers.

What do you think? If you are interested, what is the best way for me to
package it up to submit it? Although the patches are small, the modified
afms are somewhat bulky to paste into email, but I have no experience with
cvs. Would an attached tarball of stuff be OK?

Thank you,
Brian D'Urso

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Brian> I have completed some work which allows fairly complete use of Computer
    Brian> Modern fonts in R.

    Brian> First, I have a quick bug fix to devPS.c: If an afm file could
    Brian> not be loaded, R gives a "cannot read afm file" which should be
    Brian> followed by the name of the file, but instead it is followed by
    Brian> garbage. Here is a patch to devPS.c that fixes it:

  1150c1150
  < 	    warning("cannot read afm file %s", buf);
  ---
  > 	    warning("cannot read afm file %s", p);
  1156c1156
  < 	warning("cannot read afm file %s", buf);
  ---
  > 	warning("cannot read afm file sy______.afm");

Thank, I've committed these for R-patched
       (and, could you please use  "diff -u" next time ?)

    ....

    Brian> I think there may be similar problems with the error messages of
    Brian> the xfig and pdf drivers, but I have not tried to understand
    Brian> them.

I've looked for them in devPS.c and fixed them analogously.
Can you tell me how to trigger them ??


    Brian>	<........... (omitted) ..........>

I do not really feel competent to answer your general question about the
usefulness of CM fonts via postscript() graphics.

In principle, I think it's a nice idea, since (La)TeX's default CM fonts
are still used quite a bit, and liked by many, and hence it would be quite 
neat to have the graphics using the same fonts.

As for how to `submit' your changes (*when* there is agreement that they
 are wanted): 
Consider putting up your code as *.tar.gz for FTP (or HTTP) and just
forward the URL to this list. 


Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Wed, 11 Jul 2001, Martin Maechler wrote:

            
They can be triggered by telling the postscript driver to load an afm file
that doesn't exist, e.g. :

postscript(family=c(doesnotexist1.afm, dne2.afm, dne3.afm, dne4.afm ), etc)

To trigger the problem with the pdf and xfig drivers, remove one of the
afm files from R's afm directory, e.g. hv______.afm and then use
family="Helvetica" in the pdf or xfig driver.


-- Brian D'Urso

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
7 days later
#
I have assembled the changes I have been working on to make TeX Computer
Modern fonts more fully usable in R. I have made the patches and support
files available at:

http://hussle.harvard.edu/~durso/CM_R.tar.gz

The diffs are against R-1.3.0. Let me know if there is a chance of these
changes being included in R or if you have any comments.

Thank you,
Brian D'Urso


My system:
----------
platform i686-pc-linux-gnu
arch     i686
os       linux-gnu
system   i686, linux-gnu
status
major    1
minor    3.0
year     2001
month    06
day      22
language R

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._