[Rd] Phonetic symbols (IPA) in R graphics
Jeffrey Horner
jeff.horner at vanderbilt.edu
Tue Dec 19 17:56:30 CET 2006
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
--
http://biostat.mc.vanderbilt.edu/JeffreyHorner
More information about the R-devel
mailing list