Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dreamRs/gfonts
:abc: Offline Google Fonts for rmarkdown and shiny
https://github.com/dreamRs/gfonts
fonts r rmarkdown shiny
Last synced: 3 months ago
JSON representation
:abc: Offline Google Fonts for rmarkdown and shiny
- Host: GitHub
- URL: https://github.com/dreamRs/gfonts
- Owner: dreamRs
- Created: 2020-01-16T20:07:52.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-08T18:52:28.000Z (almost 2 years ago)
- Last Synced: 2024-05-21T02:11:04.162Z (6 months ago)
- Topics: fonts, r, rmarkdown, shiny
- Language: R
- Homepage: https://dreamrs.github.io/gfonts/
- Size: 10.3 MB
- Stars: 112
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
- jimsghstars - dreamRs/gfonts - :abc: Offline Google Fonts for rmarkdown and shiny (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# gfonts
[![CRAN status](https://www.r-pkg.org/badges/version/gfonts)](https://CRAN.R-project.org/package=gfonts)
[![Codecov test coverage](https://codecov.io/gh/dreamRs/gfonts/branch/master/graph/badge.svg)](https://app.codecov.io/gh/dreamRs/gfonts?branch=master)
[![R-CMD-check](https://github.com/dreamRs/gfonts/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/dreamRs/gfonts/actions/workflows/R-CMD-check.yaml)> Download 'Google' fonts (via [google-webfonts-helper](https://gwfh.mranftl.com)) and generate CSS to use in [rmarkdown](https://rmarkdown.rstudio.com/) documents and [shiny](https://shiny.rstudio.com/) applications. Some popular fonts are included and ready to use.
## Installation
Install from [CRAN](https://CRAN.R-project.org/package=gfonts) with:
```r
install.packages("gfonts")
```You can install the development version from [GitHub](https://github.com/dreamRs/gfonts) with:
```r
# install.packages("remotes")
remotes::install_github("dreamRs/gfonts")
```## Download a font to use it locally
Get the ID of the desired font between **`r nrow(gfonts::get_all_fonts())`** available :
```{r all-fonts, eval=FALSE}
library(gfonts)
get_all_fonts()
```Download the files necessary for its use and generate the appropriate CSS code :
```{r setup-font, eval=FALSE}
setup_font(
id = "roboto",
output_dir = "path/to"
)
```Use it in {shiny} or {rmarkdown} :
```{r use-font, eval=FALSE}
use_font("roboto", "www/css/roboto.css")
```:point_right: [See detailed example](https://dreamrs.github.io/gfonts/articles/gfonts.html)
## Included fonts
Some fonts are included in the package and ready to use :
```{r included-fonts, eval=FALSE}
use_pkg_gfont("roboto")
```![](man/figures/included-fonts.png)
:point_right: [See all fonts available](https://dreamrs.github.io/gfonts/articles/articles/included-fonts.html)
## Related packages
* Package [`googlefontR`](https://github.com/timelyportfolio/googlefontR) provides helper functions to ease the use of Google Fonts with R.
* Package [`showtext`](https://github.com/yixuan/showtext) makes it easy to use various types of fonts (TrueType, OpenType, Type 1, web fonts, etc.) in R graphs.