소스 검색

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

Fixes #36
tags/v0.4.0
Garrick Aden-Buie 5 년 전
부모
커밋
ddcbccf55c
3개의 변경된 파일15개의 추가작업 그리고 7개의 파일을 삭제
  1. +2
    -1
      NEWS.md
  2. +11
    -0
      R/ggplot2.R
  3. +2
    -6
      R/zzz.R

+ 2
- 1
NEWS.md 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

@@ -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…
취소
저장