Adding a function which detects the client’s OS and silently loads fonts accordingly
When building a package for clients which applies a custom theme, I was keen to make it as easy as possible. But particular issue caused a few headaches. I adapted this solution by June Choe to add a simple .onLoad()
function to the package - problem solved!
The challenge was tied to Mac and Windows dealing differently with spaces in font names. Working across different operating systems at rfortherest showed us where the problem was. The package now includes a function which detects the OS and silently loads fonts accordingly 🥳
Adding an .onLoad()
function to the package is a really useful trick that I’ll be using again! Really easy way to set things up nicely without having to remind clients to run X, Y or Z function before making use of the rest of the package. But with one key caveat. If the font isn’t installed on the client’s device, the .onLoad()
function produces an error when the client tries to install the package - once we figured that out, it more plain sailing!
Every day an #rstats school day!