[R-SIG-Mac] Possible mac-specific bug in svg (cairo) graphics

Simon Urbanek simon.urbanek at r-project.org
Thu Jan 29 16:29:11 CET 2009


Yan,

On Jan 28, 2009, at 6:33 , Yan Wong wrote:

>
> On 27 Jan 2009, at 16:16, Simon Urbanek wrote:
>
>> I think you got the corresponding response to your post before -
>
> Apologies: I didn't see that reponse.

>> cairographics cannot locate an italic version of the font -  
>> switching to a font which has the desired traits will produce the  
>> desired output, e.g.:
>>
>> svg("test.svg", width=4,4,8)
>> par(family="Arial")
>> plot.new()
>> text(0.5,0.5,labels=expression(italic("This should be in italics")))
>> dev.off()
>
> Thanks. I tried this with family="Arial", family="Times",  
> family="serif", family="sans", family="Verdana", and family="mono",  
> and they all come out as bold.
>
> I guess if this doesn't happen on other systems, then is must be a  
> problem with my R or system setup. Unfortunately I don't have  
> another system  to try this out on.
>

Ah, sorry, my bad - I forgot that you're on 10.4 and I was testing  
with 10.5. I do remember that 10.4 is missing italics from several  
default fonts (e.g. Helvetica). You can enable fontconfig debug using  
FC_DEBUG=1 -- that will at least tell you what fontconfig found.

To make things worse, FreeType on Mac is quite buggy and screws up  
numbering of fonts within a container which results in incorrect  
styles - it is something we try to work around, but if FT recognizes  
the wrong style we can't do anything about it. From what I can see  
this is what happens -- the main difference between 10.4 and 10.5 is  
that Arial and friends are supplied as (rf-style) font suitcases in  
10.4 which is what FT has trouble dealing with. In 10.5 they come as  
individual fonts which FT can deal with just fine.

I know that this is catching straws, but of one the few fonts that  
come as TTF in 10.4 is "Euphemia UCAS", so this will produce italic  
output even on 10.4:

svg("test.svg", width=4,4,8)
par(family="Euphemia UCAS")
plot.new()
text(0.5,0.5,labels=expression(italic("This should be in italics")))
dev.off()

Although this is a nuisance, working around bugs in 3rd party  
libraries on older systems is not high on my priority list, os I  
cannot promise anything, but maybe I'll get to it...


> The italic versions of Arial, Time, and Verdana are all available,  
> according to Font Book.
>

All styles are in a single file and FT picks the wrong one,  
unfortunately.


> Have you any suggestions as to how I could try and find out what is  
> going on here? Can I activate some sort of debugging or verbose mode  
> in Cairographics?
>

FC_DEBUG=1 may help, but FT/cairographics don't have any debugging env  
vars AFAIR.

Cheers,
Simon



More information about the R-SIG-Mac mailing list