diff --git a/DESCRIPTION b/DESCRIPTION index 51f73b0..a555926 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,8 +24,7 @@ Imports: scales, ggtext, ggrepel, - systemfonts, - extrafont + systemfonts Suggests: rmarkdown, knitr, diff --git a/NAMESPACE b/NAMESPACE index 6021ef6..824fc33 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,7 +4,6 @@ export(display_unhcr_all) export(display_unhcr_pal) export(import_lato) export(lato_installed) -export(lato_registered) export(scale_color_unhcr_b) export(scale_color_unhcr_c) export(scale_color_unhcr_d) @@ -17,8 +16,6 @@ export(scale_fill_unhcr_d) export(theme_unhcr) export(unhcr_pal) import(ggplot2) -importFrom(extrafont,font_import) -importFrom(extrafont,fonts) importFrom(ggplot2,continuous_scale) importFrom(ggplot2,discrete_scale) importFrom(ggplot2,update_geom_defaults) diff --git a/NEWS.md b/NEWS.md index cdfeb9e..25852c5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,16 @@ # unhcrthemes (development version) +## Breaking changes + +- Removed the dependency on `{extrafont}`, as its dependency `{Rttf2pt1}` is scheduled for removal from CRAN. +- The function `lato_registered()`, which verified if Lato was registered through `{extrafont}`, has been **removed**. +- The function `import_lato()` now only imports Lato via `{systemfonts}`. + +## Notes + +- This change does **not** affect the use of `{unhcrthemes}` in general workflows. +- However, it limits the possibility to create PDFs with the official Lato font **embedded**. Users can still rely on system-installed fonts for consistent rendering. + # unhcrthemes 0.7.0 ## Updates aligned with 2025 UNHCR Data Visualization Guidelines diff --git a/R/lato.R b/R/lato.R index 6f3e75d..170ebcd 100644 --- a/R/lato.R +++ b/R/lato.R @@ -11,34 +11,18 @@ lato_installed <- function() { any(grepl("lato", sys_fonts$family, ignore.case = TRUE)) } -#' Check if Lato font is registered through \code{extrafont} -#' -#' Verify if Lato is registered through \code{extrafont} -#' -#' @importFrom systemfonts system_fonts -#' @importFrom extrafont fonts -#' -#' @returns TRUE if Lato is registered -#' @export -lato_registered <- function() { - any(grepl("lato", extrafont::fonts(), ignore.case = TRUE)) -} - #' Import Lato font #' #' Import Lato font for use in R graphic devices #' #' @importFrom systemfonts register_font -#' @importFrom extrafont font_import #' #' @return No return value, called for side effects #' @export import_lato <- function() { if (!lato_installed()) { - font_dir <- system.file("fonts", "Lato", - package = "unhcrthemes" - ) - register_font( + font_dir <- system.file("fonts", "Lato", package = "unhcrthemes") + systemfonts::register_font( name = "Lato", plain = file.path(font_dir, "Lato-Regular.ttf"), italic = file.path(font_dir, "Lato-Italic.ttf"), @@ -48,23 +32,6 @@ import_lato <- function() { "Lato-BoldItalic.ttf" ) ) - pattern <- "(?i)lato-(regular|bold|italic|bolditalic)" - suppressMessages(extrafont::font_import(font_dir, - pattern = pattern, - prompt = FALSE - )) - suppressMessages(extrafont::loadfonts()) - } else { - font_dir <- systemfonts::system_fonts() - b <- grepl("lato", font_dir$family, ignore.case = TRUE) - font_dir <- font_dir[b, ] - font_dir <- unique(dirname(font_dir$path)) - pattern <- "(?i)lato-(regular|bold|italic|bolditalic)" - suppressMessages(extrafont::font_import(font_dir, - pattern = pattern, - prompt = FALSE - )) - suppressMessages(extrafont::loadfonts()) } update_geom_font_defaults() } diff --git a/man/lato_registered.Rd b/man/lato_registered.Rd deleted file mode 100644 index 1c3af78..0000000 --- a/man/lato_registered.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/lato.R -\name{lato_registered} -\alias{lato_registered} -\title{Check if Lato font is registered through \code{extrafont}} -\usage{ -lato_registered() -} -\value{ -TRUE if Lato is registered -} -\description{ -Verify if Lato is registered through \code{extrafont} -}