knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) code_output <- function(x) { writeLines(c("```", x, "```")) }
code_output(rfiglet::figlet("rfiglet!"))
rfiglet is a pure-R implementation of FIGlet (Frank, Ian and Glenn's letters) a classic system for creating text banners in many fonts.
The core of the package is the rfiglet::figlet
function, which renders a string in a figlet font (by default standard
)
rfiglet::figlet("Hello world!")
There are r length(rfiglet::figlet_font_list())
bundled fonts, representing the standard figlet font library
rfiglet::figlet_font_list()
Pass the name of the font to rfiglet::figlet
to use it
rfiglet::figlet("Hello shadow!", font = "shadow")
There are many more fonts available, and these can be downloaded by running
path <- rfiglet::figlet_download_fonts()
This will download all the extra fonts to wherever RFIGLET_FONT_DIR
points, falling back on the cache directory tools::R_user_dir("rfiglet", "data"
in R 4.0.0 or higher
dir(path)
Once downloaded you can reference these fonts by name (i.e., filename without the extension)
rfiglet::figlet("Extra!", font = "acrobatic.flf")
Some degree of layout conrol is available via the arguments justify
and width
, powered by R's strwrap
and format
options. By default lines are broken at the width of your terminal (getOption("width")
) but you can override this.
If a string is too long it will be wrapped to fit:
rfiglet::figlet("A quick brown fox", width = 45)
You can align the fragments relative to each other using justify
:
rfiglet::figlet("A quick brown fox", width = 45, justify = "centre")
Or relative to the entire width by adding absolute = TRUE
rfiglet::figlet("A quick brown fox", width = 45, justify = "centre", absolute = TRUE)
The latter option is more obvious with a longer width or shorter text
rfiglet::figlet("right", justify = "right", absolute = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.