Просмотр исходного кода

Store whether font is from google fonts in css vars

tags/v0.3.0
Garrick Aden-Buie 6 лет назад
Родитель
Сommit
46643574e3
18 измененных файлов: 143 добавлений и 63 удалений
  1. +8
    -4
      R/ggplot2.R
  2. +5
    -2
      R/style_xaringan.R
  3. +7
    -2
      inst/resources/template.css
  4. +5
    -2
      inst/scripts/style_xaringan_body.R
  5. +9
    -4
      tests/testthat/css/duo-header_bg.css
  6. +9
    -4
      tests/testthat/css/duo.css
  7. +9
    -4
      tests/testthat/css/duo_accent.css
  8. +9
    -4
      tests/testthat/css/duo_accent_inverse.css
  9. +9
    -4
      tests/testthat/css/mono_accent.css
  10. +9
    -4
      tests/testthat/css/mono_accent_inverse.css
  11. +9
    -4
      tests/testthat/css/mono_dark.css
  12. +9
    -4
      tests/testthat/css/mono_light-header_bg.css
  13. +9
    -4
      tests/testthat/css/mono_light.css
  14. +9
    -4
      tests/testthat/css/solarized_dark-header_bg.css
  15. +9
    -4
      tests/testthat/css/solarized_dark.css
  16. +9
    -4
      tests/testthat/css/solarized_light.css
  17. +9
    -4
      tests/testthat/css/xaringan.css
  18. +1
    -1
      tests/testthat/test-themes.R

+ 8
- 4
R/ggplot2.R Просмотреть файл



element_family <- paste0(element, "_font_family") element_family <- paste0(element, "_font_family")
element_google <- paste0(element, "_font_google") element_google <- paste0(element, "_font_google")
element_is_google <- paste0(element, "_font_is_google")
element_url <- paste0(element, "_font_url") element_url <- paste0(element, "_font_url")


family <- xaringanthemer_env[[element_family]] family <- xaringanthemer_env[[element_family]]
is_google_font <- !is.null(xaringanthemer_env[[element_google]]) ||
grepl("fonts.google", xaringanthemer_env[[element_url]], fixed = TRUE)
is_google_font <- xaringanthemer_env[[element_is_google]]
if (is.null(is_google_font)) {
is_google_font <- !is.null(xaringanthemer_env[[element_google]]) ||
grepl("fonts.google", xaringanthemer_env[[element_url]], fixed = TRUE)
}


register_font(family, google = is_google_font, fn = sys.calls()[[max(1, length(sys.calls()) - 1)]]) register_font(family, google = is_google_font, fn = sys.calls()[[max(1, length(sys.calls()) - 1)]])
} }


requires_xaringanthemer_env <- function() { requires_xaringanthemer_env <- function() {
if (!exists("xaringanthemer_env") || is.null(xaringanthemer_env$header_color)) { if (!exists("xaringanthemer_env") || is.null(xaringanthemer_env$header_color)) {
stop("Please call a xaringanthemer theme function first.")
stop("Please call a xaringanthemer theme function first.")
}
} }
}


#' Get the Value of xaringanthemer Style Setting #' Get the Value of xaringanthemer Style Setting
#' #'

+ 5
- 2
R/style_xaringan.R Просмотреть файл

f_args <- names(formals(sys.function())) f_args <- names(formals(sys.function()))
for (var in f_args[grepl("font_family$", f_args)]) { for (var in f_args[grepl("font_family$", f_args)]) {
eval(parse(text = paste0(var, "<-quote_elements_w_spaces(", var, ")"))) eval(parse(text = paste0(var, "<-quote_elements_w_spaces(", var, ")")))
# set an is_google flag default of FALSE that is possibly overwritten later
eval(parse(text = paste0(sub("font_family$", "font_is_google", var), "<-0")))
} }
# Use font_..._google args to overwrite font args # Use font_..._google args to overwrite font args
} }
group <- strsplit(var, "_")[[1]][1] group <- strsplit(var, "_")[[1]][1]
if (group == "text") { if (group == "text") {
text_font_family <- gf$family
text_font_family <- quote_elements_w_spaces(gf$family)
text_font_weight <- gf$weights %||% "normal" text_font_weight <- gf$weights %||% "normal"
text_font_weight <- substr(text_font_weight, 1, regexpr(",", text_font_weight)[1] - 1) text_font_weight <- substr(text_font_weight, 1, regexpr(",", text_font_weight)[1] - 1)
text_font_url <- gf$url text_font_url <- gf$url
} else { } else {
for (thing in c("family", "url")) { for (thing in c("family", "url")) {
eval(parse(text = paste0(group, "_font_", thing, " <- gf$", thing )))
eval(parse(text = paste0(group, "_font_", thing, " <- gf$", quote_elements_w_spaces(thing))))
} }
} }
eval(parse(text = paste0(group, "_font_is_google <- 1")))
} }
extra_font_imports <- if (is.null(extra_fonts)) "" else list2fonts(extra_fonts) extra_font_imports <- if (is.null(extra_fonts)) "" else list2fonts(extra_fonts)

+ 7
- 2
inst/resources/template.css Просмотреть файл



:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: {{body_font_family}};
--text-font-family: {{text_font_family}};
--text-font-is-google: {{text_font_is_google}};
--text-font-family-fallback: {{text_font_family_fallback}};
--text-font-base: {{text_font_base}};
--header-font-family: {{header_font_family}}; --header-font-family: {{header_font_family}};
--header-font-is-google: {{header_font_is_google}};
--code-font-family: {{code_font_family}}; --code-font-family: {{code_font_family}};
--code-font-is-google: {{code_font_is_google}};
--text-font-size: {{text_font_size}}; --text-font-size: {{text_font_size}};
--code-font-size: {{code_font_size}}; --code-font-size: {{code_font_size}};
--code-inline-font-size: {{code_inline_font_size}}; --code-inline-font-size: {{code_inline_font_size}};
} }


body { body {
font-family: var(--body-font-family);
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: {{text_font_weight}}; font-weight: {{text_font_weight}};
color: var(--text-color); color: var(--text-color);
} }

+ 5
- 2
inst/scripts/style_xaringan_body.R Просмотреть файл

f_args <- names(formals(sys.function())) f_args <- names(formals(sys.function()))
for (var in f_args[grepl("font_family$", f_args)]) { for (var in f_args[grepl("font_family$", f_args)]) {
eval(parse(text = paste0(var, "<-quote_elements_w_spaces(", var, ")"))) eval(parse(text = paste0(var, "<-quote_elements_w_spaces(", var, ")")))
# set an is_google flag default of FALSE that is possibly overwritten later
eval(parse(text = paste0(sub("font_family$", "font_is_google", var), "<-0")))
} }


# Use font_..._google args to overwrite font args # Use font_..._google args to overwrite font args
} }
group <- strsplit(var, "_")[[1]][1] group <- strsplit(var, "_")[[1]][1]
if (group == "text") { if (group == "text") {
text_font_family <- gf$family
text_font_family <- quote_elements_w_spaces(gf$family)
text_font_weight <- gf$weights %||% "normal" text_font_weight <- gf$weights %||% "normal"
text_font_weight <- substr(text_font_weight, 1, regexpr(",", text_font_weight)[1] - 1) text_font_weight <- substr(text_font_weight, 1, regexpr(",", text_font_weight)[1] - 1)
text_font_url <- gf$url text_font_url <- gf$url
} else { } else {
for (thing in c("family", "url")) { for (thing in c("family", "url")) {
eval(parse(text = paste0(group, "_font_", thing, " <- gf$", thing )))
eval(parse(text = paste0(group, "_font_", thing, " <- gf$", quote_elements_w_spaces(thing))))
} }
} }
eval(parse(text = paste0(group, "_font_is_google <- 1")))
} }


extra_font_imports <- if (is.null(extra_fonts)) "" else list2fonts(extra_fonts) extra_font_imports <- if (is.null(extra_fonts)) "" else list2fonts(extra_fonts)

+ 9
- 4
tests/testthat/css/duo-header_bg.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/duo.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/duo_accent.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/duo_accent_inverse.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/mono_accent.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/mono_accent_inverse.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/mono_dark.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/mono_light-header_bg.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/mono_light.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/solarized_dark-header_bg.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/solarized_dark.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/solarized_light.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 9
- 4
tests/testthat/css/xaringan.css Просмотреть файл

* Version: a.b.c.d.eeee * Version: a.b.c.d.eeee
* *
* ------------------------------------------------------- */ * ------------------------------------------------------- */
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Noto+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700); @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);




:root { :root {
/* Fonts */ /* Fonts */
--body-font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif;
--text-font-family: 'Noto Serif';
--text-font-is-google: 1;
--text-font-family-fallback: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC';
--text-font-base: serif;
--header-font-family: 'Yanone Kaffeesatz'; --header-font-family: 'Yanone Kaffeesatz';
--header-font-is-google: 0;
--code-font-family: 'Source Code Pro'; --code-font-family: 'Source Code Pro';
--code-font-is-google: 0;
--text-font-size: 20px; --text-font-size: 20px;
--code-font-size: 0.9em; --code-font-size: 0.9em;
--code-inline-font-size: 1em; --code-inline-font-size: 1em;
} }


body { body {
font-family: var(--body-font-family);
font-weight: normal;
font-family: var(--text-font-family), var(--text-font-family-fallback), var(--text-font-base);
font-weight: ;
color: var(--text-color); color: var(--text-color);
} }
h1, h2, h3 { h1, h2, h3 {

+ 1
- 1
tests/testthat/test-themes.R Просмотреть файл



tmpfile <- tempfile() tmpfile <- tempfile()


theme_fun(outfile = tmpfile, ...)
theme_fun(outfile = tmpfile, ..., text_font_google = google_font("Noto Serif"))
theme_css <- readLines(tmpfile) theme_css <- readLines(tmpfile)
# Mask package version in test files # Mask package version in test files
theme_css <- sub("( \\* Version: )[\\d.-]+", "\\1a.b.c.d.eeee", theme_css, perl = TRUE) theme_css <- sub("( \\* Version: )[\\d.-]+", "\\1a.b.c.d.eeee", theme_css, perl = TRUE)

Загрузка…
Отмена
Сохранить