Hi everyone,
I'm developing an internal package for my organization. We've decided to start with some basic functions that will help use deliver more consistent visualizations using our corporate image (vector with corporate color codes, logos, functions to standarized ggplots, etc).
We have our own custom font which is 'Montserrat'. It's a google font so we can even use it with R Markdown files. Nevertheless, we algo use it with ggplot graphs so we can keep our visualizations clean and standarized. In order to do that we have a local folder with out fonts with '.ttf' formats.
For the first time using this font we make a standard procedure which implies that each user downloads the folder available in the cloud with the font, installs it and then run the following code from the extrafont package:
# Install the package if needed
install.packages('extrafont')
#Load the package
library(extrafont)
# this funciton imports the fonts
font_import()
loadfonts(device = "win")
I would like to know if there is a way in which I could automate the entire process and have the font files save into my R Package. In this way the process of importing the brand's font would look something like:
- Install Internal Package
- Run Function called: setup_font() ( Or whatever name we assign)
- This function now goes through the files inside the R Package, look for the fonts, then install the library extrafont if necessary. Solve any issues ( sometimes you have to install the following package because it may cause conflicts:
remotes::install_version("Rttf2pt1", version = "1.3.8")
- Install the fonts in the user's pc
- Import Fonts to extrafont
Is that Possible? If it is, could you guide me into how to do something like this? How should i save the fonts in the package, etc.
I would really appreciate it. I haven't found any help in other forums.
Thank you.