-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathlato.R
More file actions
37 lines (36 loc) · 1003 Bytes
/
lato.R
File metadata and controls
37 lines (36 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#' Check if Lato font is installed in the system
#'
#' Verify if you have Lato font installed in your system
#'
#' @importFrom systemfonts system_fonts
#'
#' @returns TRUE if Lato is installed in the system
#' @export
lato_installed <- function() {
sys_fonts <- systemfonts::system_fonts()
any(grepl("lato", sys_fonts$family, ignore.case = TRUE))
}
#' Import Lato font
#'
#' Import Lato font for use in R graphic devices
#'
#' @importFrom systemfonts register_font
#'
#' @return No return value, called for side effects
#' @export
import_lato <- function() {
if (!lato_installed()) {
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"),
bold = file.path(font_dir, "Lato-Bold.ttf"),
bolditalic = file.path(
font_dir,
"Lato-BoldItalic.ttf"
)
)
}
update_geom_font_defaults()
}