automatic command when load my library

Hi,

At my company I created a package for plot formatting, but we use font Roboto, which we have to load in R every time. Is there a way to make extrafont::loadfonts(device="win") an automatic response when someone runs library(ourpackage).

I am thinking something similar to .Rprofile but pushing it into a package.

thank you for your help in advance,
Marcell

Chapter 7 R code | R Packages (r-pkgs.org)

7.5.4 When you do need side-effects

Occasionally, packages do need side-effects. This is most common if your package talks to an external system — you might need to do some initial setup when the package loads. To do that, you can use two special functions: .onLoad() and .onAttach() . These are called when the package is loaded and attached. You’ll learn about the distinction between the two in Namespaces. For now, you should always use .onLoad() unless explicitly directed otherwise.

1 Like

For an alternative workflow without the extrafont package see the overview Setting up and debugging custom fonts that uses ragg. Now, of course if you are otherwise happy with extrafont, no need to switch. :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.