Skip to content

Commit

Permalink
create spectral_font_dep()
Browse files Browse the repository at this point in the history
  • Loading branch information
RLesur committed Apr 24, 2020
1 parent 62acee0 commit 23722a5
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 6 deletions.
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ Authors@R:
email = "[email protected]"),
person(family = "République Française",
role = "cph"),
person(family = "Production Type",
person(family = "Production Type",
role = "cph",
comment = "Spectral typeface in inst/resources/fonts/spectral/files"))
Description: Produce documents compliants with the French
government design system.
License: EUPL (>= 1.2) | file LICENCE
URL: https://github.com/spyrales/gouvdown
BugReports: https://github.com/spyrales/gouvdown/issues
Imports:
htmltools,
utils,
xfun
Suggests:
testthat
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.0
Imports:
htmltools
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Generated by roxygen2: do not edit by hand

export(spectral_font_dep)
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# gouvdown 0.0.0.9000

* Created a `spectral_font_dep()` function which returns HTML dependencies for
the Spectral font.

* Created `inst/resources` directory and `pkg_resource()` function for
resources management.

Expand Down
28 changes: 28 additions & 0 deletions R/fonts.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#' HTML dependencies for fonts used by the French government
#'
#' These functions provide common HTML dependencies for re-use by other R
#' Markdown output formats or Shiny applications.
#'
#' @param use_gouvdown_fonts Do you prefer to use `gouvdown.fonts` dependencies?
#'
#' @return An object that can be included in a list of dependencies passed to
#' [attachDependencies][htmltools::attachDependencies()].
#'
#' @export
#' @keywords internal
#'
#' @examples
#' spectral_font_dep()
spectral_font_dep <- function(use_gouvdown_fonts = TRUE) {
if (isTRUE(use_gouvdown_fonts) && xfun::loadable("gouvdown.fonts")) {
dep <- utils::getFromNamespace("html_dependency_spectral", "gouvdown.fonts")
return(dep())
}

htmltools::htmlDependency(
"fontspectral", "v2.000", src = pkg_resource(),
head = paste(readLines(pkg_resource("fonts", "spectral", "links.html")), collapse = "\n")
)
}


Empty file removed inst/resources/.gitignore
Empty file.
3 changes: 0 additions & 3 deletions inst/resources/README.md

This file was deleted.

2 changes: 2 additions & 0 deletions inst/resources/fonts/spectral/links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<link href="https://fonts.googleapis.com/css2?family=Spectral&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Spectral&display=swap" rel="stylesheet">
23 changes: 23 additions & 0 deletions man/spectral_font_dep.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 23722a5

Please sign in to comment.