Hi all, I would like to add phonetic symbols in my figures. Usually I typeset my documents in LaTeX and I use the tipa [1] package to get International Phonetic Alphabet (IPA) fonts. So, my problem would be solved if I could insert LaTeX commands in the text() function (I guess at least). I would like to avoid using psfrag (that is, inserting a string in the eps figure and then substituting it with the right symbol with dvips) because I would like to work with pdf pictures and pdflatex as well as latex -> dvips -> ps2pdf. If inserting special fonts is not possible at the moment, I would appreciate some hints on how I could go about modifying text() to include this feature. (This is why I post to r-devel instead of r-help) Thank you! Giampiero [1] http://www.essex.ac.uk/linguistics/clmt/latex4ling/tipa/
Phonetic symbols (IPA) in R graphics
8 messages · Giampiero Salvi, Paul Murrell, Hin-Tak Leung +1 more
Hi
Giampiero Salvi wrote:
Hi all, I would like to add phonetic symbols in my figures. Usually I typeset my documents in LaTeX and I use the tipa [1] package to get International Phonetic Alphabet (IPA) fonts. So, my problem would be solved if I could insert LaTeX commands in the text() function (I guess at least). I would like to avoid using psfrag (that is, inserting a string in the eps figure and then substituting it with the right symbol with dvips) because I would like to work with pdf pictures and pdflatex as well as latex -> dvips -> ps2pdf.
Take a look at ... Fonts, lines, and transparency in R graphics. R News, 4(2):5-9, September 2004. Non-standard fonts in PostScript and PDF graphics. R News, 6(2):41-47, May 2006. http://www.stat.auckland.ac.nz/~paul/Talks/fonts.pdf Paul
If inserting special fonts is not possible at the moment, I would appreciate some hints on how I could go about modifying text() to include this feature. (This is why I post to r-devel instead of r-help) Thank you! Giampiero [1] http://www.essex.ac.uk/linguistics/clmt/latex4ling/tipa/
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/
Hi Paul,
I tried the following from your slides, perhaps you can see the
error:
1) I downloaded the fonts and the encoding file into the directories
Type1 and encodings (in my current directory)
2) I ran R from the same directory (ver 2.4.0)
3) I added the font mapping for the pdf and postscript devices:
ipa <- Type1Font("InternationalPhoneticAlphabet",
c("Type1/tipa10.afm",
"Type1/tipabx10.afm",
"Type1/tipasi10.afm",
"Type1/tipabx10.afm"),
"encodings/silipa.enc")
pdfFonts(ipa=ipa)
postscriptFonts(ipa=ipa)
4) I created a simple figure:
plot(10,10,type="n")
text(10,10,"whatever",family="InternationalPhoneticAlphabet")
Here I get 13 warnings of the type:
"font family not found in X11 font database"
As far as I understand this is because I defined the fonts only for
the postscript and pdf devices.
5) I copy the device to postscript:
dev.copy2eps(file="whatever.eps")
Here I get the real problem:
Error in dev.copy(file = "whatever.eps", device = function (file =
ifelse(onefile, :
invalid character sent to 'PostScriptCIDMetricInfo' in a
single-byte locale
I googled for PostScriptCIDMetricInfo but only found a few pages in
Japanese, can you help me?
Thanks,
Giampiero
I can put the font and encoding files somewhere if necessary.
I am working on a RedHat linux computer with locale:
LANG=en_US.iso88591
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=C
On Thu, 14 Dec 2006, Paul Murrell wrote:
Hi Giampiero Salvi wrote:
Hi all, I would like to add phonetic symbols in my figures. Usually I typeset my documents in LaTeX and I use the tipa [1] package to get International Phonetic Alphabet (IPA) fonts. So, my problem would be solved if I could insert LaTeX commands in the text() function (I guess at least). I would like to avoid using psfrag (that is, inserting a string in the eps figure and then substituting it with the right symbol with dvips) because I would like to work with pdf pictures and pdflatex as well as latex -> dvips -> ps2pdf.
Take a look at ... Fonts, lines, and transparency in R graphics. R News, 4(2):5-9, September 2004. Non-standard fonts in PostScript and PDF graphics. R News, 6(2):41-47, May 2006. http://www.stat.auckland.ac.nz/~paul/Talks/fonts.pdf Paul
If inserting special fonts is not possible at the moment, I would appreciate some hints on how I could go about modifying text() to include this feature. (This is why I post to r-devel instead of r-help) Thank you! Giampiero [1] http://www.essex.ac.uk/linguistics/clmt/latex4ling/tipa/
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Hi
Giampiero Salvi wrote:
Hi Paul,
I tried the following from your slides, perhaps you can see the
error:
1) I downloaded the fonts and the encoding file into the directories
Type1 and encodings (in my current directory)
2) I ran R from the same directory (ver 2.4.0)
3) I added the font mapping for the pdf and postscript devices:
ipa <- Type1Font("InternationalPhoneticAlphabet",
c("Type1/tipa10.afm",
"Type1/tipabx10.afm",
"Type1/tipasi10.afm",
"Type1/tipabx10.afm"),
"encodings/silipa.enc")
pdfFonts(ipa=ipa)
postscriptFonts(ipa=ipa)
4) I created a simple figure:
plot(10,10,type="n")
text(10,10,"whatever",family="InternationalPhoneticAlphabet")
Here I get 13 warnings of the type:
"font family not found in X11 font database"
As far as I understand this is because I defined the fonts only for
the postscript and pdf devices.
Exactly. The process would be simpler if you drew directly to PostScript or PDF via postscript() or pdf(). Also, the text() call should be ... text(10,10,"whatever",family="ipa")
5) I copy the device to postscript:
dev.copy2eps(file="whatever.eps")
Here I get the real problem:
Error in dev.copy(file = "whatever.eps", device = function (file =
ifelse(onefile, :
invalid character sent to 'PostScriptCIDMetricInfo' in a
single-byte locale
I googled for PostScriptCIDMetricInfo but only found a few pages in
Japanese, can you help me?
I'm not sure how you got there. You've specified the family wrong so I would expect more "family not found" warnings. Let me know if this persists with the correct family specified. Paul
Thanks, Giampiero I can put the font and encoding files somewhere if necessary. I am working on a RedHat linux computer with locale: LANG=en_US.iso88591 LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" LC_COLLATE="C" LC_MONETARY="C" LC_MESSAGES="C" LC_PAPER="C" LC_NAME="C" LC_ADDRESS="C" LC_TELEPHONE="C" LC_MEASUREMENT="C" LC_IDENTIFICATION="C" LC_ALL=C On Thu, 14 Dec 2006, Paul Murrell wrote:
Hi Giampiero Salvi wrote:
Hi all, I would like to add phonetic symbols in my figures. Usually I typeset my documents in LaTeX and I use the tipa [1] package to get International Phonetic Alphabet (IPA) fonts. So, my problem would be solved if I could insert LaTeX commands in the text() function (I guess at least). I would like to avoid using psfrag (that is, inserting a string in the eps figure and then substituting it with the right symbol with dvips) because I would like to work with pdf pictures and pdflatex as well as latex -> dvips -> ps2pdf.
Take a look at ... Fonts, lines, and transparency in R graphics. R News, 4(2):5-9, September 2004. Non-standard fonts in PostScript and PDF graphics. R News, 6(2):41-47, May 2006. http://www.stat.auckland.ac.nz/~paul/Talks/fonts.pdf Paul
If inserting special fonts is not possible at the moment, I would appreciate some hints on how I could go about modifying text() to include this feature. (This is why I post to r-devel instead of r-help) Thank you! Giampiero [1] http://www.essex.ac.uk/linguistics/clmt/latex4ling/tipa/
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/
Hi Paul, first thank you for helping out.
On Fri, 15 Dec 2006, Paul Murrell wrote:
Exactly. The process would be simpler if you drew directly to PostScript or PDF via postscript() or pdf(). Also, the text() call should be ... text(10,10,"whatever",family="ipa")
[...]
I'm not sure how you got there. You've specified the family wrong so I would expect more "family not found" warnings. Let me know if this persists with the correct family specified.
Strangely enough I get the "family 'ipa' not included in PostScript device" if I run text(10,10,"whatever",family="ipa") while the "PostScriptCIDMetricInfo" error if I run text(10,10,"whatever",family="InternationalPhoneticAlphabet"") I get the same behaviour when I write directly to the postscript device: postscript(file="whatever.eps") plot(10,10,type="n") text(10,10,"whatever",family="InternationalPhoneticAlphabet") or text(10,10,"whatever",family="ipa") I suspect the "PostScriptCIDMetricInfo" error depends on the fact the the encodings/silipa.enc file contains all values from 33 to 255 (with a few undefines values). Can that be possible? Thanks, Giampiero
3 days later
Hi,
I am not familiar with how R deals with postscript fonts, but
I am fairly familiar with some font technology, so here are a few
random thoughts:
(1) You are not supposed to specify just any random font family string
- postscript type 1 fonts contain their own family name inside.
(read the top of the font file - the header is is plain ascii). If it
works with a random font family name, it is probably because R does not
check (?).
(2) if you are using symbol fonts, some of X11 funtionality may depend
on your locale - the warning message on PostscriptCIDMetricIndfo
did say something about you using a one-byte locale - LANG=en_US.iso88591 .
(3) There are various ways to add fonts to the X server - for new
linux systems you are just copy them into ${HOME}/.fonts (don't know if
R can use fonts via xft), for older linux boxes, you can do
"xset fp+ <fontdir>", after running mkfontdir in that directory
beforehand.
Giampiero Salvi wrote:
Hi Paul, first thank you for helping out. On Fri, 15 Dec 2006, Paul Murrell wrote:
Exactly. The process would be simpler if you drew directly to PostScript or PDF via postscript() or pdf(). Also, the text() call should be ... text(10,10,"whatever",family="ipa")
[...]
I'm not sure how you got there. You've specified the family wrong so I would expect more "family not found" warnings. Let me know if this persists with the correct family specified.
Strangely enough I get the "family 'ipa' not included in PostScript device" if I run text(10,10,"whatever",family="ipa") while the "PostScriptCIDMetricInfo" error if I run text(10,10,"whatever",family="InternationalPhoneticAlphabet"") I get the same behaviour when I write directly to the postscript device: postscript(file="whatever.eps") plot(10,10,type="n") text(10,10,"whatever",family="InternationalPhoneticAlphabet") or text(10,10,"whatever",family="ipa") I suspect the "PostScriptCIDMetricInfo" error depends on the fact the the encodings/silipa.enc file contains all values from 33 to 255 (with a few undefines values). Can that be possible? Thanks, Giampiero
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Hi Hin-Tak Leung,
thank you for your help. Paul and I had solved the problem off-line.
Here is the solution: the encoding file contained in the tipa package
is not in adobe format and therefore causes the problem. The default
encoding, however, seems to work well. In case of fonts corresponding
to extended ascii, the octal code you find in appendix A in the tipa
manual [1] can be entered in the string in the form \xyz.
This code demonstrates the use of IPA fonts (provided you have
downloaded the fonts in the Type1 directory in your current path):
Note in the end that you have to explicitely embed the fonts into the
pdf file.
ipa <- Type1Font("InternationalPhoneticAlphabet",
c("Type1/tipa10.afm",
"Type1/tipabx10.afm",
"Type1/tipasi10.afm",
"Type1/tipabx10.afm"))
pdfFonts(ipa=ipa)
pdf("ipademo.pdf")
grid.text("whatever", y=2/3, gp=gpar(fontfamily="ipa"))
grid.text("WHATEVER", y=1/3, gp=gpar(fontfamily="ipa"))
grid.text("\312", y=1/4, gp=gpar(fontfamily="ipa"))
dev.off()
embedFonts("ipademo.pdf", out="ipademoembed.pdf", fontpath="Type1")
The only missing part is including symbols that are created in
tipa/LaTeX by macros, but this is another story...
Thanks to anyone who helped.
Giampiero
[1] http://tug.ctan.org/tex-archive/fonts/tipa/tipaman.pdf
On Mon, 18 Dec 2006, Hin-Tak Leung wrote:
Hi,
I am not familiar with how R deals with postscript fonts, but
I am fairly familiar with some font technology, so here are a few
random thoughts:
(1) You are not supposed to specify just any random font family string
- postscript type 1 fonts contain their own family name inside.
(read the top of the font file - the header is is plain ascii). If it
works with a random font family name, it is probably because R does not
check (?).
(2) if you are using symbol fonts, some of X11 funtionality may depend
on your locale - the warning message on PostscriptCIDMetricIndfo
did say something about you using a one-byte locale - LANG=en_US.iso88591 .
(3) There are various ways to add fonts to the X server - for new
linux systems you are just copy them into ${HOME}/.fonts (don't know if
R can use fonts via xft), for older linux boxes, you can do
"xset fp+ <fontdir>", after running mkfontdir in that directory
beforehand.
Giampiero Salvi wrote:
Hi Paul, first thank you for helping out. On Fri, 15 Dec 2006, Paul Murrell wrote:
Exactly. The process would be simpler if you drew directly to PostScript or PDF via postscript() or pdf(). Also, the text() call should be ... text(10,10,"whatever",family="ipa")
[...]
I'm not sure how you got there. You've specified the family wrong so I would expect more "family not found" warnings. Let me know if this persists with the correct family specified.
Strangely enough I get the "family 'ipa' not included in PostScript device" if I run text(10,10,"whatever",family="ipa") while the "PostScriptCIDMetricInfo" error if I run text(10,10,"whatever",family="InternationalPhoneticAlphabet"") I get the same behaviour when I write directly to the postscript device: postscript(file="whatever.eps") plot(10,10,type="n") text(10,10,"whatever",family="InternationalPhoneticAlphabet") or text(10,10,"whatever",family="ipa") I suspect the "PostScriptCIDMetricInfo" error depends on the fact the the encodings/silipa.enc file contains all values from 33 to 255 (with a few undefines values). Can that be possible? Thanks, Giampiero
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Giampiero Salvi wrote:
Hi Hin-Tak Leung,
thank you for your help. Paul and I had solved the problem off-line.
Here is the solution: the encoding file contained in the tipa package
is not in adobe format and therefore causes the problem. The default
encoding, however, seems to work well. In case of fonts corresponding
to extended ascii, the octal code you find in appendix A in the tipa
manual [1] can be entered in the string in the form \xyz.
This code demonstrates the use of IPA fonts (provided you have
downloaded the fonts in the Type1 directory in your current path):
Note in the end that you have to explicitely embed the fonts into the
pdf file.
ipa <- Type1Font("InternationalPhoneticAlphabet",
c("Type1/tipa10.afm",
"Type1/tipabx10.afm",
"Type1/tipasi10.afm",
"Type1/tipabx10.afm"))
pdfFonts(ipa=ipa)
pdf("ipademo.pdf")
grid.text("whatever", y=2/3, gp=gpar(fontfamily="ipa"))
grid.text("WHATEVER", y=1/3, gp=gpar(fontfamily="ipa"))
grid.text("\312", y=1/4, gp=gpar(fontfamily="ipa"))
dev.off()
embedFonts("ipademo.pdf", out="ipademoembed.pdf", fontpath="Type1")
The only missing part is including symbols that are created in
tipa/LaTeX by macros, but this is another story...
I've recently added freetype font support (http://www.freetype.org/) and pdf output to Simon Urbanek's Cairo package: http://www.rforge.net/Cairo/ which supports pdf and png output. Freetype supports many font formats, including truetype and the newer opentype format. When R plots are created with truetype (or opentype) fonts, Cairo will by default embed the fonts into the pdf file. I've also noticed a couple of debian unicode truetype font packages with IPA extensions: $ apt-cache search ipa | grep ttf ttf-thryomanes - A Unicode font covering Latin, Greek, Cyrillic and IPA ttf-junicode - a Unicode font for medievalists (Latin, IPA and Runic) So, I could envision creating an R package very similar to the LaTeX tipa package that could spit out the IPA unicode code points for these truetype fonts, thus supporting plots with IPA symbols but exclusively for the Cairo graphics device.
Thanks to anyone who helped. Giampiero [1] http://tug.ctan.org/tex-archive/fonts/tipa/tipaman.pdf On Mon, 18 Dec 2006, Hin-Tak Leung wrote:
Hi,
I am not familiar with how R deals with postscript fonts, but
I am fairly familiar with some font technology, so here are a few
random thoughts:
(1) You are not supposed to specify just any random font family string
- postscript type 1 fonts contain their own family name inside.
(read the top of the font file - the header is is plain ascii). If it
works with a random font family name, it is probably because R does not
check (?).
(2) if you are using symbol fonts, some of X11 funtionality may depend
on your locale - the warning message on PostscriptCIDMetricIndfo
did say something about you using a one-byte locale - LANG=en_US.iso88591 .
(3) There are various ways to add fonts to the X server - for new
linux systems you are just copy them into ${HOME}/.fonts (don't know if
R can use fonts via xft), for older linux boxes, you can do
"xset fp+ <fontdir>", after running mkfontdir in that directory
beforehand.
Giampiero Salvi wrote:
Hi Paul, first thank you for helping out. On Fri, 15 Dec 2006, Paul Murrell wrote:
Exactly. The process would be simpler if you drew directly to PostScript or PDF via postscript() or pdf(). Also, the text() call should be ... text(10,10,"whatever",family="ipa")
[...]
I'm not sure how you got there. You've specified the family wrong so I would expect more "family not found" warnings. Let me know if this persists with the correct family specified.
Strangely enough I get the "family 'ipa' not included in PostScript device" if I run text(10,10,"whatever",family="ipa") while the "PostScriptCIDMetricInfo" error if I run text(10,10,"whatever",family="InternationalPhoneticAlphabet"") I get the same behaviour when I write directly to the postscript device: postscript(file="whatever.eps") plot(10,10,type="n") text(10,10,"whatever",family="InternationalPhoneticAlphabet") or text(10,10,"whatever",family="ipa") I suspect the "PostScriptCIDMetricInfo" error depends on the fact the the encodings/silipa.enc file contains all values from 33 to 255 (with a few undefines values). Can that be possible? Thanks, Giampiero
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel