Learn R Programming

gfonts

Download ‘Google’ fonts (via google-webfonts-helper) and generate CSS to use in rmarkdown documents and shiny applications. Some popular fonts are included and ready to use.

Installation

Install from CRAN with:

install.packages("gfonts")

You can install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("dreamRs/gfonts")

Download a font to use it locally

Get the ID of the desired font between 1474 available :

library(gfonts)
get_all_fonts()

Download the files necessary for its use and generate the appropriate CSS code :

setup_font(
  id = "roboto",
  output_dir = "path/to"
)

Use it in {shiny} or {rmarkdown} :

use_font("roboto", "www/css/roboto.css")

:point_right: See detailed example

Included fonts

Some fonts are included in the package and ready to use :

use_pkg_gfont("roboto")

:point_right: See all fonts available

Related packages

  • Package googlefontR provides helper functions to ease the use of Google Fonts with R.
  • Package showtext makes it easy to use various types of fonts (TrueType, OpenType, Type 1, web fonts, etc.) in R graphs.

Copy Link

Version

Install

install.packages('gfonts')

Monthly Downloads

2,824

Version

0.2.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Victor Perrier

Last Published

January 8th, 2023

Functions in gfonts (0.2.0)

included_fonts

Detail about included fonts.
gfonts

Use Google fonts offline
generate_css

Generate CSS to import fonts
get_font_info

Get detailed information about a font
download_font

Download font files
tag_example

Generate HTML tags used in examples
use_font

Use a downloaded font in Shiny or Markdown
use_pkg_gfont

Use a Google Font included in gfonts
get_all_fonts

Get infos about all fonts available
setup_font

Setup a font to be used in Shiny or Markdown