diff --git a/README.Rmd b/README.Rmd index a9227a7..16684d2 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,7 +19,7 @@ knitr::opts_chunk$set( ![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/cardargus)   ![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/cardargus)   -![License](https://img.shields.io/badge/license-MIT-darkviolet.svg)  ![](https://img.shields.io/badge/devel%20version-0.2.4-blue.svg) +![License](https://img.shields.io/badge/license-MIT-darkviolet.svg)  ![](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) @@ -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") ``` diff --git a/README.md b/README.md index dad2726..34874a1 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/cardargus)   ![License](https://img.shields.io/badge/license-MIT-darkviolet.svg)  -![](https://img.shields.io/badge/devel%20version-0.2.4-blue.svg) +![](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) @@ -99,7 +99,7 @@ include_card_png(card, dpi = 300, width = '50%')
-Card generated by cardargus +Card generated by cardargus
@@ -109,6 +109,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") ``` ## Displaying Cards in R Markdown / Quarto @@ -219,7 +222,7 @@ card <- svg_card(
-Card generated by cardargus +Card generated by cardargus
diff --git a/_pkgdown.yml b/_pkgdown.yml index b30e820..d9e767d 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -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 diff --git a/cran-comments.md b/cran-comments.md index cb0bce7..9024d24 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -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 diff --git a/man/figures/cardargus_card.png b/man/figures/cardargus_card.png index 4186708..59ef72e 100644 Binary files a/man/figures/cardargus_card.png and b/man/figures/cardargus_card.png differ diff --git a/vignettes/export.Rmd b/vignettes/export.Rmd index 2f33143..05855eb 100644 --- a/vignettes/export.Rmd +++ b/vignettes/export.Rmd @@ -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