From ae6493dc5a644d1cac20739ef5153f8cf9deb011 Mon Sep 17 00:00:00 2001 From: Noam Ross Date: Fri, 26 Dec 2014 14:11:31 -0800 Subject: [PATCH] Allowing perl-type regexes for font import --- R/font.r | 4 ++-- R/truetype.r | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/R/font.r b/R/font.r index baf64e0..34124dd 100644 --- a/R/font.r +++ b/R/font.r @@ -12,7 +12,7 @@ #' #' @export font_import <- function(paths = NULL, recursive = TRUE, prompt = TRUE, - pattern = NULL) { + pattern = NULL, perl = FALSE) { if (prompt) { resp <- readline("Importing fonts may take a few minutes, depending on the number of fonts and the speed of the system.\nContinue? [y/n] ") @@ -22,7 +22,7 @@ font_import <- function(paths = NULL, recursive = TRUE, prompt = TRUE, } } - ttf_import(paths, recursive, pattern) + ttf_import(paths, recursive, pattern, perl) } diff --git a/R/truetype.r b/R/truetype.r index e1fc853..ae5dc8c 100644 --- a/R/truetype.r +++ b/R/truetype.r @@ -12,7 +12,7 @@ #' #' @importFrom Rttf2pt1 which_ttf2pt1 #' @export -ttf_import <- function(paths = NULL, recursive = TRUE, pattern = NULL) { +ttf_import <- function(paths = NULL, recursive = TRUE, pattern = NULL, perl = FALSE) { if (is.null(paths)) paths <- ttf_find_default_path() @@ -21,7 +21,7 @@ ttf_import <- function(paths = NULL, recursive = TRUE, pattern = NULL) { ignore.case = TRUE)) if (!is.null(pattern)) { - matchfiles <- grepl(pattern, basename(ttfiles)) + matchfiles <- grepl(pattern, basename(ttfiles), perl = perl) ttfiles <- ttfiles[matchfiles] } @@ -56,7 +56,7 @@ ttf_extract <- function(ttfiles) { message("Extracting .afm files from .ttf files...") # This stores information about the fonts - fontdata <- data.frame(fontfile = ttfiles, FontName = "", + fontdata <- data.frame(fontfile = ttfiles, FontName = "", stringsAsFactors = FALSE) outfiles <- file.path(metrics_path(),