Skip to content

Commit 1fd3334

Browse files
authored
fix #267: change regex to find fonts, e.g., for the font name 'Caladea', we should also try to find Caladea-(Bold|Italic|Regular) (#268)
1 parent 6c0078f commit 1fd3334

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

R/latex.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ miss_font = function() {
568568

569569
font_ext = function(x) {
570570
i = !grepl('[.]', x)
571-
x[i] = paste0(x[i], '[.](tfm|afm|mf|otf)')
571+
x[i] = paste0(x[i], '(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)')
572572
x
573573
}
574574

tests/test-cran/test-latex.R

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
11
library(testit)
22

33
assert('detect_files() can detect filenames from LaTeX log', {
4-
(length(detect_files("asdf qwer")) == 0)
4+
# Fonts are tested in test-tlmgr.R also
5+
(detect_files("! Font U/psy/m/n/10=psyr at 10.0pt not loadable: Metric (TFM) file not found") %==% font_ext("psyr"))
6+
(detect_files('! The font "FandolSong-Regular" cannot be found.') %==% font_ext("FandolSong-Regular"))
7+
(detect_files('!pdfTeX error: /usr/local/bin/pdflatex (file tcrm0700): Font tcrm0700 at 600 not found') %==% font_ext('tcrm0700'))
58

9+
(length(detect_files("asdf qwer")) == 0)
610
(detect_files("! LaTeX Error: File `framed.sty' not found.") %==% 'framed.sty')
7-
811
(detect_files("/usr/local/bin/mktexpk: line 123: mf: command not found") %==% 'mf')
9-
10-
(grepl('^psyr\\[\\.\\]', detect_files("! Font U/psy/m/n/10=psyr at 10.0pt not loadable: Metric (TFM) file not found")))
11-
12-
(grepl('^FandolSong-Regular\\[\\.\\]', detect_files('! The font "FandolSong-Regular" cannot be found.')))
13-
14-
(grepl('^tcrm0700\\[\\.\\]', detect_files('!pdfTeX error: /usr/local/bin/pdflatex (file tcrm0700): Font tcrm0700 at 600 not found')))
15-
1612
(detect_files("or the language definition file ngerman.ldf was not found") %==% 'ngerman.ldf')
17-
1813
(detect_files("!pdfTeX error: pdflatex (file 8r.enc): cannot open encoding file for reading") %==% '8r.enc')
19-
2014
(detect_files("! CTeX fontset `fandol' is unavailable in current mode") %==% 'fandol')
21-
2215
(detect_files('Package widetext error: Install the flushend package which is a part of sttools') %==% 'flushend.sty')
23-
2416
(detect_files('! Package isodate.sty Error: Package file substr.sty not found.') %==% 'substr.sty')
25-
2617
(detect_files("! Package fontenc Error: Encoding file `t2aenc.def' not found.") %==% 't2aenc.def')
27-
2818
(detect_files("! I can't find file `hyph-de-1901.ec.tex'.") %==% 'hyph-de-1901.ec.tex')
2919
})

tests/test-travis/test-tlmgr.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ assert('`tlmgr info` can list the installed packages', {
1616
# only check a few basic packages
1717
(c('xetex', 'luatex', 'graphics') %in% res)
1818
})
19+
20+
assert('fonts package are correctly identified', {
21+
p_q <- function(...) parse_packages(..., quiet = c(TRUE, TRUE, TRUE))
22+
(p_q(text = "! Font U/psy/m/n/10=psyr at 10.0pt not loadable: Metric (TFM) file not found") %==% 'symbol')
23+
(p_q(text = '! The font "FandolSong-Regular" cannot be found.') %==% 'fandol')
24+
(p_q(text = '!pdfTeX error: /usr/local/bin/pdflatex (file tcrm0700): Font tcrm0700 at 600 not found') %==% 'ec')
25+
(p_q(text = '! Package fontspec Error: The font "Caladea" cannot be found.') %==% 'caladea')
26+
})

0 commit comments

Comments
 (0)