Skip to content

Commit 2c06844

Browse files
committed
feat: Add header_font_family_fallback
Fixes #41
1 parent 8a8ebd5 commit 2c06844

38 files changed

+163
-15
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- .pull-right[] now clears floats just for its immediate sibling
66

7+
- Add `header_font_family_fallback` to control fallback fonts for headings (thanks @mattwarkentin, #41)
8+
79
# xaringanthemer 0.3.0
810

911
* Adds `theme_xaringan()`, a ggplot2 theme that automatically uses the colors

R/style_duo.R

+6
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@
236236
#' `h1, h2, h3` elements. Accepts CSS
237237
#' [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
238238
#' property values.
239+
#' @param header_font_family_fallback Header Font Family Fallback. Defaults to
240+
#' Georgia, serif. Modifies the `h1, h2, h3` elements. The value of this
241+
#' variable is also stored as a CSS variable that can be referenced with
242+
#' `var(--header-font-family-fallback)` in any argument of a style function
243+
#' or in custom CSS.
239244
#' @param header_font_url Header Font URL. Defaults to
240245
#' `xaringanthemer_font_default("header_font_url")`. Modifies the
241246
#' `@import url` elements.
@@ -321,6 +326,7 @@ style_duo <- function(
321326
header_font_google = NULL,
322327
header_font_family = xaringanthemer_font_default("header_font_family"),
323328
header_font_weight = xaringanthemer_font_default("header_font_weight"),
329+
header_font_family_fallback = "Georgia, serif",
324330
header_font_url = xaringanthemer_font_default("header_font_url"),
325331
code_font_google = NULL,
326332
code_font_family = xaringanthemer_font_default("code_font_family"),

R/style_duo_accent.R

+6
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@
248248
#' `h1, h2, h3` elements. Accepts CSS
249249
#' [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
250250
#' property values.
251+
#' @param header_font_family_fallback Header Font Family Fallback. Defaults to
252+
#' Georgia, serif. Modifies the `h1, h2, h3` elements. The value of this
253+
#' variable is also stored as a CSS variable that can be referenced with
254+
#' `var(--header-font-family-fallback)` in any argument of a style function
255+
#' or in custom CSS.
251256
#' @param header_font_url Header Font URL. Defaults to
252257
#' `xaringanthemer_font_default("header_font_url")`. Modifies the
253258
#' `@import url` elements.
@@ -335,6 +340,7 @@ style_duo_accent <- function(
335340
header_font_google = NULL,
336341
header_font_family = xaringanthemer_font_default("header_font_family"),
337342
header_font_weight = xaringanthemer_font_default("header_font_weight"),
343+
header_font_family_fallback = "Georgia, serif",
338344
header_font_url = xaringanthemer_font_default("header_font_url"),
339345
code_font_google = NULL,
340346
code_font_family = xaringanthemer_font_default("code_font_family"),

R/style_duo_accent_inverse.R

+6
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@
249249
#' `h1, h2, h3` elements. Accepts CSS
250250
#' [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
251251
#' property values.
252+
#' @param header_font_family_fallback Header Font Family Fallback. Defaults to
253+
#' Georgia, serif. Modifies the `h1, h2, h3` elements. The value of this
254+
#' variable is also stored as a CSS variable that can be referenced with
255+
#' `var(--header-font-family-fallback)` in any argument of a style function
256+
#' or in custom CSS.
252257
#' @param header_font_url Header Font URL. Defaults to
253258
#' `xaringanthemer_font_default("header_font_url")`. Modifies the
254259
#' `@import url` elements.
@@ -336,6 +341,7 @@ style_duo_accent_inverse <- function(
336341
header_font_google = NULL,
337342
header_font_family = xaringanthemer_font_default("header_font_family"),
338343
header_font_weight = xaringanthemer_font_default("header_font_weight"),
344+
header_font_family_fallback = "Georgia, serif",
339345
header_font_url = xaringanthemer_font_default("header_font_url"),
340346
code_font_google = NULL,
341347
code_font_family = xaringanthemer_font_default("code_font_family"),

R/style_mono_accent.R

+6
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@
239239
#' `h1, h2, h3` elements. Accepts CSS
240240
#' [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
241241
#' property values.
242+
#' @param header_font_family_fallback Header Font Family Fallback. Defaults to
243+
#' Georgia, serif. Modifies the `h1, h2, h3` elements. The value of this
244+
#' variable is also stored as a CSS variable that can be referenced with
245+
#' `var(--header-font-family-fallback)` in any argument of a style function
246+
#' or in custom CSS.
242247
#' @param header_font_url Header Font URL. Defaults to
243248
#' `xaringanthemer_font_default("header_font_url")`. Modifies the
244249
#' `@import url` elements.
@@ -325,6 +330,7 @@ style_mono_accent <- function(
325330
header_font_google = NULL,
326331
header_font_family = xaringanthemer_font_default("header_font_family"),
327332
header_font_weight = xaringanthemer_font_default("header_font_weight"),
333+
header_font_family_fallback = "Georgia, serif",
328334
header_font_url = xaringanthemer_font_default("header_font_url"),
329335
code_font_google = NULL,
330336
code_font_family = xaringanthemer_font_default("code_font_family"),

R/style_mono_accent_inverse.R

+6
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@
240240
#' `h1, h2, h3` elements. Accepts CSS
241241
#' [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
242242
#' property values.
243+
#' @param header_font_family_fallback Header Font Family Fallback. Defaults to
244+
#' Georgia, serif. Modifies the `h1, h2, h3` elements. The value of this
245+
#' variable is also stored as a CSS variable that can be referenced with
246+
#' `var(--header-font-family-fallback)` in any argument of a style function
247+
#' or in custom CSS.
243248
#' @param header_font_url Header Font URL. Defaults to
244249
#' `xaringanthemer_font_default("header_font_url")`. Modifies the
245250
#' `@import url` elements.
@@ -326,6 +331,7 @@ style_mono_accent_inverse <- function(
326331
header_font_google = NULL,
327332
header_font_family = xaringanthemer_font_default("header_font_family"),
328333
header_font_weight = xaringanthemer_font_default("header_font_weight"),
334+
header_font_family_fallback = "Georgia, serif",
329335
header_font_url = xaringanthemer_font_default("header_font_url"),
330336
code_font_google = NULL,
331337
code_font_family = xaringanthemer_font_default("code_font_family"),

R/style_mono_dark.R

+6
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@
241241
#' `h1, h2, h3` elements. Accepts CSS
242242
#' [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
243243
#' property values.
244+
#' @param header_font_family_fallback Header Font Family Fallback. Defaults to
245+
#' Georgia, serif. Modifies the `h1, h2, h3` elements. The value of this
246+
#' variable is also stored as a CSS variable that can be referenced with
247+
#' `var(--header-font-family-fallback)` in any argument of a style function
248+
#' or in custom CSS.
244249
#' @param header_font_url Header Font URL. Defaults to
245250
#' `xaringanthemer_font_default("header_font_url")`. Modifies the
246251
#' `@import url` elements.
@@ -327,6 +332,7 @@ style_mono_dark <- function(
327332
header_font_google = NULL,
328333
header_font_family = xaringanthemer_font_default("header_font_family"),
329334
header_font_weight = xaringanthemer_font_default("header_font_weight"),
335+
header_font_family_fallback = "Georgia, serif",
330336
header_font_url = xaringanthemer_font_default("header_font_url"),
331337
code_font_google = NULL,
332338
code_font_family = xaringanthemer_font_default("code_font_family"),

R/style_mono_light.R

+6
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@
241241
#' `h1, h2, h3` elements. Accepts CSS
242242
#' [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
243243
#' property values.
244+
#' @param header_font_family_fallback Header Font Family Fallback. Defaults to
245+
#' Georgia, serif. Modifies the `h1, h2, h3` elements. The value of this
246+
#' variable is also stored as a CSS variable that can be referenced with
247+
#' `var(--header-font-family-fallback)` in any argument of a style function
248+
#' or in custom CSS.
244249
#' @param header_font_url Header Font URL. Defaults to
245250
#' `xaringanthemer_font_default("header_font_url")`. Modifies the
246251
#' `@import url` elements.
@@ -327,6 +332,7 @@ style_mono_light <- function(
327332
header_font_google = NULL,
328333
header_font_family = xaringanthemer_font_default("header_font_family"),
329334
header_font_weight = xaringanthemer_font_default("header_font_weight"),
335+
header_font_family_fallback = "Georgia, serif",
330336
header_font_url = xaringanthemer_font_default("header_font_url"),
331337
code_font_google = NULL,
332338
code_font_family = xaringanthemer_font_default("code_font_family"),

R/style_solarized_dark.R

+6
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@
226226
#' `h1, h2, h3` elements. Accepts CSS
227227
#' [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
228228
#' property values.
229+
#' @param header_font_family_fallback Header Font Family Fallback. Defaults to
230+
#' Georgia, serif. Modifies the `h1, h2, h3` elements. The value of this
231+
#' variable is also stored as a CSS variable that can be referenced with
232+
#' `var(--header-font-family-fallback)` in any argument of a style function
233+
#' or in custom CSS.
229234
#' @param header_font_url Header Font URL. Defaults to
230235
#' `xaringanthemer_font_default("header_font_url")`. Modifies the
231236
#' `@import url` elements.
@@ -309,6 +314,7 @@ style_solarized_dark <- function(
309314
header_font_google = NULL,
310315
header_font_family = xaringanthemer_font_default("header_font_family"),
311316
header_font_weight = xaringanthemer_font_default("header_font_weight"),
317+
header_font_family_fallback = "Georgia, serif",
312318
header_font_url = xaringanthemer_font_default("header_font_url"),
313319
code_font_google = NULL,
314320
code_font_family = xaringanthemer_font_default("code_font_family"),

R/style_solarized_light.R

+6
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@
226226
#' `h1, h2, h3` elements. Accepts CSS
227227
#' [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
228228
#' property values.
229+
#' @param header_font_family_fallback Header Font Family Fallback. Defaults to
230+
#' Georgia, serif. Modifies the `h1, h2, h3` elements. The value of this
231+
#' variable is also stored as a CSS variable that can be referenced with
232+
#' `var(--header-font-family-fallback)` in any argument of a style function
233+
#' or in custom CSS.
229234
#' @param header_font_url Header Font URL. Defaults to
230235
#' `xaringanthemer_font_default("header_font_url")`. Modifies the
231236
#' `@import url` elements.
@@ -309,6 +314,7 @@ style_solarized_light <- function(
309314
header_font_google = NULL,
310315
header_font_family = xaringanthemer_font_default("header_font_family"),
311316
header_font_weight = xaringanthemer_font_default("header_font_weight"),
317+
header_font_family_fallback = "Georgia, serif",
312318
header_font_url = xaringanthemer_font_default("header_font_url"),
313319
code_font_google = NULL,
314320
code_font_family = xaringanthemer_font_default("code_font_family"),

R/style_xaringan.R

+6
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@
226226
#' `h1, h2, h3` elements. Accepts CSS
227227
#' [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
228228
#' property values.
229+
#' @param header_font_family_fallback Header Font Family Fallback. Defaults to
230+
#' Georgia, serif. Modifies the `h1, h2, h3` elements. The value of this
231+
#' variable is also stored as a CSS variable that can be referenced with
232+
#' `var(--header-font-family-fallback)` in any argument of a style function
233+
#' or in custom CSS.
229234
#' @param header_font_url Header Font URL. Defaults to
230235
#' `xaringanthemer_font_default("header_font_url")`. Modifies the
231236
#' `@import url` elements.
@@ -308,6 +313,7 @@ style_xaringan <- function(
308313
header_font_google = NULL,
309314
header_font_family = xaringanthemer_font_default("header_font_family"),
310315
header_font_weight = xaringanthemer_font_default("header_font_weight"),
316+
header_font_family_fallback = "Georgia, serif",
311317
header_font_url = xaringanthemer_font_default("header_font_url"),
312318
code_font_google = NULL,
313319
code_font_family = xaringanthemer_font_default("code_font_family"),

R/sysdata.rda

43 Bytes
Binary file not shown.

data-raw/theme_template_variables.R

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ template_variables <- tibble::tribble(
5555
, "header_font_google", "{NULL}", "body", "Use `google_font()` to specify header font", NA_character_
5656
, "header_font_family", '{xaringanthemer_font_default("header_font_family")}', "h1, h2, h3", "Header Font Family (xaringan default is `'Yanone Kaffeesatz'`)", "--header-font-family"
5757
, "header_font_weight", '{xaringanthemer_font_default("header_font_weight")}', "h1, h2, h3", "Header Font Weight", NA_character_
58+
, "header_font_family_fallback", 'Georgia, serif', "h1, h2, h3", "Header Font Family Fallback", "--header-font-family-fallback"
5859
, "header_font_url", '{xaringanthemer_font_default("header_font_url")}', "@import url", "Header Font URL", NA_character_
5960
, "code_font_google", "{NULL}", "body", "Use `google_font()` to specify code font", NA_character_
6061
, "code_font_family", '{xaringanthemer_font_default("code_font_family")}', ".remark-code, .remark-inline-code", "Code Font Family", "--code-font-family"

inst/resources/template.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
--text-font-base: {{text_font_base}};
3232
--header-font-family: {{header_font_family}};
3333
--header-font-is-google: {{header_font_is_google}};
34+
--header-font-family-fallback: {{header_font_family_fallback}};
3435
--code-font-family: {{code_font_family}};
3536
--code-font-is-google: {{code_font_is_google}};
3637
--base-font-size: {{base_font_size}};
@@ -69,7 +70,7 @@ body {
6970
color: var(--text-color);
7071
}
7172
h1, h2, h3 {
72-
font-family: var(--header-font-family);
73+
font-family: var(--header-font-family), var(--header-font-family-fallback);
7374
font-weight: {{header_font_weight}};
7475
color: var(--header-color);
7576
}

man/style_duo.Rd

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/style_duo_accent.Rd

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/style_duo_accent_inverse.Rd

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/style_mono_accent.Rd

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/style_mono_accent_inverse.Rd

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/style_mono_dark.Rd

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)