Skip to content

Commit 78d768c

Browse files
committed
run patcher again even if font_scale = 1 to allow resetting
1 parent 9891478 commit 78d768c

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

R/awesomecv.R

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,7 @@ awesomecv <- function(...,
3131
)
3232
set_entry_formats(awesome_cv_entries)
3333
copy_supporting_files("awesomecv")
34-
35-
if (!isTRUE(all.equal(font_scale, 1))) {
36-
cls_path <- "awesome-cv.cls"
37-
if (!file.exists(cls_path)) {
38-
stop("Expected 'awesome-cv.cls' in the working directory after copy_supporting_files().")
39-
}
40-
font_size_scaling(scale = font_scale, file_path = cls_path)
41-
}
42-
34+
font_size_scaling(scale = font_scale)
4335
pandoc_vars <- list()
4436
if(page_total) pandoc_vars$page_total <- TRUE
4537
if(show_footer) pandoc_vars$show_footer <- TRUE
@@ -80,6 +72,10 @@ awesome_cv_entries <- new_entry_formats(
8072
# Strategy: inject \usepackage{xfp} and \newcommand\ACVscale{<scale>},
8173
# then convert \fontsize{<n>pt}{...} -> \fontsize{\fpeval{<n>*\ACVscale}pt}{...}
8274
font_size_scaling <- function(scale = 1, file_path = "awesome-cv.cls") {
75+
if (!file.exists(file_path)) {
76+
stop("Expected 'awesome-cv.cls' in the working directory after copy_supporting_files().")
77+
}
78+
8379
stopifnot(is.numeric(scale), length(scale) == 1, scale > 0)
8480
if (!file.exists(file_path)) stop("File not found: ", file_path)
8581

tests/testthat/test-font-scale.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ test_that("awesomecv copies resources and conditionally patches class", {
3636
# No patch when font_scale = 1
3737
awesomecv(font_scale = 1)
3838
expect_true(file.exists("awesome-cv.cls"))
39-
base_cls <- readLines("awesome-cv.cls", warn = FALSE)
40-
expect_false(any(grepl("\\\\usepackage\\{xfp\\}", base_cls)))
41-
expect_false(any(grepl("\\\\ACVscale", base_cls)))
42-
expect_false(any(grepl("\\\\fontsize\\{\\\\fpeval\\{", base_cls)))
39+
patched <- readLines("awesome-cv.cls", warn = FALSE)
40+
expect_true(any(grepl("\\\\usepackage\\{xfp\\}", patched)))
41+
expect_true(any(grepl("\\\\renewcommand\\\\ACVscale\\{1\\.00", patched)))
42+
expect_true(any(grepl("\\\\fontsize\\{\\\\fpeval\\{[0-9.]+\\*\\\\ACVscale\\}pt\\}\\{", patched)))
4343

4444
# Patch when font_scale != 1
4545
awesomecv(font_scale = 1.05)

0 commit comments

Comments
 (0)