Skip to content

Korean in quartz() device.

3 messages · Dong-hyun Oh, Brian Ripley, Ei-ji Nakama

#
Dear R users,

I run R-2.9.2 on the Snow Leopard 10.6.1 OS system. The default  
language of the OS is english.

I want to plot a very simple graph with Korean letters on a quartz()  
device, but it fails. Korean Letters appear as being squares.

The same command works fine in Windows systems.

My question is how can I draw or typeset Korean letters in quartz()  
device on SL OS?


Best regards,
Donghyun Oh
#
On Fri, 30 Oct 2009, Dong-hyun Oh wrote:

            
We don't have a reproducible example, but this usually indicates that 
the font you are using does not contain the glyphs you are requesting.
Unlikely, as quartz() does not exist on Windows, and on the windows() 
the font selection is crucial for CJK glyphs.  How about the X11() 
device?
Probably, select a suitable font.  If you can prepare a reproducible 
example (see the posting guide) we may be able to help further. 
Please use \uxxxx or put the example on a website, as mailers frequent 
mangle non-ASCII content or attachments.

  
    
#
Hi

You can write the following in "~/.Rprofile".

----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----
setHook(packageEvent("grDevices", "onLoad"),
	function(...){
        if(capabilities("aqua"))
            grDevices::quartzFonts(
              sans =grDevices::quartzFont(rep("AppleGothic",4)),
              serif=grDevices::quartzFont(rep("AppleMyungjp",4)))
        grDevices::pdf.options(family="Korea1")
        grDevices::ps.options(family="Korea1")
        }
)
attach(NULL, name = "KoreaEnv")
assign("familyset_hook",
       function() {
            macfontdevs=c("quartz","quartz_off_screen")
            devname=strsplit(names(dev.cur()),":")[[1L]][1]
            if (capabilities("aqua") &&
                devname %in% macfontdevs)
                    par(family="sans")
       },
       pos="KoreaEnv")
setHook("plot.new", get("familyset_hook", pos="KoreaEnv"))
setHook("persp", get("familyset_hook", pos="KoreaEnv"))
----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----

familyset_hook is a claptrap method.

There were no italics in Japanese, but there were two weight fonts.
I don't know good Korean font, choose a good font, please.


2009/10/30 Dong-hyun Oh <oh.donghyun77 at gmail.com>: