From ab1816b3b6bc62d594d2e10fd04dc33bf5cb0aa0 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Wed, 11 Dec 2024 09:37:43 -0500 Subject: [PATCH] chore: Add {tools} and {utils} to Suggests --- DESCRIPTION | 2 ++ R/bs-theme-preset-brand.R | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5be8ec01e..46964a7d4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -55,6 +55,8 @@ Suggests: shiny (> 1.8.1), testthat, thematic, + tools, + utils, withr, yaml Config/Needs/deploy: diff --git a/R/bs-theme-preset-brand.R b/R/bs-theme-preset-brand.R index 0a1d4e989..95b51beb0 100644 --- a/R/bs-theme-preset-brand.R +++ b/R/bs-theme-preset-brand.R @@ -260,6 +260,10 @@ brand_font_bunny <- function( style = NULL, display = NULL ) { + if (!is_installed("utils")) { + abort("The {utils} package is required.") + } + weight <- brand_remap_font_weight(weight) %||% seq(100, 900, 100) style <- style %||% c("normal", "italic") @@ -319,6 +323,10 @@ brand_font_bunny <- function( } brand_font_file <- function(family, files, brand_root = getwd()) { + if (!is_installed("tools")) { + abort("The {tools} package is required.") + } + if (!(is.list(files) && length(files) > 0)) { abort( c( @@ -345,7 +353,7 @@ brand_font_file <- function(family, files, brand_root = getwd()) { ) } font_type <- switch( - sub(".+[.]([a-z0-9]+)$", "\\1", tolower(font_path)), + tools::file_ext(tolower(font_path)), # otc = "collection", # ttc = "collection", # eot = "embedded-opentype",