Skip to contents

The google_font() helper function can be used wherever a font name should be specified. There are two instances where this helper can be used: the name argument in opt_table_font() (for setting a table font) and in that of cell_text() (used with tab_style()). To get a helpful listing of fonts that work well in tables, use the info_google_fonts() function.





The complete name of a font available in Google Fonts.


An object of class font_css.


Use exibble to create a gt table of eight rows, replace missing values with em dashes. For text in the time column, we use the Google font "IBM Plex Mono" and set up the default_fonts() as fallbacks (just in case the webfont is not accessible).

exibble %>%
  dplyr::select(char, time) %>%
  gt() %>%
  sub_missing() %>%
    style = cell_text(
      font = c(
        google_font(name = "IBM Plex Mono"),
    locations = cells_body(columns = time)

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

Use sp500 to create a small gt table, using fmt_currency() to provide a dollar sign for the first row of monetary values. Then, set a larger font size for the table and use the "Merriweather" font using the google_font() function (with two font fallbacks: "Cochin" and the catchall "Serif" group).

sp500 %>%
  dplyr::slice(1:10) %>%
  dplyr::select(-volume, -adj_close) %>%
  gt() %>%
    columns = 2:5,
    rows = 1,
    currency = "USD",
    use_seps = FALSE
  ) %>%
  tab_options(table.font.size = px(20)) %>%
    font = list(
      google_font(name = "Merriweather"),
      "Cochin", "Serif"

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

Function ID