Reputation: 25
This question relates to an answer given by Yihui here:
https://groups.google.com/g/shinyapps-users/c/0czcsM4vziM/m/GNuyL3ClCgAJ
In the instruction, it says to:
I've put this into my .app code (just after all my library() calls) before trying to deploy the app to shinapps.io.:
dir.create('~/.fonts')
download.file('https://github.com/**MY USERNAME**/fonts', '~/.fonts')
system('fc-cache -f ~/.fonts')
As you can see, I have put all the fonts the app requires into a public repo on my github account. This is the URL that the font .ttf files are from. However, i think i may have misunderstood the directions, as i get this error from shinyapps.io:
Error in value[[3L]](cond) : Error sourcing /srv/connect/apps/font/app.R
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
The fonts I wish to use are derivations of the "Sarabun" and "Garamond" families.
Please can someone provide more detail to Yihui's solution? Any help would be greatly appreciated. If you also have another solution that would be good to hear. However, please note that 'font style packages' tend not to work with shinyapps.io as these look locally for the styles, which defeats the purpose of it! Additionally, I wish to use a specific .ttf file.
Cheers all,
Matt
Upvotes: 0
Views: 497
Reputation:
The URL https://github.com/**MY USERNAME**/fonts
points to a repository overview, not the folder itself, so maybe you are downloading just the HTML page on that URL.
You need to download the archive depending on your OS (ZIP on Windows, .TAR.GZ on Unix-alike).
download.file("https://github.com/**USERNAME**/fonts/archive/master.tar.gz", destfile = "fonts.tar.gz")
# or ZIP file on Windows
download.file("https://github.com/**USERNAME**/fonts/archive/master.zip", destfile = "fonts.zip")
Then you have to extract the archive:
untar("fonts.tar.gz", exdir = "~/.fonts/")
# or with ZIP file on Windows
unzip("fonts.zip", exdir = "~/.fonts/")
Then you can use that in your script:
system('fc-cache -f ~/.fonts')
I hope the way is clear as it may vary depending on your OS, fonts and subfolders etc... Something like that should work.
Upvotes: 1