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

fa_png

Create a PNG version of a Font Awesome icon


Description

Get a Font Awesome icon as a PNG file. We can optionally set the fill attribute before writing the PNG. Additionally, there is control over the output width and height (usually, icons are 512 by 512 pixels). Please note that this function requires that the rsvg is installed on the system. Attempting to use fa_png() without rsvg available will result in an error message.

Usage

fa_png(
  name,
  file = NULL,
  fill = NULL,
  fill_opacity = NULL,
  stroke = NULL,
  stroke_width = NULL,
  stroke_opacity = NULL,
  height = NULL,
  width = NULL
)

Arguments

name

The name of the Font Awesome icon.

file

the path to the output file. If NULL, then filename will take the short name of the icon and a .png extension will be applied.

fill, fill_opacity

The fill color of the icon can be set with fill. If not provided then the default fill color will be black. The opacity level of the fill color can be controlled with a decimal value between 0 and 1.

stroke, stroke_width, stroke_opacity

The stroke options allow for setting the color, width, and opacity of the outline stroke. By default, the stroke width is very small at "1px" so a size adjustment with "stroke_width" can be useful. The "stroke_opacity" value can be any decimal values between 0 and 1 (bounds included).

height, width

The output height and width of the rendered PNG. If nothing is provided then the output dimensions will match that of the input SVG viewBox.

Value

A PNG file written to disk.

Examples

if (interactive()) {

# Create a Font Awesome SVG icon as a
# PNG file on disk
fa_png(name = "r-project")

}

fontawesome

Easily Work with 'Font Awesome' Icons

v0.2.1
MIT + file LICENSE
Authors
Richard Iannone [aut, cre] (<https://orcid.org/0000-0003-3925-190X>), Christophe Dervieux [ctb] (<https://orcid.org/0000-0003-4474-2498>), Winston Chang [ctb], Dave Gandy [ctb, cph] (Font-Awesome font), RStudio [cph, fnd]
Initial release

We don't support your browser anymore

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