Thursday 17 May 2018

shiny - Using custom fonts on shinyapps.io

This is the answer I received from RStudio regarding this. I haven't tested this out myself.


Hi,


Our developer was able to advise this is due to a possibly unfortunate design choice made when they created extrafont and the associated extrafontdb package. The extrafont font database is stored in the extrafontdb package directory -- that's essentially all that the extrafontdb package is used for.


This means that the extrafontdb directory needs to be user-writable. If the user installs the package, this will work fine, but if root installs the package (as is the case on shinyapps.io), then it won't work.


One potential workaround is to install the extrafontdb package to library that is in subdirectory of the app.


To do it: create an r-lib/ subdir, and download the extrafontdb source package there:


dir.create('r-lib')
download.file('https://cran.r-project.org/src/contrib/extrafontdb_1.0.tar.gz','r-lib/extrafontdb_1.0.tar.gz')

When deployed, the app will include this r-lib/ subdirectory and the extrafontdb source package.


Then, at the top of the app, install the extrafontdb package from the source package, into the r-lib directory.


.libPaths(c('r-lib', .libPaths()))
install.packages('r-lib/extrafontdb_1.0.tar.gz',type = 'source',repos = NULL)

They deployed an app on shinyapps.io that does the extrafontdb installation, and it works fine. The libpath is set so so that install.packages() will install from the provided source package to the r-lib/ subdirectory of the app.


Please let us know if you're able to implement the above or have any additional questions.


Thanks,

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...