Open schloerke opened 1 year ago
@schloerke those font files include all of the fonts downloaded for the Bootswatch presets provided by bslib, so you definitely don't want all of them. It looks like you're on the right path of finding the fonts needed for preset = "shiny"
and copying only those.
I don't mind trimming the set of font files myself, but it feels like {bslib}
should only provide the usable set of fonts... not all fonts bslib knows about.
but it feels like
{bslib}
should only provide the usable set of fonts... not all fonts bslib knows about.
I'm not sure I follow and my confusion probably rests on what you mean by provide.
Within the package, bslib bundles the fonts used by Bootstrap or Bootswatch. We store all of the fonts in one location and provide that collection of fonts by making them available in the bs_theme()
dependency. AFAICT, we don't inline those fonts or bundle them into Bootstrap, but they're made available upon request. In that sense we provide all of the fonts bslib knows about, but this is a local server-side copy and not something we need to optimize. Only the requested fonts are sent to the client.
If you invert the question and find where the fonts are used, many fonts are used in more than one file.
fonts <-
fs::path_package("bslib", "fonts") |>
fs::dir_ls(glob = "*.woff") |>
fs::path_file()
fonts[1:3]
#> [1] "1Ptxg8zYS_SKggPN4iEgvnHyvveLxVs9pbCIPrc.woff"
#> [2] "1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCIPrc.woff"
#> [3] "1adeadb2fe618c5ed46221f15e12b9c8.woff"
files <- vector("list", length(fonts))
names(files) <- fonts
for (font in fonts) {
files[[font]] <- processx::run(
"grep",
args = c("-rl", font, fs::path_package("bslib"))
)
# grepl -l returns the file name where a match is found
files[[font]] <- strsplit(files[[font]]$stdout, "\n")[[1]]
}
font_used_in_file_count <- vapply(files, length, integer(1))
sum(font_used_in_file_count)
#> [1] 169
all(font_used_in_file_count > 0)
#> [1] TRUE
Describe the problem
When saving the dependencies for the shiny preset theme, 70x
.woff
files are saved. But only 16x.woff
links exist infont.css
I'm ok if they're all used, but it seems excessive for the amount of links inside the
font.css
file.Reprex of behavior:
Session Info