use_font {gfonts} | R Documentation |
Use a downloaded font in Shiny or Markdown
Description
Use a downloaded font in Shiny or Markdown
Usage
use_font(id, css_path, selector = "body", css = NULL)
Arguments
id |
Id of the font downloaded. |
css_path |
Path to CSS generated by |
selector |
CSS selector for which to use the font,
usually an HTML tag, default to |
css |
CSS variables needed to use font, normally this should be automatic. |
Value
an HTML tag with an HTML dependency (htmlDependency
).
Examples
if (interactive()) {
library(gfonts)
# Here we use a temp directory
# but in Shiny, it can be www/ folder
directory <- tempfile()
dir.create(directory)
# Setup a font (only needed once)
setup_font(
id = "dancing-script",
output_dir = directory
)
library(shiny)
ui <- fluidPage(
# Use font
use_font(
id = "dancing-script",
css_path = file.path(directory, "css/dancing-script.css")
),
tags$p(
paste(letters, collapse = "")
),
tags$p(
paste(LETTERS, collapse = "")
),
tags$p(
style = "font-weight: bold;",
paste(letters, collapse = "")
),
tags$p(
style = "font-weight: bold;",
paste(LETTERS, collapse = "")
),
tags$p(
style = "font-style: italic;",
paste(letters, collapse = "")
),
tags$p(
style = "font-style: italic;",
paste(LETTERS, collapse = "")
),
tags$h1("First level title"),
tags$h2("Second level title"),
tags$h3("Third level title"),
tags$h4("Fourth level title"),
tags$h5("Fifth level title"),
tags$h6("Sixth level title")
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
}
[Package gfonts version 0.2.0 Index]