Conditionally import a function from another package

My package imports a function available only on Windows systems: grDevices::windowsFonts().

This causes problems for a Mac user attempting to build the package through RStudio's "Build" pane (which I assume is equivalent to a source install).

Error: object 'windowsFonts' is not exported by 'namespace:grDevices'

Is there a way to conditionally import the function only if the system is Windows?

You could use a structure like this:

if (.Platform$OS.type == "windows") {