Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ Imports:
scales,
ggtext,
ggrepel,
systemfonts,
extrafont
systemfonts
Suggests:
rmarkdown,
knitr,
Expand Down
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
37 changes: 2 additions & 35 deletions R/lato.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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()
}
14 changes: 0 additions & 14 deletions man/lato_registered.Rd

This file was deleted.

Loading