Many Japanese were troubled with the setting of the font.
I added the following to .Rprofile first.
setHook(packageEvent("grDevices", "onLoad"),
function(...){
grDevices::quartzFonts(sans=grDevices::quartzFont(
c("Hiragino Kaku Gothic Pro W3",
"Hiragino Kaku Gothic Pro W6",
"Hiragino Kaku Gothic Pro W3",
"Hiragino Kaku Gothic Pro W6")))
grDevices::quartz.options(family="sans")
)
However, it was not reflected in family of the default.
If I appoint it with `quartz(family="sans")', which was able to
use Japanese.
Therefore I added hook.
attach(NULL, name = "MacJapanEnv")
assign("familyset_hook",
function() { if(names(dev.cur())=="quartz")
par(family="sans")},
pos="MacJapanEnv")
setHook("plot.new", get("familyset_hook",
pos="MacJapanEnv"))
However, the following practice caused a problem.
> plot(1:5,1:5)
>
legend("bottomright",legend=c("a","b"),lwd=1,col=1:2)
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000014
0x900031c8 in strlen ()
(gdb) bt
#0 0x900031c8 in strlen ()
#1 0x907bf19c in CFStringCreateWithCString ()
#2 0x0221bc58 in RQuartz_FindFont (fontface=-2147483648,
fontfamily=0xbfffc3c0 "sans") at devQuartz.c:533
#3 0x0221bd0c in RQuartz_Font (gc=0xbfffc378, dd=0x17) at devQuartz.c:548
#4 0x0221c184 in RQuartz_Set (ctx=0x2155eb0, gc=0xbfffc378, flags=8)
at devQuartz.c:623
#5 0x0221cc3c in RQuartz_StrWidth (text=0x1ff7e20 "a", gc=0xbfffc378,
dd=0x212cd60) at devQuartz.c:736
Reference of fontface seems to watch the thing which R must not sometimes watch.
--- R-patched.orig/src/library/grDevices/src/devQuartz.c
2008-05-01 00:45:39.000000000 +0900
+++ R-patched/src/library/grDevices/src/devQuartz.c 2008-05-22
13:16:46.000000000 +0900
@@ -529,7 +529,7 @@
int i;
for(i = 0; i < length(names); i++)
if(0 == strcmp(fontfamily, CHAR(STRING_ELT(names, i)))) break;
- if(i < length(names))
+ if(i < length(names) && fontface > 0)
fontName = CFStringCreateWithCString(kCFAllocatorDefault,
CHAR(STRING_ELT(VECTOR_ELT(db, i), fontface - 1)),
kCFStringEncodingUTF8);
There was not the problem in the Japanese environment if this added a change.
--
EI-JI Nakama <nakama at ki.rim.or.jp>
"\u4e2d\u9593\u6804\u6cbb" <nakama at ki.rim.or.jp>