From d9f781561857c5fc3d6db6c5fc07d180db69e16d Mon Sep 17 00:00:00 2001 From: christophe dervieux Date: Mon, 18 Jan 2021 19:01:44 +0100 Subject: [PATCH 1/4] change regex to find font --- R/latex.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/latex.R b/R/latex.R index cdc44b785..ffdc4e9d0 100644 --- a/R/latex.R +++ b/R/latex.R @@ -568,7 +568,7 @@ miss_font = function() { font_ext = function(x) { i = !grepl('[.]', x) - x[i] = paste0(x[i], '[.](tfm|afm|mf|otf)') + x[i] = paste0(x[i], '(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)') x } From decfcb841ba917a8608a41b919a78417c61f02b9 Mon Sep 17 00:00:00 2001 From: christophe dervieux Date: Mon, 18 Jan 2021 19:02:14 +0100 Subject: [PATCH 2/4] Modify test about detect_files --- tests/test-cran/test-latex.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test-cran/test-latex.R b/tests/test-cran/test-latex.R index 2c74dbb63..c350d0cd0 100644 --- a/tests/test-cran/test-latex.R +++ b/tests/test-cran/test-latex.R @@ -7,11 +7,11 @@ assert('detect_files() can detect filenames from LaTeX log', { (detect_files("/usr/local/bin/mktexpk: line 123: mf: command not found") %==% 'mf') - (grepl('^psyr\\[\\.\\]', detect_files("! Font U/psy/m/n/10=psyr at 10.0pt not loadable: Metric (TFM) file not found"))) + (detect_files("! Font U/psy/m/n/10=psyr at 10.0pt not loadable: Metric (TFM) file not found") %==% font_ext("psyr")) - (grepl('^FandolSong-Regular\\[\\.\\]', detect_files('! The font "FandolSong-Regular" cannot be found.'))) + (detect_files('! The font "FandolSong-Regular" cannot be found.') %==% font_ext("FandolSong-Regular")) - (grepl('^tcrm0700\\[\\.\\]', detect_files('!pdfTeX error: /usr/local/bin/pdflatex (file tcrm0700): Font tcrm0700 at 600 not found'))) + (detect_files('!pdfTeX error: /usr/local/bin/pdflatex (file tcrm0700): Font tcrm0700 at 600 not found') %==% font_ext('tcrm0700')) (detect_files("or the language definition file ngerman.ldf was not found") %==% 'ngerman.ldf') From 0335b635959aaaa8e9143aaec1d6ff84aad844fb Mon Sep 17 00:00:00 2001 From: christophe dervieux Date: Mon, 18 Jan 2021 19:05:30 +0100 Subject: [PATCH 3/4] add test with tlmgr to check the font is correctly found in a package --- tests/test-travis/test-tlmgr.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test-travis/test-tlmgr.R b/tests/test-travis/test-tlmgr.R index 6dadd1a32..0b729d63f 100644 --- a/tests/test-travis/test-tlmgr.R +++ b/tests/test-travis/test-tlmgr.R @@ -16,3 +16,10 @@ assert('`tlmgr info` can list the installed packages', { # only check a few basic packages (c('xetex', 'luatex', 'graphics') %in% res) }) + +suppressMessages( + assert('fonts package are correctly identified', { + parse_packages(text = "! Font U/psy/m/n/10=psyr at 10.0pt not loadable: Metric (TFM) file not found") %==% "symbol" + parse_packages(text = '! Package fontspec Error: The font "Caladea" cannot be found.') %==% 'caladea' + }) +) From b6d162dfdd934fa919b172b78327450ee2edb18e Mon Sep 17 00:00:00 2001 From: christophe dervieux Date: Mon, 18 Jan 2021 19:16:32 +0100 Subject: [PATCH 4/4] Add tests to check the fonts is indeed found in the online database --- tests/test-cran/test-latex.R | 18 ++++-------------- tests/test-travis/test-tlmgr.R | 13 +++++++------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/tests/test-cran/test-latex.R b/tests/test-cran/test-latex.R index c350d0cd0..25babd865 100644 --- a/tests/test-cran/test-latex.R +++ b/tests/test-cran/test-latex.R @@ -1,29 +1,19 @@ library(testit) assert('detect_files() can detect filenames from LaTeX log', { - (length(detect_files("asdf qwer")) == 0) - - (detect_files("! LaTeX Error: File `framed.sty' not found.") %==% 'framed.sty') - - (detect_files("/usr/local/bin/mktexpk: line 123: mf: command not found") %==% 'mf') - + # Fonts are tested in test-tlmgr.R also (detect_files("! Font U/psy/m/n/10=psyr at 10.0pt not loadable: Metric (TFM) file not found") %==% font_ext("psyr")) - (detect_files('! The font "FandolSong-Regular" cannot be found.') %==% font_ext("FandolSong-Regular")) - (detect_files('!pdfTeX error: /usr/local/bin/pdflatex (file tcrm0700): Font tcrm0700 at 600 not found') %==% font_ext('tcrm0700')) + (length(detect_files("asdf qwer")) == 0) + (detect_files("! LaTeX Error: File `framed.sty' not found.") %==% 'framed.sty') + (detect_files("/usr/local/bin/mktexpk: line 123: mf: command not found") %==% 'mf') (detect_files("or the language definition file ngerman.ldf was not found") %==% 'ngerman.ldf') - (detect_files("!pdfTeX error: pdflatex (file 8r.enc): cannot open encoding file for reading") %==% '8r.enc') - (detect_files("! CTeX fontset `fandol' is unavailable in current mode") %==% 'fandol') - (detect_files('Package widetext error: Install the flushend package which is a part of sttools') %==% 'flushend.sty') - (detect_files('! Package isodate.sty Error: Package file substr.sty not found.') %==% 'substr.sty') - (detect_files("! Package fontenc Error: Encoding file `t2aenc.def' not found.") %==% 't2aenc.def') - (detect_files("! I can't find file `hyph-de-1901.ec.tex'.") %==% 'hyph-de-1901.ec.tex') }) diff --git a/tests/test-travis/test-tlmgr.R b/tests/test-travis/test-tlmgr.R index 0b729d63f..83db74d55 100644 --- a/tests/test-travis/test-tlmgr.R +++ b/tests/test-travis/test-tlmgr.R @@ -17,9 +17,10 @@ assert('`tlmgr info` can list the installed packages', { (c('xetex', 'luatex', 'graphics') %in% res) }) -suppressMessages( - assert('fonts package are correctly identified', { - parse_packages(text = "! Font U/psy/m/n/10=psyr at 10.0pt not loadable: Metric (TFM) file not found") %==% "symbol" - parse_packages(text = '! Package fontspec Error: The font "Caladea" cannot be found.') %==% 'caladea' - }) -) +assert('fonts package are correctly identified', { + p_q <- function(...) parse_packages(..., quiet = c(TRUE, TRUE, TRUE)) + (p_q(text = "! Font U/psy/m/n/10=psyr at 10.0pt not loadable: Metric (TFM) file not found") %==% 'symbol') + (p_q(text = '! The font "FandolSong-Regular" cannot be found.') %==% 'fandol') + (p_q(text = '!pdfTeX error: /usr/local/bin/pdflatex (file tcrm0700): Font tcrm0700 at 600 not found') %==% 'ec') + (p_q(text = '! Package fontspec Error: The font "Caladea" cannot be found.') %==% 'caladea') +})