[R] Fonts, Plus

ivo welch ivo_welch at mailblocks.com
Thu Nov 10 15:44:49 CET 2005

Dear R Wizards:

sorry, I need more help.  hopefully, it will help others in the future. 
I am using R 2.2.0 Patched (2005-11-07 r36217).


# copy from the postscriptFont documentation
CMitalic <- postscriptFont("ComputerModern",
               c("CM_regular_10.afm", "CM_boldx_10.afm",
                 "cmti10.afm", "cmbxti10.afm",

# trying this one out.  I copied the syntax that worked for lucida
pdf(file="test.pdf", fonts="CMitalic", version="1.4");
plot( c(0,1),c(0,1) );
myeq <- bquote((w[I]==.(1/7)));
text( 0.5, 0.3, myeq );
text( 0.5, 0.7, "this is computer modern");

Now, pdffonts test.pdf (from the xpdf distribution) gives me

$ pdffonts test.pdf
name                                 type         emb sub uni object ID
------------------------------------ ------------ --- --- --- ---------
Error (4149): Dictionary key must be a name object
Error (4152): Dictionary key must be a name object
ZapfDingbats                         Type 1       no  no  no       5  0
Helvetica                            Type 1       no  no  no      10  0
Helvetica-Bold                       Type 1       no  no  no      11  0
Helvetica-Oblique                    Type 1       no  no  no      12  0
Helvetica-BoldOblique                Type 1       no  no  no      13  0
Symbol                               Type 1       no  no  no      14  0
CMR10                                Type 1       no  no  no      15  0
CMBX10                               Type 1       no  no  no      16  0
CMTI10                               Type 1       no  no  no      17  0
CMBXTI10                             Type 1       no  no  no      18  0
Error (4149): Dictionary key must be a name object
Error (4152): Dictionary key must be a name object
CMSY10                               Type 1       no  no  no      19  0

so, something is still wrong.


I am looking at the docs for postscriptFonts.  ?postscriptFonts.  May I
suggest that we add two or three more lines to show usage?  something
like "plot(c(0,1),c(0,1)); text(0.2, 0.5, "hello", font=2); dev.off()". 
More generally, a documented sample example file that shows usage of
many/multiple postscript fonts and families within one graph would be a
great help.

This is of course all just my own ignorance.  In general, I am not yet
sure about the whole font syntax.  I wonder what a font="something"
statement in the plot statement itself does.  I believe the
"par(family=)" changes the font used for the figure [e.g., axis labels],
although I am wondering why I am giving a string ["CMItalic"] rather
than a variable [CMItalic].  the ?text documentation does not have an
example of font selection, especially if I want to mix multiple fonts
and from different font families.


how do I tell a CMD BATCH not to execute the site file?  "R
--no-init-file" works only interactively.  ( Would it not make sense to
allow this options also for CMD BATCH?)  I probably have an incorrect
installation, because the suggestion from "R --help" fails for me

$ R CMD command --help
/usr/local/lib64/R/bin/Rcmd: line 45: exec: command: not found

However, R CMD BATCH my.R works just fine.

Further suggestion: let's have an abbreviation for --no-init-file, too;
e.g., "-I".

[d] regarding my earlier suggestion of a variable that contains the
currently executing file, I know I can put an argv0 <- "filename" into
each file, but it would be nice if this happened automatically and was
available everywhere.  just a suggestion...

please don't see the above as a complaint.  R is great, and the effort
you guys put in is terrific.  It's just that I am struggling with the
syntax here, and this one is not easy to figure out.



More information about the R-help mailing list