Skip to contents

The vector of fonts given by default_fonts() can be safely used with a gt table rendered as HTML since the font stack is expected to be available across a wide set of systems. We can always specify additional fonts to use and place them higher in precedence order, done through prepending to this vector (i.e., this font stack should be placed after that to act as a set of fallbacks).

This vector of fonts is useful when specifying font values inside cell_text() (itself usable in tab_style() or tab_style_body()). If using opt_table_font() (which also has a font argument), we probably don't need to specify this vector of fonts since that function prepends font names (this is handled by its add option, which is TRUE by default).




A character vector of font names.


Let's use the exibble dataset to create a simple, two-column gt table (keeping only the char and time columns). Attempting to modify the fonts used for the time column is much safer if default_fonts() is appended to the end of the font listing inside cell_text(). What will happen, since the "Comic Sansa" and "Menloa" fonts shouldn't exist, is that we'll get

exibble |>
  dplyr::select(char, time) |>
  gt() |>
    style = cell_text(
      font = c("Comic Sansa", "Menloa", default_fonts())
    locations = cells_body(columns = time)

This image of a table was generated from the first code example in the `default_fonts()` help file.

Function ID


Function Introduced

v0.2.2 (August 5, 2020)