Skip to content
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
5 changes: 4 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ knitr::opts_chunk$set(
<!-- badges: start -->
![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/cardargus) &nbsp;
![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/cardargus) &nbsp;
![License](https://img.shields.io/badge/license-MIT-darkviolet.svg)&nbsp; ![](https://img.shields.io/badge/devel%20version-0.2.4-blue.svg)
![License](https://img.shields.io/badge/license-MIT-darkviolet.svg)&nbsp; ![](https://img.shields.io/badge/devel%20version-0.2.5-blue.svg)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
<!-- badges: end -->

Expand Down Expand Up @@ -110,6 +110,9 @@ save_svg(card, "my_card.svg")

# Convert to high-quality PNG
svg_to_png(card, "my_card.png", dpi = 300)

# Convert to a vector PDF (via rsvg)
svg_to_pdf(card, "my_card.pdf")
```


Expand Down
9 changes: 6 additions & 3 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ reference:
contents:
- save_svg
- svg_to_png
- svg_to_pdf
- svg_to_png_with_margin
- svg_to_formats
- batch_svg_to_png
Expand Down
31 changes: 15 additions & 16 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
# cran-comments — cardargus 0.2.4
# cran-comments — cardargus 0.2.5

## Submission summary

This is a maintenance release submitted shortly after 0.2.3 to resolve the
additional `donttest` issue reported by the CRAN auto-check service for the
previously released version.
This is a minor feature release.

The issue: some examples (`install_fonts()`, `svg_to_png()`, `save_svg()`)
downloaded Google Fonts into the persistent user cache
(`tools::R_user_dir("cardargus", "cache")`), which writes to the user's home
filespace during checks when network access is available on the check machine.

The fix: `font_cache_dir()` now detects `R CMD check` via the
`_R_CHECK_PACKAGE_NAME_` environment variable and routes all font downloads to a
session-specific temporary directory. Examples, tests and vignettes therefore no
longer write anything under `~/.cache`. Interactive and normal use is unchanged
(the persistent cache remains the default).
* New `svg_to_pdf()` exports a card to a vector PDF via `rsvg::rsvg_pdf()`,
mirroring `svg_to_png()` (the SVG is sanitized and required fonts are embedded).
`save_card_for_knitr()` gains `format = "pdf"`, and `svg_to_formats()` reuses
`svg_to_pdf()` for the vector path.
* `magick` and `rsvg` moved from `Imports` to `Suggests`: they are only used for
raster/PDF export, which is already guarded with `requireNamespace()`. Examples
that need them are conditioned on the package being available, so the package
checks cleanly with `_R_CHECK_DEPENDS_ONLY_`.
* Minor fixes: `svg_card()` sizes badges using `value_fontsize` (no longer a
hard-coded `10`); `is_light_color()` reports an unknown color name via `cli`
instead of a raw `col2rgb()` error.

## R CMD check results

0 errors | 0 warnings | 0 notes

Verified locally with `R CMD check --as-cran --run-donttest`; the home cache
(`~/.cache/R/cardargus`) is left untouched by the check.
Verified locally with `R CMD check --as-cran --run-donttest`. The font cache fix
from 0.2.4 is retained: checks do not write to the user's home filespace.

## Test environments

Expand Down
Binary file modified man/figures/cardargus_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 35 additions & 3 deletions vignettes/export.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,51 @@ svg_to_png_with_margin(
)
```

## Converting to PDF

Both engines produce **vector** PDFs (text stays selectable and scales without
pixelation).

### Standard conversion (rsvg)

`svg_to_pdf()` mirrors `svg_to_png()`: it sanitizes the SVG, embeds the required
fonts, and writes a vector PDF via `rsvg::rsvg_pdf()`. No Chrome required.

```{r pdf-basic, eval=FALSE}
# Vector PDF (via rsvg)
svg_to_pdf(card, "my_card.pdf")
```

### Chrome-based conversion

Use `svg_to_pdf_chrome()` when you rely on web fonts loaded via `@import`:

```{r pdf-chrome, eval=FALSE}
if (chrome_available()) {
svg_to_pdf_chrome(card, "my_card.pdf")
}
```

PDF is also available from the knitr helper:

```{r pdf-knitr, eval=FALSE}
# Saves card.pdf using Chrome when available, else rsvg
save_card_for_knitr(card, format = "pdf")
```

## Multiple formats

Export to multiple formats at once:

```{r formats, eval=FALSE}
# Export to SVG and PNG
# Export to SVG, PNG and (vector) PDF
svg_to_formats(
card,
output_base = "exports/my_card", # Without extension
formats = c("svg", "png"),
formats = c("svg", "png", "pdf"),
dpi = 300
)
# Creates: exports/my_card.svg, exports/my_card.png
# Creates: exports/my_card.svg, exports/my_card.png, exports/my_card.pdf
```

## Batch processing
Expand Down