rstudio / thematic

Theme ggplot2, lattice, and base graphics based on a few simple settings.
https://rstudio.github.io/thematic/
Other
244 stars 10 forks source link

Pattern matching in registering Google fonts #120

Closed yixuan closed 2 years ago

yixuan commented 2 years ago

The current code

font_file <- function(variant) {
  dir(
    cache_dir, full.names = TRUE,
    pattern = paste0(variant, "\\.ttf$")
  )
}

will match both italic.ttf and bolditalic.ttf if variant is "italic", thus passing a length-two vector to systemfonts::register_font() or sysfonts::font_add(). The fix is also simple:

font_file <- function(variant) {
  dir(
    cache_dir, full.names = TRUE,
    pattern = paste0("^", variant, "\\.ttf$")
  )
}
savemark commented 2 years ago

Oh yes, this is likely what causes the follwing warning I get when using thematic_shiny(font = "auto")

Warning in check_font_path(italic, "italic") : 'italic' should be a length-one vector, using the first element