From bac2af836e479a68e4ce9abaf04d1f428daf1c3d Mon Sep 17 00:00:00 2001
From: Thomas Lin Pedersen <thomasp85@gmail.com>
Date: Wed, 23 Oct 2024 12:57:28 +0200
Subject: [PATCH] add note on building from source

---
 README.Rmd | 19 +++++++++++++++++++
 README.md  | 32 ++++++++++++++++++++++++++++----
 2 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/README.Rmd b/README.Rmd
index 8aaeb62..bdade7c 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -95,6 +95,25 @@ One of the main reasons for the size difference between the size of the output o
 
 svglite uses systemfonts for font discovery which means that all installed fonts on your system is available to use. The systemfonts foundation means that fonts registered with `register_font()` or `register_variant()` will also be available. If any of these contains non-standard weights or OpenType features (e.g. ligatures or tabular numerics) this will be correctly encoded in the style block. systemfonts also allows you to embed webfont `@imports` in your file to ensure that the file looks as expected even on systems without the used font installed.
 
+## Building svglite
+
+_This section is only relevant for building svglite from scratch, as opposed to installing from a pre-built package on CRAN._
+
+Building vdiffr requires the system dependency libpng. As vdiffr doesn't have any build-time configuration, your R configuration must point to libpng's `include` and `lib` folders.
+
+For instance on macOS, install libpng with:
+
+```sh
+brew install libpng
+```
+
+And make sure your `~/.R/Makevars` knows about Homebrew's `include` and `lib` folders where libpng should now be installed. On arm64 hardware, this would be:
+
+```mk
+CPPFLAGS += -I/opt/homebrew/include
+LDFLAGS += -L/opt/homebrew/lib
+```
+
 ## Code of Conduct
 
 Please note that the svglite project is released with a [Contributor Code of Conduct](https://svglite.r-lib.org/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
diff --git a/README.md b/README.md
index e251584..d8390d8 100644
--- a/README.md
+++ b/README.md
@@ -62,8 +62,8 @@ bench::mark(svglite_test(), svg_test(), min_iterations = 250, check = FALSE)
 #> # A tibble: 2 × 6
 #>   expression          min   median `itr/sec` mem_alloc `gc/sec`
 #>   <bch:expr>     <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
-#> 1 svglite_test()   2.08ms   2.23ms      438.     691KB    7.13 
-#> 2 svg_test()       6.07ms   6.26ms      159.     179KB    0.638
+#> 1 svglite_test()   1.47ms   1.53ms      648.     587KB    6.15 
+#> 2 svg_test()       6.19ms   6.42ms      155.     192KB    0.623
 ```
 
 ### File size
@@ -78,7 +78,7 @@ fs::file_size(tmp1)
 
 # svg
 fs::file_size(tmp2)
-#> 321K
+#> 327K
 ```
 
 In both cases, compressing to make `.svgz` (gzipped svg) is worthwhile.
@@ -93,7 +93,7 @@ invisible(dev.off())
 
 # svglite - svgz
 fs::file_size(tmp3)
-#> 9.42K
+#> 9.45K
 ```
 
 ### Editability
@@ -120,6 +120,30 @@ also allows you to embed webfont `@imports` in your file to ensure that
 the file looks as expected even on systems without the used font
 installed.
 
+## Building svglite
+
+*This section is only relevant for building svglite from scratch, as
+opposed to installing from a pre-built package on CRAN.*
+
+Building vdiffr requires the system dependency libpng. As vdiffr doesn’t
+have any build-time configuration, your R configuration must point to
+libpng’s `include` and `lib` folders.
+
+For instance on macOS, install libpng with:
+
+``` sh
+brew install libpng
+```
+
+And make sure your `~/.R/Makevars` knows about Homebrew’s `include` and
+`lib` folders where libpng should now be installed. On arm64 hardware,
+this would be:
+
+``` mk
+CPPFLAGS += -I/opt/homebrew/include
+LDFLAGS += -L/opt/homebrew/lib
+```
+
 ## Code of Conduct
 
 Please note that the svglite project is released with a [Contributor