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

Add ability to pass arguments to dvisvgm through engine.opts (fixes #2038) #2039

Merged
merged 4 commits into from
Aug 28, 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: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- For the `tikz` engine, the class options of the `standalone` document classs can be specified via the chunk option `engine.opts$classoption` (thanks, @XiangyunHuang, #1985). The default value is `tikz`, i.e., `\documentclass[tikz]{standalone}` is used by default.

- Added the ability to pass additional arguments to `dvisvgm` when using the `tikz` engine with `fig.ext = "svg"` by using `dvisvgm.opts` in `engine.opts` (thanks, @andrewheiss, #2039). Recent versions of `dvisvgm` now allow you to embed fonts into SVG files as base64-encoded WOFF files, so `tikz` chunks can embed fonts using like so: ```` ```{tikz, fig.ext="svg", engine.opts=list(dvisvgm.opts = "--font-format=woff")}````.

- Added a new `targets` engine (https://github.com/ropensci/targets/issues/503, @wlandau). Details: https://books.ropensci.org/targets/markdown.html.

- The [chunk option `cache.globals`](https://yihui.org/knitr/options/) can take values `TRUE` and `FALSE` now (in addition to a character vector). When `FALSE`, it tries to find all symbols in the code chunk, no matter if they are local or global variables. When `NULL` or `TRUE`, it tries to find all global variables (thanks, @knokknok, #1898).
Expand Down
5 changes: 3 additions & 2 deletions R/engine.R
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,9 @@ eng_tikz = function(options) {
# dvisvgm needs to be on the path
# dvisvgm for windows needs ghostscript bin dir on the path also
if (Sys.which('dvisvgm') == '') tinytex::tlmgr_install('dvisvgm')
if (system2('dvisvgm', c('-o', shQuote(fig2), fig)) != 0)
stop('Failed to compile ', fig, ' to ', fig2)
if (system2('dvisvgm', c(
options$engine.opts$dvisvgm.opts, '-o', shQuote(fig2), fig
)) != 0) stop('Failed to compile ', fig, ' to ', fig2)
} else {
# convert to the desired output-format using magick
if (ext != 'pdf') magick::image_write(do.call(magick::image_convert, c(
Expand Down