Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change regex to find fonts #268

Merged
merged 4 commits into from
Jan 20, 2021
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
2 changes: 1 addition & 1 deletion R/latex.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
20 changes: 5 additions & 15 deletions tests/test-cran/test-latex.R
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
library(testit)

assert('detect_files() can detect filenames from LaTeX log', {
(length(detect_files("asdf qwer")) == 0)
# 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')

(grepl('^psyr\\[\\.\\]', detect_files("! Font U/psy/m/n/10=psyr at 10.0pt not loadable: Metric (TFM) file not found")))

(grepl('^FandolSong-Regular\\[\\.\\]', detect_files('! The font "FandolSong-Regular" cannot be found.')))

(grepl('^tcrm0700\\[\\.\\]', detect_files('!pdfTeX error: /usr/local/bin/pdflatex (file tcrm0700): Font tcrm0700 at 600 not found')))

(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')
})
8 changes: 8 additions & 0 deletions tests/test-travis/test-tlmgr.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ assert('`tlmgr info` can list the installed packages', {
# only check a few basic packages
(c('xetex', 'luatex', 'graphics') %in% res)
})

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')
})