Quantcast

How to enable Arial font for postcript/pdf figure on Windows?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

How to enable Arial font for postcript/pdf figure on Windows?

Agnès Paquet
Hi,

I need to generate some figure using the Arial font as a requirement for
PLoS.
Following their guidelines, I have converted the windows font files
arial.tff files to .afm using tff2afm (exec file from MikTeX), but when I
try to generate a postcript file, the postcript device does not recognize
the .afm files.

The code I use to test the new font is the following:

postscript(file="try.ps", horizontal=F,
onefile=F,
width=4, height=4,
family=c("C:/MyDoc/arial.afm",
"C:/MyDoc/arialbd.afm",
"C:/MyDoc/ariali.afm",
"C:/MyDoc/arialbi.afm"),
pointsize=12)
hist(rnorm(100))
dev.off()
And I get the warnings:
In postscript(file = "try.ps", horizontal = F, onefile = F,  ... :
  unknown AFM entity encountered
 Is there another way to convert .tff files into .afm on Windows, or any
other way to use Arial in pdf/postcript on Windows?

Thank you very much,

Agnes

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to enable Arial font for postcript/pdf figure on Windows?

Camille
Hi Agnes,

I converted the Arial font files from ttf to afm using ttf2afm from MikTex complete installation.

When used in R with the line recommended by Plos, they seem to give correct Arial font graphics: I checked by opening the ps file with a viewer (gsview), a text editor (notepad++) and Adobe illustrator.
However I did not try (but hopefully will do soon) the ultimate test:  submission to Plos.

Here is a way to do it: (Mind the trick at step 5)

1) Download ttf2afm.exe (available for ex in the install directory of MikTex complete installation)
2) Fetch the arial ttf files in C:\Windows\Fonts
3) Place ttf2afm.exe and the ttf files in a directory (eg C:/ttf2afm/)
4) Open a DOS window (using cmd). Place yourself into the created directory (using cd). Then type

ttf2afm.exe arial.ttf > arial.afm
ttf2afm.exe arialbd.ttf > arial-Bold.afm
ttf2afm.exe ariali.ttf > arial-Oblique.afm
ttf2afm.exe arialbi.ttf > arial-BoldOblique.afm

5) Now, if you used ttf2afm.exe from MikTex you should open the created afm files with a text editor (ex Notepad++) and correct the following things:
• Remove the copyright line (or make it start zith comment and get rid of the (c) copyright symbol )
• At the beginning of 4 of the first lines, the variable name is missing, so add it. Eg in arial.afm:
o FontName ArialMT
o FullName Arial
o FamilyName Arial
o Weight Normal

 Now you can use these fonts with the postscript function in R with the following line:
postscript(file="try.ps", horizontal=F, onefile=F, width=4, height=4, pointsize=12,
family=c (
“C:/ttf2afm/arial.afm",
“C:/ttf2afm/arial-Bold.afm ",
“C:/ttf2afm/arial-Oblique.afm ",
“C:/ttf2afm/arial-BoldOblique.afm "
)
)
hist( rnorm(100) )
dev.off()

Cheers,
Camille
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to enable Arial font for postcript/pdf figure on Windows?

antagomir
Hi Agnes and Camille (and help-list),

In Ubuntu 11.10 I needed to use su permissions to copy and gzip the *.afm files manually into "/usr/lib/R/library/grDevices/afm/" to get the Arial embedding to work in R for postscript.

Ie. after following the instructions by Agnes and Camille, I did
  sudo cp arial*.afm /usr/lib/R/library/grDevices/afm/
  gzip /usr/lib/R/library/grDevices/afm/arial*.afm

Then the postscript toy example in this thread worked.

Leo
Loading...