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

Font import helpers #74

Merged
merged 18 commits into from
Mar 26, 2021
Merged

Font import helpers #74

merged 18 commits into from
Mar 26, 2021

Conversation

cpsievert
Copy link
Contributor

@cpsievert cpsievert commented Mar 19, 2021

This PR ports font_google(), font_link(), and font_face() from {bslib} into {sass} so that any {sass} project can more easily import font files when declaring font-family Sass variables. The one catch is that you must use them inside named list variable declarations (as shown below). Note that by default font_google() will download, cache, and serve font files locally (so end users don't need an internet connection to render the font), but you can also import any remotely hosted web font with font_link()/font_face().

library(htmltools)

scss <- list(
  list("font-variable" = font_google("Pacifico")),
  list("body {font-family: $font-variable}")
)

hello <- tags$body(
  "Hello",
  tags$style(sass(scss))
)

if (interactive()) {
  browsable(hello)
}

Screen Shot 2021-03-19 at 5 18 27 PM

@cpsievert cpsievert marked this pull request as draft March 19, 2021 23:04
@cpsievert cpsievert marked this pull request as ready for review March 22, 2021 22:20
R/as_sass.R Show resolved Hide resolved
R/fonts.R Show resolved Hide resolved
R/fonts.R Outdated Show resolved Hide resolved
R/fonts.R Outdated Show resolved Hide resolved
R/fonts.R Show resolved Hide resolved
R/fonts.R Show resolved Hide resolved
… named arguments (i.e., font_collection(google = 'foo') => font_collection(font_google('foo')) )
R/fonts.R Outdated Show resolved Hide resolved
R/fonts.R Show resolved Hide resolved
@cpsievert cpsievert merged commit 4b98868 into master Mar 26, 2021
@cpsievert cpsievert deleted the font-import-helpers branch March 26, 2021 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants