Sfoglia il codice sorgente

Don't set `fig.showtext` if it's already set to `FALSE`

Fixes #36
tags/v0.4.0
Garrick Aden-Buie 5 anni fa
parent
commit
ddcbccf55c
3 ha cambiato i file con 15 aggiunte e 7 eliminazioni
  1. +2
    -1
      NEWS.md
  2. +11
    -0
      R/ggplot2.R
  3. +2
    -6
      R/zzz.R

+ 2
- 1
NEWS.md Vedi File

@@ -12,7 +12,8 @@
slide level doesn't result in giant slide numbers (#53).
* xaringanthemer no longer sets the `fig.showtext` chunk option when the
showtext package isn't installed (#56).
showtext package isn't installed and also when `fig.showtext = FALSE`
(thanks @mikedecr #36, #56).
* The style functions gain a `link_decoration` argument to set the
[`text-decoration`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration)

+ 11
- 0
R/ggplot2.R Vedi File

@@ -903,6 +903,17 @@ verify_fig_showtext <- function(fn = "theme_xaringan_base") {
))
}

set_fig_showtext <- function() {
if (!requireNamespace("showtext", quietly = TRUE)) {
return(invisible())
}
curr_fst <- knitr::opts_chunk$get("fig.showtext")
if (!is.null(curr_fst) && identical(curr_fst, FALSE)) {
return(invisible())
}
knitr::opts_chunk$set(fig.showtext = TRUE)
}

requires_xaringanthemer_env <- function(
css_file = NULL,
try_css = TRUE,

+ 2
- 6
R/zzz.R Vedi File

@@ -2,17 +2,13 @@
.onLoad <- function(libname, pkgname, ...) {

if ("knitr" %in% loadedNamespaces()) {
if (requireNamespace("showtext", quietly = TRUE)) {
knitr::opts_chunk$set(fig.showtext = TRUE)
}
set_fig_showtext()
}

setHook(
packageEvent("knitr", "onLoad"),
function(...) {
if (requireNamespace("showtext", quietly = TRUE)) {
knitr::opts_chunk$set(fig.showtext = TRUE)
}
set_fig_showtext()
}
)


Loading…
Annulla
Salva