Parameters to customize fonts in various roboplotr contexts.
Arguments
- font
 Character. One of your system fonts if
systemfontspackage is available, or "Arial", "Verdana", "Tahoma", "Trebuchet", "Times New Roman", "Georgia", "Garamond", "Courier New", "Brush Script MT", a Google font, or a path to an .otf or .ttf file.- fallback
 Character. Only used when a file path is used with
font. Fallback font when the defined font is unavailable. Especially concerns image downloads.- size
 Numeric. Font size.
- color
 Character. Must be a hexadecimal color or a valid css color.
- bold_title
 Logical. Only used for font of type
title. Determines if the title is bolded.- ...
 Placeholder for future arguments
Examples
# Used to set fonts used by `roboplotr` functions. You can designate various
# specifications. You must provide a web-safe fallback (as accepted by `roboplotr`,
# see `font`) font if an actual filepath is provided for 'path'.
set_roboplot_options(
  caption_template = "Lähde: {text}!!",
  font_title = set_font(size = 17, font = "Tahoma", bold = TRUE),
  font_main =  set_font(
    size = 11,
    font = system.file("www","fonts","bladerunner.TTF", package = "roboplotr"),
    fallback = "Verdana",
    color = "darkred",
    type = "main"),
  font_caption = set_font(color = "green")
)
#> Warning: The `font_caption` argument of `set_roboplot_options()` is deprecated as of
#> roboplotr 2.7.0.
#> ℹ Please use the `caption` argument instead.
#> Warning: The `font_title` argument of `set_roboplot_options()` is deprecated as of
#> roboplotr 2.7.0.
#> ℹ Please use the `title` argument instead.
d <- energiantuonti |> dplyr::filter(Alue == "USA",Suunta == "Tuonti")
d |> roboplot(Alue,"Energian tuonti Yhdysvalloista","Milj. €","Tilastokeskus")
# Valid Google Fonts work as well.
set_roboplot_options(font_title = set_font(font = "Exo"))
# Note that `plotly`'s own downloadImage method does not support external fonts.
# It can only use the fonts the browser has available. Use `set_artefacts()`
# `roboplot()` to automate their creation if you need static images with external fonts.
if (FALSE) { # \dontrun{
  # Create a html file with `roboplot()`.
  d |>
    roboplot(
      color = Alue,
      title = "Energian tuonti Yhdysvalloista",
      subtitle = "Milj. €",
      caption = "Tilastokeskus",
      artefacts = set_artefacts(artefacts = c("html", "png"), filepath = tempdir())
    )
  # The html has proper fonts, but files exported from modebar will not.
  utils::browseURL(paste0(tempdir(),"/energian_tuonti_yhdysvalloista.html"))
  # The images automated with `set_artefacts()` will have the proper font.
  utils::browseURL(paste0(tempdir(),"/energian_tuonti_yhdysvalloista.png"))
} # }
# Revert to defaults:
set_roboplot_options(reset = TRUE)