Hi Paul: I very much appreciate your spending the time to help me here, and I hope we will get a nice how-to document from this for other novices---or at least a google-able record in the r-help archive.
* The following is working R code to embed fonts, such as the lucida font family: afmfiles <- c("/usr/share/texmf/fonts/afm/yandy/lubright/lbr.afm", "/usr/share/texmf/fonts/afm/yandy/lubright/lbd.afm", "/usr/share/texmf/fonts/afm/yandy/lubright/lbi.afm", "/usr/share/texmf/fonts/afm/yandy/lubright/lbdi.afm", "/usr/share/texmf/fonts/afm/yandy/lumath/lbms.afm") # Set up the mapping for "lucida" font family postscriptFonts(lucida=postscriptFont("Lucida", metrics=afmfiles)) # Specify that the "lucida" font is to be used postscript(file="lu1.ps", fonts="lucida"); l<- 40:80; plot(l,l,pch=l); dev.off(); * The resulting file lu1.ps knows about Lucida fonts, e.g., $ grep LucidaBright-Demi lu1.ps %%+ font LucidaBright-Demi %%+ font LucidaBright-DemiItalic %%IncludeResource: font LucidaBright-Demi /LucidaBright-Demi findfont %%IncludeResource: font LucidaBright-DemiItalic /LucidaBright-DemiItalic findfont but is also still includes the Helvetica font family, even though my intent is to get rid of them. * In the same local directory, I have a Fontmap file (note capitalization; thank strace!), which is /LucidaBright (/usr/local/share/texmf/fonts/type1/yandy/lbr.pfb); /LucidaBright-Demi (/usr/local/share/texmf/fonts/type1/yandy/lbd.pfb); /LucidaBright-Italic (/usr/local/share/texmf/fonts/type1/yandy/lbi.pfb); /LucidaBright-DemiItalic (/usr/local/share/texmf/fonts/type1/yandy/lbdi.pfb); /LucidaNewMath-Symbol (/usr/local/share/texmf/fonts/type1/yandy/lbms.pfb); * I can now execute ghostscript, $ gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sPAPERSIZE=a4 -sOutputFile=testembed.pdf lu1.ps Loading NimbusSanL-Regu font from /usr/share/fonts/default/ghostscript/n019003l.pfb... 2614080 1177851 1691032 395776 0 done. Loading NimbusSanL-Bold font from /usr/share/fonts/default/ghostscript/n019004l.pfb... 2748280 1295559 1711216 410271 0 done. Loading NimbusSanL-ReguItal font from /usr/share/fonts/default/ghostscript/n019023l.pfb... 2862296 1345751 1691032 368290 0 done. Loading NimbusSanL-BoldItal font from /usr/share/fonts/default/ghostscript/n019024l.pfb... 2976312 1462430 1711216 382930 0 done. Loading StandardSymL font from /usr/share/fonts/default/ghostscript/s050000l.pfb... 3036864 1512937 1731400 392499 0 done. Loading LucidaBright font from /usr/local/share/texmf/fonts/type1/yandy/lbr.pfb... 3094128 1564220 1731400 379225 0 done. Loading LucidaBright-Demi font from /usr/local/share/texmf/fonts/type1/yandy/lbd.pfb... 3154680 1618028 1731400 386450 0 done. Loading LucidaBright-Italic font from /usr/local/share/texmf/fonts/type1/yandy/lbi.pfb... 3195048 1667744 1751584 396673 0 done. Loading LucidaBright-DemiItalic font from /usr/local/share/texmf/fonts/type1/yandy/lbdi.pfb... 3255600 1720688 1751584 403496 0 done. Loading LucidaNewMath-Symbol font from /usr/local/share/texmf/fonts/type1/yandy/lbms.pfb... 3316152 1776143 1751584 409361 0 done. which seems to indicate that the Fontmap file was found. (Adding a "-GS_FONTPATH=." to point to the local directory is not necessary.) * Alas, the output still does not have my Lucida fonts: $ pdffonts testembed.pdf name type emb sub uni object ID ------------------------------------ ------------ --- --- --- --------- Helvetica Type 1C yes no no 10 0 Also, looking at either lu1.ps or testembed.pdf with previewers shows that I am still using Helvetica fonts, not Lucida fonts. so something is still missing somewhere. (I also tried creating a pdf file directly under R, and though it gives me no error, and although the resulting pdf file claims to reference both helvetica and lucida fonts [and others], upon viewing, I can see that there are only helvetica fonts visible; no lucida fonts.) further help and advice would still be appreciated. Regards, /iaw -----Original Message----- From: Paul Murrell <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Sent: Tue, 30 Aug 2005 12:19:47 +1200 Subject: Re: [R] pdf font embedding --- again Hi [EMAIL PROTECTED] wrote: > Hi Paul: > > You are correct. it was the same little bug I hit on. Specifying the > full (not the symlinked) afm filenames lets me run the code. No R > error. yoohoo! > > alas, the files don't seem to come out right. I can use these commands > on the R postscript() and on the R pdf() device. they have an effect > on both. (that is, if I grep for lucida in the resulting ps or pdf > file, respectively, the word lucida appears in both files). alas, > usage is another story: Right, the fonts are referred to in the PostScript or PDF file, but no font information is embedded. Now we move to the second problem I mentioned, embedding the fonts. Can you try using ghostscript? (see my first post) Paul > $ pdffonts tonativepdf.pdf > name type emb sub uni object ID > ------------------------------------ ------------ --- --- --- --------- > 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 > LucidaBright Type 1 no no no 15 0 > LucidaBright-Demi Type 1 no no no 16 0 > LucidaBright-Italic Type 1 no no no 17 0 > LucidaBright-DemiItalic Type 1 no no no 18 0 > LucidaNewMath-Symbol Type 1 no no no 19 0 > > This is not so great. I had hoped to get rid of the Helvetica fonts > here. Moreover, if I run my "firsttops.ps" file through ps2pdf12, I > see > > $ ps2pdf12 firsttops.ps firsttops.pdf ; pdffonts firsttops.pdf > name type emb sub uni object ID > ------------------------------------ ------------ --- --- --- --------- > Helvetica Type 1 no no no 9 0 > > So, it seems that the lucida font is not used, and therefore optimized > away. > > regards, > > /ivo > > > --- > ivo welch > > -----Original Message----- > From: Paul Murrell <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED]; r-help@stat.math.ethz.ch > Sent: Tue, 30 Aug 2005 11:49:38 +1200 > Subject: Re: [R] pdf font embedding --- again > > Hi > > [EMAIL PROTECTED] wrote: > > > > Ooops. hit the button too soon. I have tried as arguments > variation of > the fonts and family arguments to postscript, such as > getting the case > right (i.e., lucida rather than Lucida). Alas > > > > postscript(file="test.ps", fonts="lucida"); > > *** glibc detected *** free(): invalid pointer: 0x0000000000f7dfb8 > *** > > > this is under R 2.1.1, 2005-06-20, built under gentoo from > scratch. > > > so, the problem is probably now internal, not the commands. I > guess I > will now investigate glibc in a little more detail... > > You might just be tickling the segfault you reported earlier (which > appears to happen [sometimes] when R cannot find the AFM files). > Try ... > > afmfiles <- c("/usr/share/texmf/fonts/afm/yandy/lubright/lbr.afm", > "/usr/share/texmf/fonts/afm/yandy/lubright/lbd.afm", > "/usr/share/texmf/fonts/afm/yandy/lubright/lbi.afm", > "/usr/share/texmf/fonts/afm/yandy/lubright/lbdi.afm", > "/usr/share/texmf/fonts/afm/yandy/lubright/lbms.afm") > > Paul > > > -----Original Message----- > > From: Paul Murrell <[EMAIL PROTECTED]> > > To: Paul Murrell <[EMAIL PROTECTED]> > > Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; > > r-help@stat.math.ethz.ch > > Sent: Tue, 30 Aug 2005 10:04:11 +1200 > > Subject: Re: [R] pdf font embedding --- again > > > Hi > > > Paul Murrell wrote: > > > Hi > > > > I think there are two problems: > > > > (i) You are specifying the font incorrectly. Try ... > > > > # You might need to specify full paths to these > > > afmfiles <- c("lbr.afm", "lbd.afm", "lbi.afm", "lbdi.afm", > "lbms.afm"); > > > # Set up the mapping for "lucida" font family > > > postscriptFonts(lucida=postscriptFont("Lucida", metrics=afmfiles)) > > > # Specify that the "lucida" font is to be used > > > postscript(file="test.ps", family="lucida"); > > > Thanks to Brian Ripley for pointing out that that should be ... > > > postscript(file="test.ps", fonts="lucida"); > > > > l<- 40:80; > > > plot(l,l,pch=l); > > > dev.off(); > > > > Should work for pdf() too. > > > > This should put a reference to the appropriate font in the > > PostScript or > PDF file that R creates. > > > > (ii) R does not embed font information. But you can, for > example, > use > ghostscript to do it, as long as you tell ghostscript > about the > font > too. You might have to set up a file 'FontMap' which > looks > something > like ... > > > > /Lucida (PATH_TO/lb___.pfb); > > > > ... (assuming that lb___.pfb is the name of the .pfb file for > the > Lucida > font). Then try something like (NOTE that you have to > specify > > >> GS_FONTPATH to tell ghostscript where your FontMap file is) ... > > > > > GS_FONTPATH=PATH_TO_FontMap gs -dBATCH -dNOPAUSE > -sDEVICE=pdfwrite > > >> -sPAPERSIZE=a4 -sOutputFile=testembed.pdf test.pdf > > > > > This should give you a file with the font info embedded and > then > you > should be able to include that in a LaTeX document. > > > > Paul > > > > p.s. Thanks for the segfault report. I will look at why that is > >>happening. > > > > > > [EMAIL PROTECTED] wrote: > > > >> Thank you---as always. > > >> > > >> still, I remain font-desparate. > > >> > > >> I would love to use the fonts from my book, but [a] I cannot > figure > >> out how to do this yet even in the R postscript device; and > [b] I am > >> using the R pdf device, not the postscript device. I > guess if I can > >> solve [a], then I can rewrite all my graphics > creations now into the > >> postscript device, and replace the > dev.off() with something that >> > follows it with ps2pdf. The > following attempt, however, does not work: > > >> > > >> afmfiles <- c("lbr.afm", "lbd.afm", "lbi.afm", "lbdi.afm", >> > > "lbms.afm"); > > >> Lucida <- postscriptFont("Lucida", metrics=afmfiles); > > >> postscript(file="test.ps", family=Lucida); > > >> l<- 40:80; > > >> plot(l,l,pch=l); > > >> dev.off(); > > >> > > >> By the way, if I try " postscript(family=afmfiles);" then I do > not > >> get an R error, but R 2.1.0 segfaults, which is probably not > >> > desirable. This occurs even if there is no .afm file in the > current >> > directory. > > >> > > >> > > >> Can I make a suggestion to the R team? It would be nice if I > could > >> specify a pdf() device parameter that says "choose font > settings to > >> embed all fonts" (i.e., do not use fonts that cannot > be embedded, >> > either). Something that guarantees me that I get a > figure that I can >> > give to someone that is fully specified. Right > now, accomplishing >> > this is not easy to figure out, and perhaps not > even possible. Yes, >> > in the list of font families that R recognizes > are some fonts that do >> > not seem among the 13 standard fonts (such > as URWbookman). moreover, >> > if I choose it as my pdf font family, it > is smart enough to use a >> > different symbol file ('StandardSymL'), > which I hope is also open and >> > not adobe. If so, they could be used > in principle. How do I get R to >> > embed URWbookman? ZapfDingbats > always seems to be included, so I hope >> > this is open and > embeddable. > > >> > > >> more help would be highly appreciated. > > >> > > >> Regards, > > >> > > >> /iaw > > >> --- > > >> ivo welch > > >> > > >> -----Original Message----- > > >> From: Prof Brian Ripley <[EMAIL PROTECTED]> > > >> To: [EMAIL PROTECTED] > > >> Cc: r-help@stat.math.ethz.ch > > >> Sent: Mon, 22 Aug 2005 17:07:14 +0100 (BST) > > >> Subject: Re: [R] pdf font embedding --- again > > >> > > >> On Mon, 22 Aug 2005 [EMAIL PROTECTED] wrote: > > >> > > >> > > > >> > dear R wizards--- I would like to do some book-on-demand > printing > > >>> at a > >> > > >> > popular printer named lulu, but lulu requires inclusion even of > the > > >> > basic postscript fonts. Interestingly, my book itself does not > need > > >> > the 14 base acrobat fonts, only the embedded R figures do. Of > course, > > >> > I really would like to get pdftex to embed the fonts, but how > to do > > >> > this is not obvious either. [This method seems to be what the R > help > > >> > page is indicating... The software including the PostScript > plot file > > >> > should either embed the font outlines (usually from '.pfb' or > '.pfa' > > >> > files) or use DSC comments to instruct the print spooler to do > so.) > > >> > > >> Why not use the fonts your book does use in the figures? (That's > how > > >> my books are done.) > > >> > > >> > So, I would really, really like to embed the necessary fonts > with > > >>> the R > >> > > >> > figures. I first reread the discussion in this mailing list > about > > >> > (eps) font embedding earlier this year. This was ultimately not > very > > >> > helpful. First, I do not know how to instruct my embedding > program to > > >> > include the fonts that R figures want. Second, I already start > with > > >> > the pdf device, so distilling eps files is not a good > option--and it > > >> > would seem a bit crazy to first use the wrong output device > > >> > (postscript), then ship my files over to a windows machine > somewhere > > >> > that has distiller installed, run distiller by hand, then ftp > them > >> back > > >> > to my linux machine---just for getting the fonts embedded. > > >> > > > >> > Is it impossible to get R to embed the necessary fonts in its > pdf > > >> > output? > > >> > > >> Yes, as it has no access to them. They are not Open Source. You > may > > >>> be able to use URW clones, depending on their licensing > conditions. > >> > > >> > > >> -- Brian D. Ripley, [EMAIL PROTECTED] > > >> 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 > > >> > > >> ______________________________________________ > > >> R-help@stat.math.ethz.ch mailing list > > >> https://stat.ethz.ch/mailman/listinfo/r-help > > >> PLEASE do read the posting guide! >> > > http://www.R-project.org/posting-guide.html > > > > > > > -- Dr Paul Murrell > > Department of Statistics > > The University of Auckland > > Private Bag 92019 > > Auckland > > New Zealand > > 64 9 3737599 x85392 > > [EMAIL PROTECTED] > > http://www.stat.auckland.ac.nz/~paul/ > > > > -- Dr Paul Murrell > Department of Statistics > The University of Auckland > Private Bag 92019 > Auckland > New Zealand > 64 9 3737599 x85392 > [EMAIL PROTECTED] > http://www.stat.auckland.ac.nz/~paul/ > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html