| @@ -208,14 +208,16 @@ theme_xaringan_inverse <- function( | |||
| #' defaults, see [theme_xaringan_restore_defaults()]. | |||
| #' @param text_font Font to use for text elements, passed to | |||
| #' [sysfonts::font_add_google()], if available and `text_font_use_google` is | |||
| #' `TRUE`. Inherits from `text_font_family`. | |||
| #' `TRUE`. Inherits from `text_font_family`. If manually specified, can be a | |||
| #' [google_font()]. | |||
| #' @param text_font_use_google Is `text_font` available on [Google | |||
| #' Fonts](https://fonts.google.com)? | |||
| #' @param text_font_size Base text font size, inherits from `text_font_size`, or | |||
| #' defaults to 11. | |||
| #' @param title_font Font to use for title elements, passed to | |||
| #' [sysfonts::font_add_google()], if available and `title_font_use_google` is | |||
| #' `TRUE`. Inherits from `title_font_family`. | |||
| #' `TRUE`. Inherits from `title_font_family`. If manually specified, can be a | |||
| #' [google_font()]. | |||
| #' @param title_font_use_google Is `title_font` available on [Google | |||
| #' Fonts](https://fonts.google.com)? | |||
| #' @param title_font_size Base text font size, inherits from `title_font_size`, | |||
| @@ -297,6 +299,9 @@ theme_xaringan_base <- function( | |||
| text_font_size <- text_font_size %||% web_to_point(xaringanthemer_env$text_font_size, scale = 1.25) %||% 11 | |||
| title_font_size <- title_font_size %||% web_to_point(xaringanthemer_env$header_h3_font_size, scale = 0.8) %||% 14 | |||
| text_font_use_google <- text_font_use_google %||% is_google_font(text_font) | |||
| title_font_use_google <- title_font_use_google %||% is_google_font(title_font) | |||
| text_font <- if (!is.null(text_font)) { | |||
| register_font(text_font, identical(text_font_use_google, TRUE) && use_showtext) | |||
| } else { | |||
| @@ -382,6 +387,9 @@ theme_xaringan_base <- function( | |||
| #' [theme_xaringan_inverse()]. | |||
| #' | |||
| #' @family xaringanthemer ggplot2 themes | |||
| #' @param text_font Font to use for text elements, passed to | |||
| #' [sysfonts::font_add_google()], if available and `text_font_use_google` is | |||
| #' `TRUE`. Inherits from `text_font_family`. Must be a length-one character. | |||
| #' @inheritParams theme_xaringan | |||
| #' @inheritParams theme_xaringan_base | |||
| #' @return Invisibly returns a list of the current ggplot2 geom defaults | |||
| @@ -394,6 +402,7 @@ theme_xaringan_set_defaults <- function( | |||
| text_font = NULL | |||
| ) { | |||
| requires_package("ggplot2") | |||
| text_font %||% stopifnot(is.character(text_font) && length(text_font) == 1) | |||
| blend <- color_blender(text_color, background_color) | |||
| @@ -789,6 +798,7 @@ register_font <- function( | |||
| if (is.null(family) || !use_showtext) { | |||
| return(NULL) | |||
| } | |||
| if (is_google_font(family)) family <- family$family | |||
| family <- gsub("['\"]", "", family) | |||
| if (!identical(xaringanthemer_env$showtext_auto, TRUE)) { | |||
| @@ -63,6 +63,8 @@ google_font <- function(family, ..., languages = NULL) { | |||
| ) | |||
| } | |||
| is_google_font <- function(x) inherits(x, "google_font") | |||
| #' @title List Valid Google Language Codes | |||
| #' @description Gives a list of valid Language Codes for Google Fonts, or | |||
| #' validates that the language codes given are valid. | |||
| @@ -45,7 +45,8 @@ defaults, see \code{\link[=theme_xaringan_restore_defaults]{theme_xaringan_resto | |||
| \item{text_font}{Font to use for text elements, passed to | |||
| \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{text_font_use_google} is | |||
| \code{TRUE}. Inherits from \code{text_font_family}.} | |||
| \code{TRUE}. Inherits from \code{text_font_family}. If manually specified, can be a | |||
| \code{\link[=google_font]{google_font()}}.} | |||
| \item{text_font_use_google}{Is \code{text_font} available on \href{https://fonts.google.com}{Google Fonts}?} | |||
| @@ -54,7 +55,8 @@ defaults to 11.} | |||
| \item{title_font}{Font to use for title elements, passed to | |||
| \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{title_font_use_google} is | |||
| \code{TRUE}. Inherits from \code{title_font_family}.} | |||
| \code{TRUE}. Inherits from \code{title_font_family}. If manually specified, can be a | |||
| \code{\link[=google_font]{google_font()}}.} | |||
| \item{title_font_use_google}{Is \code{title_font} available on \href{https://fonts.google.com}{Google Fonts}?} | |||
| @@ -42,7 +42,8 @@ defaults.} | |||
| \item{text_font}{Font to use for text elements, passed to | |||
| \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{text_font_use_google} is | |||
| \code{TRUE}. Inherits from \code{text_font_family}.} | |||
| \code{TRUE}. Inherits from \code{text_font_family}. If manually specified, can be a | |||
| \code{\link[=google_font]{google_font()}}.} | |||
| \item{text_font_use_google}{Is \code{text_font} available on \href{https://fonts.google.com}{Google Fonts}?} | |||
| @@ -51,7 +52,8 @@ defaults to 11.} | |||
| \item{title_font}{Font to use for title elements, passed to | |||
| \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{title_font_use_google} is | |||
| \code{TRUE}. Inherits from \code{title_font_family}.} | |||
| \code{TRUE}. Inherits from \code{title_font_family}. If manually specified, can be a | |||
| \code{\link[=google_font]{google_font()}}.} | |||
| \item{title_font_use_google}{Is \code{title_font} available on \href{https://fonts.google.com}{Google Fonts}?} | |||
| @@ -45,7 +45,8 @@ defaults, see \code{\link[=theme_xaringan_restore_defaults]{theme_xaringan_resto | |||
| \item{text_font}{Font to use for text elements, passed to | |||
| \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{text_font_use_google} is | |||
| \code{TRUE}. Inherits from \code{text_font_family}.} | |||
| \code{TRUE}. Inherits from \code{text_font_family}. If manually specified, can be a | |||
| \code{\link[=google_font]{google_font()}}.} | |||
| \item{text_font_use_google}{Is \code{text_font} available on \href{https://fonts.google.com}{Google Fonts}?} | |||
| @@ -54,7 +55,8 @@ defaults to 11.} | |||
| \item{title_font}{Font to use for title elements, passed to | |||
| \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{title_font_use_google} is | |||
| \code{TRUE}. Inherits from \code{title_font_family}.} | |||
| \code{TRUE}. Inherits from \code{title_font_family}. If manually specified, can be a | |||
| \code{\link[=google_font]{google_font()}}.} | |||
| \item{title_font_use_google}{Is \code{title_font} available on \href{https://fonts.google.com}{Google Fonts}?} | |||
| @@ -29,7 +29,7 @@ theme_xaringan_restore_defaults() | |||
| \item{text_font}{Font to use for text elements, passed to | |||
| \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{text_font_use_google} is | |||
| \code{TRUE}. Inherits from \code{text_font_family}.} | |||
| \code{TRUE}. Inherits from \code{text_font_family}. Must be a length-one character.} | |||
| } | |||
| \value{ | |||
| Invisibly returns a list of the current ggplot2 geom defaults | |||