From p.murrell at auckland.ac.nz  Thu Dec 14 20:34:01 2006
From: p.murrell at auckland.ac.nz (Paul Murrell)
Date: Fri, 15 Dec 2006 08:34:01 +1300
Subject: [Rd] Phonetic symbols (IPA) in R graphics
In-Reply-To: <Pine.LNX.4.58.0612141146150.21599@ctt35.speech.kth.se>
References: <Pine.LNX.4.58.0612131459410.956@ctt35.speech.kth.se>
	<45804A25.2040903@stat.auckland.ac.nz>
	<Pine.LNX.4.58.0612141146150.21599@ctt35.speech.kth.se>
Message-ID: <4581A729.8010309@stat.auckland.ac.nz>

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/



[Rd] Phonetic symbols (IPA) in R graphics
Paul Murrell