[R-lang] Re: Embedding phonetic symbols in R
Donald Derrick
dderrick@interchange.ubc.ca
Wed Jul 20 16:26:48 PDT 2011
Put it at the beginning of the program in question. It is just a parameter that selects the fonts used in future pdf or quartz outputs.
If that does not work for you, email me direct and I'll take a look at your particular example.
DD
On 2011-07-20, at 4:21 PM, Sverre Stausland wrote:
> Hi Donald,
>
> could you be a little bit more specific? When creating a pdf, when
> should this call be made?
>
> Best
> Sverre
>
> On Wed, Jul 20, 2011 at 7:14 PM, Donald Derrick
> <dderrick@interchange.ubc.ca> wrote:
>> I just use code like:
>> tryCatch(par(family="Doulos SIL"),error=par(family="sans"))
>> If you don't like/have "Doulos SIL", pick another font. Same with the
>> fallback font.
>>
>>
>> DD
>>
>> On 2011-07-20, at 4:06 PM, Bill Poser wrote:
>>
>> I hesitate to recommend this technique, but if you are really stuck you
>> could try directly hacking the postscript as described in this post from the
>> time before R supported Unicode:
>> http://babel.ling.upenn.edu/phonetics/archive/Unicode%20in%20R%20Text.htm
>>
>> On Wed, Jul 20, 2011 at 12:50 PM, Sverre Stausland <johnsen@fas.harvard.edu>
>> wrote:
>>>
>>> Hi Roger,
>>>
>>> I've actually seen that thread before, but the only thing I extracted
>>> from it was "use Cairo", which I did ... There are some remaining
>>> details to be sorted out, I just don't know what they are.
>>>
>>> Sverre
>>>
>>> On Wed, Jul 20, 2011 at 3:47 PM, Levy, Roger <rlevy@ucsd.edu> wrote:
>>>> Hi Sverre,
>>>>
>>>> You might find the following thread useful:
>>>>
>>>>
>>>> http://pidgin.ucsd.edu/pipermail/r-lang/mailman.ucsd.edu/pipermail/ling-r-lang-l/2010-October/000110.html
>>>>
>>>> For me a crucial part of the puzzle was using the cairo_pdf and cairo_ps
>>>> drivers (kudos to Paul Metzner for pointing this out).
>>>>
>>>> Best & let us know if that helps!
>>>>
>>>> Roger
>>>>
>>>> On Jul 20, 2011, at 1:33 PM, Sverre Stausland wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I'm sure I'm not the only Windows user out there trying to embed IPA
>>>>> symbols in R graphics and then make a pdf out of it. If anyone knows
>>>>> how to do that, I would appreciate some help. Because I have not
>>>>> succeeded.
>>>>>
>>>>> Here is what I have tried. I'm creating a plot in R with IPA phonetic
>>>>> symbols, using the standard
>>>>> font Doulos SIL
>>>>>
>>>>> (http://scripts.sil.org/cms/scripts/page.php?item_id=DoulosSILfont&_sc=1)
>>>>>
>>>>> When attempting to create a pdf of this plot in R using the pdf()
>>>>> function, I will get the following error messages:
>>>>>
>>>>>> pdf(file="C:/~myplot.pdf")
>>>>>> plot.default(my.x,my.y,type="n")
>>>>>> windowsFonts(IPA="TT Doulos SIL")
>>>>>> text(my.x,my.y,labels=my.data$words.with.IPA,family="IPA")
>>>>> Error in text.default(my.x, my.y, :
>>>>> Invalid font type
>>>>> In addition: Warning messages:
>>>>> 1: In text.default(my.x, my.y, :
>>>>> font family not found in PostScript font database
>>>>>
>>>>> I've been advised that I can resolve this problem using the Cairo
>>>>> package for R. But I have not succeeded. Here is my call:
>>>>>
>>>>>> library(Cairo)
>>>>>> CairoPDF(file="C:/~myplot.pdf")
>>>>>> plot.default(my.x,my.y,type="n")
>>>>>> windowsFonts(IPA="TT Doulos SIL")
>>>>>> text(my.x,my.y,labels=my.data$words.with.IPA,family="IPA")
>>>>>> dev.off()
>>>>>
>>>>> It produces a pdf file, but all the IPA symbols come out as boxes.
>>>>>
>>>>> Please note that R has no difficulties producing this plot in its
>>>>> graphic window with IPA symbols. It's only the pdf output I'm having
>>>>> difficulties with.
>>>>>
>>>>> Any help would be appreciated! Further details follow below.
>>>>>
>>>>>> sessionInfo()
>>>>> R version 2.13.1 (2011-07-08)
>>>>> Platform: i386-pc-mingw32/i386 (32-bit)
>>>>>
>>>>> locale:
>>>>> [1] LC_COLLATE=English_United States.1252
>>>>> [2] LC_CTYPE=English_United States.1252
>>>>> [3] LC_MONETARY=English_United States.1252
>>>>> [4] LC_NUMERIC=C
>>>>> [5] LC_TIME=English_United States.1252
>>>>>
>>>>> attached base packages:
>>>>> [1] stats graphics grDevices utils datasets methods base
>>>>>
>>>>> other attached packages:
>>>>> [1] Cairo_1.4-9
>>>>>
>>>>> loaded via a namespace (and not attached):
>>>>> [1] tools_2.13.1
>>>>>
>>>>>> Sys.getlocale()
>>>>> [1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
>>>>> States.1252;LC_MONETARY=English_United
>>>>> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"
>>>>
>>>> --
>>>>
>>>> Roger Levy Email: rlevy@ucsd.edu
>>>> Assistant Professor Phone: 858-534-7219
>>>> Department of Linguistics Fax: 858-534-4789
>>>> UC San Diego Web: http://idiom.ucsd.edu/~rlevy
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>>
More information about the ling-r-lang-L
mailing list