[R-SIG-Mac] R commander fonts on R 3.4.0
Fox, John
jfox at mcmaster.ca
Tue May 16 19:57:46 CEST 2017
Dear Peter and Simon,
I don't fully understand the issues either and, again, haven't observed a problem, but I'm grateful that both of you are taking a look at it.
For what it's worth, here's what the Rcmdr package does with fonts. This code is from the development version of the Rcmdr, where the code is refactored for clarity, but the current CRAN version does the same things.
------------------ snip ----------------
setupFonts <- function(){
current <- getOption("Rcmdr")
# set up Rcmdr default and text (log) fonts, Tk scaling factor
default.font.family.val <- tclvalue(.Tcl("font actual TkDefaultFont -family"))
default.font.family.val <- gsub("\\{", "", gsub("\\}", "", default.font.family.val))
default.font.family <- setOption("default.font.family", default.font.family.val)
if (!("RcmdrDefaultFont" %in% as.character(.Tcl("font names")))){
.Tcl(paste("font create RcmdrDefaultFont", tclvalue(tkfont.actual("TkDefaultFont"))))
.Tcl("option add *font RcmdrDefaultFont")
}
.Tcl(paste("font configure RcmdrDefaultFont -family {", default.font.family, "}", sep=""))
if (!("RcmdrTitleFont" %in% as.character(.Tcl("font names")))){
.Tcl(paste("font create RcmdrTitleFont", tclvalue(tkfont.actual("TkDefaultFont"))))
}
.Tcl(paste("font configure RcmdrTitleFont -family {", default.font.family, "}", sep=""))
if (!("RcmdrOutputMessagesFont" %in% as.character(.Tcl("font names")))){
.Tcl(paste("font create RcmdrOutputMessagesFont", tclvalue(tkfont.actual("RcmdrTitleFont"))))
}
.Tcl(paste("font configure RcmdrTitleFont -family {", default.font.family, "}", sep=""))
.Tcl(paste("font configure RcmdrOutputMessagesFont -family {", default.font.family, "}", sep=""))
.Tcl(paste("font configure TkDefaultFont -family {", default.font.family, "}", sep=""))
log.font.family.val <- tclvalue(.Tcl("font actual TkFixedFont -family"))
log.font.family.val <- gsub("\\{", "", gsub("\\}", "", log.font.family.val))
log.font.family <- setOption("log.font.family", log.font.family.val)
if (!("RcmdrLogFont" %in% as.character(.Tcl("font names")))){
.Tcl(paste("font create RcmdrLogFont", tclvalue(tkfont.actual("TkFixedFont"))))
}
.Tcl(paste("font configure RcmdrLogFont -family {", log.font.family, "}", sep=""))
.Tcl(paste("font configure TkFixedFont -family {", log.font.family, "}", sep=""))
putRcmdr("logFont", "RcmdrLogFont")
scale.factor <- current$scale.factor
if (!is.null(scale.factor)) .Tcl(paste("tk scaling ", scale.factor, sep=""))
# set various font sizes
if (WindowsP()){
default.font.size.val <- abs(as.numeric(.Tcl("font actual TkDefaultFont -size")))
if (is.na(default.font.size.val)) default.font.size.val <- 10
}
else default.font.size.val <- 10
default.font.size <- setOption("default.font.size", default.font.size.val)
tkfont.configure("RcmdrDefaultFont", size=default.font.size)
tkfont.configure("RcmdrTitleFont", size=default.font.size)
tkfont.configure("RcmdrOutputMessagesFont", size=default.font.size)
tkfont.configure("TkDefaultFont", size=default.font.size)
tkfont.configure("TkTextFont", size=default.font.size)
tkfont.configure("TkCaptionFont", size=default.font.size)
log.font.size <- setOption("log.font.size", 10)
tkfont.configure("RcmdrLogFont", size=log.font.size)
tkfont.configure("TkFixedFont", size=log.font.size)
.Tcl("ttk::style configure TButton -font RcmdrDefaultFont")
.Tcl("ttk::style configure TLabel -font RcmdrDefaultFont")
.Tcl("ttk::style configure TCheckbutton -font RcmdrDefaultFont")
.Tcl("ttk::style configure TRadiobutton -font RcmdrDefaultFont")
standard.title.color <- as.character(.Tcl("ttk::style lookup TLabelframe.Label -foreground"))
title.color <- setOption("title.color", standard.title.color)
if (tolower(title.color) == "black" || title.color == "#000000"){
tkfont.configure("RcmdrTitleFont", weight="bold")
}
else tkfont.configure("RcmdrTitleFont", weight="normal")
}
--------------------- snip --------------------------
In this code, setOption() is a macro that uses user-supplied options if these are specified:
setOption <- defmacro(option, default, global=TRUE, expr= {
opt <- if (is.null(current[option][[1]])) default else current[option][[1]]
if (global) putRcmdr(option, opt)
opt
})
Best,
John
> -----Original Message-----
> From: Simon Urbanek [mailto:simon.urbanek at r-project.org]
> Sent: Tuesday, May 16, 2017 1:31 PM
> To: peter dalgaard <pdalgd at gmail.com>
> Cc: Fox, John <jfox at mcmaster.ca>; r-sig-mac at r-project.org
> Subject: Re: [R-SIG-Mac] R commander fonts on R 3.4.0
>
>
> > On May 16, 2017, at 12:20 PM, peter dalgaard <pdalgd at gmail.com> wrote:
> >
> > Mystery solved after looking into the actual .pkg files. They simply
> > contain a full Tcl/Tk which installs into /usr/local, which obviously
> > affects anything that links it dynamically. I somehow thought that
> > they would install somewhere separate. (Stop grinning, Simon!)
> >
>
> I'm not sure I understand the "they" - is it us? The difference in R 3.4.0 is that
> we are using everything from the system (and XQuartz) whereas before we
> were building dependencies ourselves before.
>
>
> > Anyways, the way forward must be to get Tcl/Tk compiled exactly as they
> were in 3.3.x.
> >
>
> R before 3.4.0 we used Tcl/Tk 8.6.0 for OS X Mavericks from 2013, for R 3.4.0
> we are using Tcl/Tk 8.6.6 for El Capitan.
>
> FWIW the config flags were
> --disable-corefoundation --disable-framework --disable-aqua --enable-64bit --
> with-tcl=/usr/local/lib --with-x --x-includes=/opt/X11/include --x-
> libraries=/opt/X11/lib CC=clang CXX=clang++
>
> I have no idea what you are talking about here so if anyone has suggestions to
> test, let me know.
>
> Cheers,
> Simon
>
>
>
> > -pd
> >
> >
> >
> >
> >> On 16 May 2017, at 15:18 , peter dalgaard <pdalgd at gmail.com> wrote:
> >>
> >> Double-checked: Indeed, installing 3.3-branch-mavericks.pkg enables xft on
> my local builds of R-patched and R-devel. Hmmmm......
> >>
> >> -pd
> >>
> >>> On 16 May 2017, at 14:55 , peter dalgaard <pdalgd at gmail.com> wrote:
> >>>
> >>> Curiouser and curiouser, now my local build of R-devel stopped using xft
> _without any recompile_ I swear that it worked before I installed R-
> 3.4.0.pkg....
> >>>
> >>> I have both /opt/local/ and /usr/local variants of Tcl/Tk 8.6 and only the
> former has wish8.6 understanding the tk::pkgconfig stuff, so there is plenty of
> room for confusion. The latter seems to be from Simon's site; the other one
> could be a MacPorts relic...
> >>>
> >>> -pd
> >>>
> >>>> On 16 May 2017, at 13:28 , peter dalgaard <pdalgd at gmail.com> wrote:
> >>>>
> >>>> It's a build issue relating to Tcl/Tk, not specifically Rcmdr (Rcmdr does
> something slightly weird[*] with the fonts too, but this seems to be
> orthogonal to the ugly-font issue).
> >>>>
> >>>> To see the issue quickly, try
> >>>>
> >>>> library(tcltk)
> >>>> .Tcl("::tk::pkgconfig get fontsystem")
> >>>>
> >>>> With CRAN 3.3.3, I get
> >>>>
> >>>> <Tcl> xft
> >>>>
> >>>> and likewise with a local nightly build of R-devel, but CRAN 3.4.0
> >>>> says
> >>>>
> >>>>> .Tcl("::tk::pkgconfig get fontsystem")
> >>>> Error in .Tcl("::tk::pkgconfig get fontsystem") :
> >>>> could not find function ".Tcl"
> >>>>
> >>>> as does a local build of R-patched (???!!!).
> >>>>
> >>>> This is pretty weird. I'll see if I can dig up some more about where the
> difference is.
> >>>>
> >>>> -pd
> >>>>
> >>>>
> >>>>
> >>>> [*] Try library(tcltk); demo(tkfaq) then library(Rcmdr) and watch the font
> change in the tkfaq window.
> >>>>
> >>>>
> >>>>> On 15 May 2017, at 23:17 , Fox, John <jfox at mcmaster.ca> wrote:
> >>>>>
> >>>>> Dear Jose,
> >>>>>
> >>>>> It's a bit difficult to respond to your latest messages because you sent
> so many of them.
> >>>>>
> >>>>> I'm not entirely sure what's producing your font problems -- perhaps
> Simon will have some additional ideas -- but you should be aware that you
> can't load the Rcmdr package -- or, more generally, the tcltk package --
> without XQuartz (or another X11 system). Normally, XQuartz should start
> automatically when the Rcmdr (or tcltk) package is loaded. That is, you should
> not have to start it separately.
> >>>>>
> >>>>> It may help to know that the Rcmdr package selects its default
> >>>>> dialog font by querying the default Tk font, via the command
> >>>>>
> >>>>> tclvalue(.Tcl("font actual TkDefaultFont -family"))
> >>>>>
> >>>>> and sets the font for commands and output by querying the default Tk
> fixed-width font:
> >>>>>
> >>>>> tclvalue(.Tcl("font actual TkFixedFont -family"))
> >>>>>
> >>>>> On my Macs, these are respectively the helvetica and courier fonts.
> >>>>>
> >>>>> In any event, I'm glad that you seem to have solved your problem.
> >>>>>
> >>>>> John
> >>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: Jose G Conde Santiago [mailto:jose.conde1 at upr.edu]
> >>>>>> Sent: Monday, May 15, 2017 3:18 PM
> >>>>>> To: Simon Urbanek <simon.urbanek at r-project.org>; Fox, John
> >>>>>> <jfox at mcmaster.ca>; r-sig-mac at r-project.org
> >>>>>> Subject: Re: [R-SIG-Mac] R commander fonts on R 3.4.0
> >>>>>>
> >>>>>> When I run R without XQuartz, the text from the help screen
> >>>>>> renders well. I think the problem seems to be related to XQuartz.
> >>>>>>
> >>>>>> José
> >>>>>>
> >>>>>>
> >>>>>> José G. Conde, MD, MPH
> >>>>>> Professor, School of Medicine
> >>>>>> Director, CentIT2
> >>>>>> UPR Medical Sciences Campus
> >>>>>>
> >>>>>> Tel (787) 763-9401 Fax (787) 758-5206
> >>>>>>
> >>>>>> Email: jose.conde1 at upr.edu
> >>>>>>
> >>>>>> URL: http://rcmi.rcm.upr.edu
> >>>>>>
> >>>>>>> On May 15, 2017, at 2:16 PM, Jose G Conde Santiago
> >>>>>> <jose.conde1 at upr.edu> wrote:
> >>>>>>>
> >>>>>>> … and the same I get the same issue with R “help” screens in my
> iMac.
> >>>>>> I cannot reproduce this in the macBook.
> >>>>>>>
> >>>>>>> José
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> <R help .png>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> José G. Conde, MD, MPH
> >>>>>>> Catedrático, Escuela de Medicina Director, CentIT2 Recinto de
> >>>>>>> Ciencias Médicas, UPR
> >>>>>>>
> >>>>>>> Tel (787) 763-9401 Fax (787) 758-5206
> >>>>>>>
> >>>>>>> Correo electrónico: jose.conde1 at upr.edu
> >>>>>>>
> >>>>>>> URL: http://rcmi.rcm.upr.edu
> >>>>>>>
> >>>>>>>> On May 15, 2017, at 2:14 PM, Jose G Conde Santiago
> >>>>>> <jose.conde1 at upr.edu> wrote:
> >>>>>>>>
> >>>>>>>> This is the actual resolutions.
> >>>>>>>>
> >>>>>>>> José
> >>>>>>>>
> >>>>>>>> <Fonts 20 points.png>
> >>>>>>>> José G. Conde, MD, MPH
> >>>>>>>> Professor, School of Medicine
> >>>>>>>> Director, CentIT2
> >>>>>>>> UPR Medical Sciences Campus
> >>>>>>>>
> >>>>>>>> Tel (787) 763-9401 Fax (787) 758-5206
> >>>>>>>>
> >>>>>>>> Email: jose.conde1 at upr.edu
> >>>>>>>>
> >>>>>>>> URL: http://rcmi.rcm.upr.edu
> >>>>>>>>
> >>>>>>>>> On May 15, 2017, at 12:31 PM, Jose G Conde Santiago
> >>>>>> <jose.conde1 at upr.edu> wrote:
> >>>>>>>>>
> >>>>>>>>> <Fonts 20 points.png>
> >>>>>>>>
> >>>>>>>
> >>>>>
> >>>>> _______________________________________________
> >>>>> R-SIG-Mac mailing list
> >>>>> R-SIG-Mac at r-project.org
> >>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> >>>>
> >>>> --
> >>>> Peter Dalgaard, Professor,
> >>>> Center for Statistics, Copenhagen Business School Solbjerg Plads 3,
> >>>> 2000 Frederiksberg, Denmark
> >>>> Phone: (+45)38153501
> >>>> Office: A 4.23
> >>>> Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>> --
> >>> Peter Dalgaard, Professor,
> >>> Center for Statistics, Copenhagen Business School Solbjerg Plads 3,
> >>> 2000 Frederiksberg, Denmark
> >>> Phone: (+45)38153501
> >>> Office: A 4.23
> >>> Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >> --
> >> Peter Dalgaard, Professor,
> >> Center for Statistics, Copenhagen Business School Solbjerg Plads 3,
> >> 2000 Frederiksberg, Denmark
> >> Phone: (+45)38153501
> >> Office: A 4.23
> >> Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >
> > --
> > Peter Dalgaard, Professor,
> > Center for Statistics, Copenhagen Business School Solbjerg Plads 3,
> > 2000 Frederiksberg, Denmark
> > Phone: (+45)38153501
> > Office: A 4.23
> > Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
> >
> >
> >
> >
> >
> >
> >
> >
> >
More information about the R-SIG-Mac
mailing list