Description Usage Arguments Value Examples
Use a downloaded font in Shiny or Markdown
1 |
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. |
an HTML tag with an HTML dependency (htmlDependency
).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.