This function uses the extrafont package to help register system fonts for use with FreeType in rgl.

rglExtrafonts(..., quiet = TRUE)

Arguments

...

Vectors of fonts to try. See the Details.

quiet

Whether to print information on progress.

Details

The extrafont package collects information on installed fonts from the system. When you first install extrafont, or after new fonts have been installed on your system, run extrafont::font_import() to build its database of system fonts.

Fonts can be installed in rgl using rglExtrafonts(rglname = familyname) or rglExtrafonts(familyname). In this call familyname is a vector of family names to look for in the extrafont database using extrafont::choose_font(familyname); the first one found will be registered with rgl. The optional name rglname will also be usable to refer to the font family.

If none of the given family names is found, no change will be made to the registered fonts in rgl.

During startup, rgl detects whether extrafont is installed, and if so runs rglExtrafonts(sans = c("Helvetica", "Arial"), serif = c("Times", "Times New Roman"), mono = c("Courier", "Courier New")) to attempt to set up the default fonts.

Fonts found by extrafont can also be used in some other graphics devices besides rgl; see the extrafont documentation for details.

Note

Each font in a display needs a unique rgl name; if the associated font for a given name is changed, all previously plotted text will also change.

Currently rglwidget displays will not respect the new definitions.

Value

Invisibly returns a vector giving the rgl name and the family name for the newly installed font.

Author

Duncan Murdoch

See also

Examples

if (requireNamespace("extrafont") && !in_pkgdown_example()) {
  
  open3d()
  text3d(1,1,1, "Default", family = "sans", cex = 2)  
  
  # Attempt to register new sans-serif font:
  newfamily <- rglExtrafonts(newsans = c("Comic Sans MS", "Impact", 
                                         "Verdana", "Tahoma"))
  
  text3d(2,2,2, newfamily, family = "newsans", cex = 2)
  
}