Skip to content

Problem with national characters in main, xlab, ylab with pdf{grDevices} / postscript {grDevices}

3 messages · Brian Ripley, Magdalena A. Tkacz

#
Hello.

I'm trying to make some graphics with nationalized labels (pdf for use
in LaTeX document).


On console (displayed on screen) using  all looks ok:
----------------------------------------\/
data<-rnorm(100)
hist(data,main='Rozk?ad g?sto?ci punkt?w', xlab='Warto?? na osi y',
ylab='Cz?sto?? wyst?powania')
-------------------------------------------/\

But using:
-------------------------------------------\/
data<-rnorm(100)

pdf('plik.pdf',encoding="CP1250.enc")
hist(data,main='Rozk?ad g?sto?ci punkt?w', xlab='Warto?? na osi y',
ylab='Cz?sto?? wyst?powania')
dev.off()
--------------------------------------------/\

It does not look fine ...

Without specifying encoding:
-------------------------------------------\/
pdf('plik-wo-enc.pdf')
hist(data,main='Rozk?ad g?sto?ci punkt?w', xlab='Warto?? na osi y',
ylab='Cz?sto?? wyst?powania')
dev.off()
---------------------------------------------/\
Almost does not have national characters. (Almost, because "?" letter appears)

Exemplary pdf file are here:
https://www.drivehq.com/file/df.aspx/shareID10318887/fileID1167942261/plik.pdf
https://www.drivehq.com/file/df.aspx/shareID10318887/fileID1167945977/plik-wo-enc.pdf


I have read "Non-Standard Fonts in PostScript and PDF Graphics" by
Paul Murrell and Brian Ripley in Rnews.

I have also tried option with
-------------------\/
Sys.setlocale(category="LC_CTYPE", locale="pl_PL.utf8")
-------------------/\
but even in admin (run R as admin) in Win7 I received warning:
-------------------\/
"In Sys.setlocale(category = "LC_CTYPE", locale = "pl_PL.utf8") :
??dania raport?w OS aby ustawi? lokalizacj? na "pl_PL.utf8" nie mog?
zosta? wykonane"
-------------------/\
(translated in short : OS report request to set locale to "pl_PL.utf8"
can not be done)


Does anyone knows how to obtain pdf documents with acceptable quality?



Thanks in advance,

Regards
#
'National': not my nation, and none is stated.  Somewhere in Eastern 
Europe ... Poland?

Short answer: you need to use a family which contains those glyphs 
(try family='NimbusSan': the default 'Helvetica' does not) *and* a 
viewer that uses fonts that do.

Longer answer: read ?pdf and ?postscript carefully, as they told you 
this and more.

Your example works correctly with that family for me on Linux, 
but not with OS X viewers.  It does not with the default family.

For people on Unix I would suggest the cairo_pdf() device as a 
possibly easier alternative since it usually embeds fonts.  On 
Windows and OS X you are at the mercy of what fonts cairo has access 
to.  That's all in the help, too.
On Sun, 7 Oct 2012, Magdalena A. Tkacz wrote:

            
Actually it is just a binary file, and no viewer has been mentioned.

  
    
#
Hello.

Yes, you're right -Poland, Central/Eastern Europe.
My apologies - my fault  - not to state it directly in post.

Than you for your advice, especially concerning viewer (when OS is Win).

Under Windows (checked both on english and polish version of OS) works
fine with font family you proposed, previewed with Sumatra PDF or
TeXworks internal viewer (Adobe Reader does NOT display generated pdf
correctly ).

On my Linux workstation, cairo_pdf(fileName.pdf) works OK without any
additional parameters, both Okular and Document Viewer also works fine
as a viewers.

Thank You very much.
Problem solved.

Regards

Magdalena Tkacz


2012/10/7 Prof Brian Ripley <ripley at stats.ox.ac.uk>: