[R-lang] Re: Including IPA fonts in plots?

Levy, Roger rlevy@ucsd.edu
Thu Oct 7 09:52:32 PDT 2010


Got it; many thanks to both Ewan and Paul for pointing me to cairo_pdf.  This solved the problem.

Now: does anyone know if there's a way to get Sweave to use cairo devices instead of the default pdf and postscript devices?

Roger

On Oct 6, 2010, at 9:54 AM, Ewan Dunbar wrote:

> 
> There are two things going on. First, Doulos is a TrueType font. The default screen plot device supports TTFs, but, at least on non-Windows systems, the pdf and ps devices do not. Second, even if you could get the font to work, the pdf device chokes on Unicode, which was the original problem. (To see this, try using a non-TTF font that supports the glyph using the pdf device.) The cairo_pdf device (and other cairo devices) will support both TTF and Unicode.
> --ewan
> 
> On Oct 6, 2010, at 4:14 AM, Paul Metzner wrote:
> 
>> I think I had a similar problem and solved it with cairo_pdf. Does that work on Linux or Windows machines?
>> 
>> On 6 Oct 2010, at 02:37, Levy, Roger wrote:
>> 
>>> Michael, Adam, many thanks! Specifying the 'family' parameter has worked for plotting commands executed within the R.app GUI.
>>> 
>>> I still am having trouble generating PDF and Postscript graphs; the postscript and PDF graphics devices don't seem to know where to find the font family, e.g.
>>> 
>>>> pdf("test.pdf")
>>>> par(family="Doulos SIL");plot(1:2,1:2);text(1.5,1.5,"ʌ")
>>> Error in axis(side = side, at = at, labels = labels, ...) : 
>>> Invalid font type
>>> In addition: Warning messages:
>>> 1: In axis(side = side, at = at, labels = labels, ...) :
>>> font family not found in PostScript font database
>>> 2: In axis(side = side, at = at, labels = labels, ...) :
>>> font family not found in PostScript font database
>>> 3: In axis(side = side, at = at, labels = labels, ...) :
>>> font family not found in PostScript font database
>>> 4: In axis(side = side, at = at, labels = labels, ...) :
>>> font family not found in PostScript font database
>>> 5: In axis(side = side, at = at, labels = labels, ...) :
>>> font family not found in PostScript font database
>>> 6: In axis(side = side, at = at, labels = labels, ...) :
>>> font family not found in PostScript font database
>>> 7: In axis(side = side, at = at, labels = labels, ...) :
>>> font family not found in PostScript font database
>>> 
>>> Does anyone have suggestions on how to inform these graphics devices of what to do given the font specification?
>>> 
>>> Many thanks again.
>>> 
>>> Roger
>>> 
>>> 
>>> On Oct 5, 2010, at 4:30 PM, Michael Becker wrote:
>>> 
>>>> Hi Roger,
>>>> 
>>>> Specifying the name of a Unicode font will do the trick, e.g.:
>>>> 
>>>> par(family="Linux Libertine"); plot(1:2,1:2);text(1.5,1.5,"ʌ")
>>>> or
>>>> par(family="Doulos SIL");plot(1:2,1:2);text(1.5,1.5,"ʌ")
>>>> 
>>>> You'll need to have the relevant font installed, of course.
>>>> 
>>>> I hope this helps,
>>>> Michael
>>>> 
>>>> 
>>>> 
>>>> On Tue, Oct 5, 2010 at 6:58 PM, Levy, Roger <rlevy@ucsd.edu> wrote:
>>>>> Hi all,
>>>>> 
>>>>> Has anyone had unqualified success in rendering IPA symbols in R?  graphs I've had trouble; within the R.app GUI on OS X, the commands
>>>>> 
>>>>>> plot(1:2,1:2)
>>>>>> text(1.5,1.5,"ʌ") # in case it's not rendered properly in your email client, the character is the wedge in UTF-8
>>>>> 
>>>>> give just a box, and I get even worse failure if I try to create a Postscript or PDF file:
>>>>> 
>>>>>> postscript("test.ps") # same error ensues if I use pdf("test.pdf") here instead
>>>>>> plot(1:2,1:2)
>>>>>> text(1.5,1.5,"ʌ")
>>>>> Warning messages:
>>>>> 1: In text.default(1.5, 1.5, "ʌ") :
>>>>> conversion failure on 'ʌ' in 'mbcsToSbcs': dot substituted for <ca>
>>>>> 2: In text.default(1.5, 1.5, "ʌ") :
>>>>> conversion failure on 'ʌ' in 'mbcsToSbcs': dot substituted for <8c>
>>>>> 3: In text.default(1.5, 1.5, "ʌ") :
>>>>> font metrics unknown for Unicode character U+028c
>>>>> 4: In text.default(1.5, 1.5, "ʌ") :
>>>>> conversion failure on 'ʌ' in 'mbcsToSbcs': dot substituted for <ca>
>>>>> 5: In text.default(1.5, 1.5, "ʌ") :
>>>>> conversion failure on 'ʌ' in 'mbcsToSbcs': dot substituted for <8c>
>>>>> 
>>>>> Interesting, ash (æ) renders fine on all graphics devices
>>>>> 
>>>>> Any suggestions would be very welcome!
>>>>> 
>>>>> (Stefan Evert suggested a while back that IPA fonts should just work within the R.app GUI for OS X, but I haven't found this to be the case.)
>>>>> 
>>>>> Best & many thanks in advance,
>>>>> 
>>>>> Roger
>>>>> 
>>>>> --
>>>>> 
>>>>> Roger Levy                      Email: rlevy@ling.ucsd.edu
>>>>> Assistant Professor             Phone: 858-534-7219
>>>>> Department of Linguistics       Fax:   858-534-4789
>>>>> UC San Diego                    Web:   http://ling.ucsd.edu/~rlevy
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> -- 
>>>> Michael Becker
>>>> Department of Linguistics
>>>> Harvard University
>>>> http://becker.phonologist.org/
>>> 
>>> --
>>> 
>>> Roger Levy                      Email: rlevy@ling.ucsd.edu
>>> Assistant Professor             Phone: 858-534-7219
>>> Department of Linguistics       Fax:   858-534-4789
>>> UC San Diego                    Web:   http://ling.ucsd.edu/~rlevy
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>> 
>> ---
>> Paul Metzner
>> 
>> Humboldt-Universität zu Berlin
>> Philosophische Fakultät II
>> Institut für deutsche Sprache und Linguistik
>> 
>> Post: Unter den Linden 6 | 10099 Berlin | Deutschland
>> Besuch: Dorotheenstraße 24 | 10117 Berlin | Deutschland
>> 
>> +49-(0)30-2093-9726
>> paul.metzner@rz.hu-berlin.de
>> http://amor.rz.hu-berlin.de/~metznerp/
>> 
>> 
> 

--

Roger Levy                      Email: rlevy@ling.ucsd.edu
Assistant Professor             Phone: 858-534-7219
Department of Linguistics       Fax:   858-534-4789
UC San Diego                    Web:   http://ling.ucsd.edu/~rlevy










More information about the ling-r-lang-L mailing list