Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settable font options #591

Merged
merged 22 commits into from
Jul 13, 2020
Merged

Settable font options #591

merged 22 commits into from
Jul 13, 2020

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

R/compile_scss.R Outdated Show resolved Hide resolved
R/helpers.R Outdated Show resolved Hide resolved
R/opts.R Show resolved Hide resolved
R/helpers.R Outdated Show resolved Hide resolved
@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?

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
rich-iannone added a commit that referenced this pull request Oct 13, 2020
* master:
  Rewrite of RTF building functions and `as_rtf()` (#638)
  v0.2.2 Release Candidate (#629)
  Settable font options (#591)
  Add options for sig figs / inclusion of trailing dec marks (#546)
  Fix issues with defining column widths in `cols_width()` (#561)
  Add `scale_values` arg to `fmt_percent()` (#565)
  Restore row striping option in stub cells (`row.striping.include_stub = TRUE`) (#564)
  Refactor `data_color()` so that it executes faster (#576)
  Update R-CMD-check.yaml (#599)
  Release gt 0.2.1 (#588)
  Ensure that row ordering doesn't affect summary row calculations (#556)
rich-iannone added a commit that referenced this pull request Oct 25, 2020
* master: (30 commits)
  Spanner alignment correction (#662)
  PEN currency fix (#663)
  Fix for `gtsave()` when saving an image and specifying a `path` value (#592)
  Rewrite of RTF building functions and `as_rtf()` (#638)
  v0.2.2 Release Candidate (#629)
  Settable font options (#591)
  Add options for sig figs / inclusion of trailing dec marks (#546)
  Fix issues with defining column widths in `cols_width()` (#561)
  Add `scale_values` arg to `fmt_percent()` (#565)
  Restore row striping option in stub cells (`row.striping.include_stub = TRUE`) (#564)
  Refactor `data_color()` so that it executes faster (#576)
  Update R-CMD-check.yaml (#599)
  Release gt 0.2.1 (#588)
  Ensure that row ordering doesn't affect summary row calculations (#556)
  Update failing example (#586)
  Remove test of scales behaviour
  Squelch warnings from tibble 3.0.0/3.0.1 (#557)
  Bump cache on pkgdown.yaml for GH workflow (#570)
  Update GH Actions workflow for R CMD check (#568)
  Update Description of package to be less confusing (#569)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants