Skip to content

charset in graphics

7 messages · Peter Dalgaard, Brian Ripley, Donatas G.

#
How do I make Lithuanian characters display correctly in R graphics? 

Instead of the special characters for Lithuanian language I get question 
marks...

I use Ubuntu Feisty, the locale is utf-8 ...

Do I need to specify somewhere the locale for R, or - default font for the 
graphics?
#
On Fri, 13 Jul 2007, Donatas G. wrote:

            
See ?X11, especially the 'Fonts' section (assuming that is the graphics 
device you are using: you did not actually say but that is the device 
most likely to be giving question marks or empty rectangles for missing 
glyphs).
#
Donatas G. wrote:
You mean as in
plot(0,main=tolower("\u104\u116\u0118\u012e\u0172\u016a\u010c\u0160\u017d"))

?

This works fine for me on OpenSUSE 10.2, so I don't think the issue is
in R. More likely, this has to do with X11 fonts (Unicode is handled via
a rather complicated mechanism involving virtual fonts). Postscript/PDF
is a bit more difficult. See ?postscript and the reference to
Murrell+Ripley's R News article inside.

The correct incantation seems to be

postscript(font="URWHelvetica", encoding="ISOLatin7")
plot(0,main=tolower("\u104\u116\u0118\u012e\u0172\u016a\u010c\u0160\u017d"))
dev.off()
#
On Fri, 13 Jul 2007, Peter Dalgaard wrote:

            
The encoding should happen automagically in a Lithuanian UTF-8 locale, and 
does for me.  But suitable fonts (e.g. URW ones) are needed.
#
Prof Brian Ripley wrote:
OK, I sort of suspected that, although it wasn't entirely clear to me
whether autoconversion would cover cases like en_LT.utf8, if that even
exists. Still, the explicit (portable?) way of doing it is probably
worth knowing too (there could be a few pitfalls with scripts getting
run outside their usual domain).
#
On Fri, 13 Jul 2007, Peter Dalgaard wrote:

            
The locale would need to be in the Lithuanian language (ISO 639 code lt or 
lit), not some language in Lithuania (ISO 3166 code LT).
Yes, the appropriate 8-bit encoding can only be a guess, and someone might 
be writing French or Japanese in lt_LT.utf8.
#
On Friday 13 July 2007 17:56:45 Prof Brian Ripley wrote:
This sequence seems to do the trick, although I do not seem to have a font 
URWHelvetica

Anyway, where do i record these lines to make it permanent?

Maybe the explanation was there in Prof Brian Ripley's first email, but I did 
not get it somehow...