Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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)

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.

Value

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

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.

Author(s)

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)
  
}

rgl

3D Visualization Using OpenGL

v0.106.8
GPL
Authors
Duncan Murdoch [aut, cre], Daniel Adler [aut], Oleg Nenadic [ctb], Simon Urbanek [ctb], Ming Chen [ctb], Albrecht Gebhardt [ctb], Ben Bolker [ctb], Gabor Csardi [ctb], Adam Strzelecki [ctb], Alexander Senger [ctb], The R Core Team [ctb, cph], Dirk Eddelbuettel [ctb], The authors of Shiny [cph], The authors of knitr [cph], Jeroen Ooms [ctb], Yohann Demont [ctb], Joshua Ulrich [ctb], Xavier Fernandez i Marin [ctb], George Helffrich [ctb], Ivan Krylov [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.