Zé Loff writes:

> Although changing the default font can be easily done -- adding a
> default site-wide configuration file could be a possible workaround to
> make the port work properly again -- this appears not to be the case
> with the math/greek symbols font, which seems to be harder to replace,
> so just changing fonts isn't a proper fix.
>
> However, all works properly if R is instructed to forget about cairo and
> just use the "Xlib" device as a default (as is done on macOS, precisely
> due to issues with pango).  Ingo: do you think we should patch the port
> to do this, until the pango/type 1 issues are solvable

>> 3. Fonts don't render in the Plots window. Not sure why. Help
>> appreciated.
>
> pango/harfbuzz fallout, probably.  Pango stopped supporting Type 1
> fonts.  I have the same issue with R itself.  My solution it to add
>
>   options.X11(family = "DejaVu Sans")
>
> or some other TrueType family.

I was preparing an editors/TeXmacs update and noticed that the R plugin
had graphs with missing glyphs.

Here is a diff for R to do what Ze Loff suggested in these two
threads[2][3]. Fix taken from [1]. sthen@ described the root cause in
[2] but consider this workaround.

This diff:
- changes the site-wide config
  (/usr/local/lib/R/library/base/R/Rprofile) to use DejaVu Sans by
  default.
- updates README to document that the font can be changed
- bumps REVISION
sources:
[1] 
https://stackoverflow.com/questions/1189759/expert-r-users-whats-in-your-rprofile
[2] https://marc.info/?l=openbsd-ports&m=157830898518255&w=2
[3] https://marc.info/?l=openbsd-ports&m=159342491019196&w=2

I was able to run these two test plots with the TeXmacs R plugin,
math/rstudio and with R itself.

test 1:
demo(plotmath)
mash enter a few times

test 2:
qnorm(1/2,mean=0,sd=1)
x<-1:100
y<-rnorm(x)
plot(x,y)

Feedback and tests are welcome.

Index: Makefile
===================================================================
RCS file: /cvs/ports/math/R/Makefile,v
retrieving revision 1.118
diff -u -p -u -p -r1.118 Makefile
--- Makefile    23 Jun 2020 18:54:24 -0000      1.118
+++ Makefile    16 Jul 2020 06:20:25 -0000
@@ -2,6 +2,7 @@
 
 COMMENT=       powerful math/statistics/graphics language
 DISTNAME=      R-4.0.2
+REVISION=      0
 
 SO_VERSION=    37.0
 .for _lib in R Rblas Rlapack
Index: patches/patch-src_library_profile_Common_R
===================================================================
RCS file: patches/patch-src_library_profile_Common_R
diff -N patches/patch-src_library_profile_Common_R
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_library_profile_Common_R  16 Jul 2020 06:20:25 -0000
@@ -0,0 +1,17 @@
+$OpenBSD$
+
+add default font to fix missing font on plots. see:
+https://stackoverflow.com/questions/1189759/expert-r-users-whats-in-your-rprofile
+
+Index: src/library/profile/Common.R
+--- src/library/profile/Common.R.orig
++++ src/library/profile/Common.R
+@@ -35,6 +35,8 @@ options(show.error.messages = TRUE)
+ options(scipen = 0)
+ options(max.print = 99999)# max. #{entries} in internal printMatrix()
+ options(add.smooth = TRUE)# currently only used in 'plot.lm'
++setHook(packageEvent("grDevices", "onLoad"),
++    function(...) grDevices::X11.options(family = "DejaVu Sans"))
+ 
+ if(isFALSE(as.logical(Sys.getenv("_R_OPTIONS_STRINGS_AS_FACTORS_",
+                                  "FALSE")))) {
Index: pkg/README
===================================================================
RCS file: /cvs/ports/math/R/pkg/README,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 README
--- pkg/README  18 May 2020 05:26:13 -0000      1.10
+++ pkg/README  16 Jul 2020 06:20:25 -0000
@@ -16,3 +16,9 @@ Running:
 
 as root, will update both ${TRUEPREFIX}/lib/R/etc/Makeconf and
 ${TRUEPREFIX}/lib/R/etc/ldpaths with the right settings.
+
+Changing fonts
+==============
+Fonts on plots can be customized.
+
+> X11.options(family = "DejaVu Sans")

Reply via email to