Learn R Programming

rgl (version 1.3.1)

rglExtrafonts: Register extra fonts

Description

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

Usage

rglExtrafonts(..., quiet = TRUE)

Value

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

Arguments

...

Vectors of fonts to try. See the Details.

quiet

Whether to print information on progress.

Author

Duncan Murdoch

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.

See Also

text3d, rglFonts

Examples

Run this code
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)
  
}

Run the code above in your browser using DataLab