Skip to content

Conversation

@rich-iannone
Copy link
Member

@rich-iannone rich-iannone commented May 20, 2020

This PR adds the ability to specify additional table fonts before the default set in the font family. This is done globally with the opt_font() function, which either accepts a local font name, or, could use the google_font() function (for specifying a webfont hosted on the Google Fonts service).

There is also the new ability to specify a Google Font through google_font() in cell_text()'s font argument.

Here is some testable code:

exibble %>%
  dplyr::select(char, time) %>%
  gt() %>%
  tab_style(
    style = cell_text(font = c("Comic Sans MS", "Menlo", default_fonts())),
    locations = cells_body(columns = vars(time))
  ) %>%
  opt_table_font(font = list(google_font(name = "Dancing Script"), "Menlo"))

Fixes: #595
Fixes: #585
Fixes: #589
Fixes: #598
Fixes: #404

cc @jthomasmock

@rich-iannone rich-iannone requested a review from schloerke May 29, 2020 19:28
@rich-iannone rich-iannone marked this pull request as ready for review June 1, 2020 15:00
@jcheng5
Copy link
Member

jcheng5 commented Jun 8, 2020

Add unexported function for appending to initial_css. This function would paste(collapse="\n") its CSS argument, and have an allow_duplicates=TRUE/FALSE parameter that determines whether it should be added if it is already %in% initial_css.

@jcheng5
Copy link
Member

jcheng5 commented Jun 12, 2020

Notes from in-person discussion.

  1. Should this be generalized from an "include arbitrary CSS" feature to "prepend/append arbitrary htmltools HTML"?
  2. Do we need a dedicated set of functions for composing CSS from R, and if so, should they live here or htmtools?
  3. Do we support scss?
  4. How can provided CSS use the id for table-instance-specific rules?

@rich-iannone rich-iannone requested a review from jcheng5 July 13, 2020 19:05
jcheng5
jcheng5 previously approved these changes Jul 13, 2020
@rich-iannone rich-iannone merged commit 6058358 into master Jul 13, 2020
@rich-iannone rich-iannone deleted the global-font-options branch July 13, 2020 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants