All Projects β†’ r-lib β†’ Svglite

r-lib / Svglite

A lightweight svg graphics device for R

Programming Languages

r
7636 projects

Labels

Projects that are alternatives of or similar to Svglite

Typesettable
πŸ“ A typesetting library for SVG and Canvas
Stars: ✭ 134 (-6.29%)
Mutual labels:  svg
Glyphs
A dynamic design system for managing large icon sets in Figma and using them on the web
Stars: ✭ 140 (-2.1%)
Mutual labels:  svg
Drawbot
Drawing robot capable of rendering SVG paths over WebSockets. Powered by a Raspberry Pi running Node.js.
Stars: ✭ 142 (-0.7%)
Mutual labels:  svg
Svg Sprite Loader
Webpack loader for creating SVG sprites.
Stars: ✭ 1,822 (+1174.13%)
Mutual labels:  svg
Svg
Useful SVGs
Stars: ✭ 137 (-4.2%)
Mutual labels:  svg
Svglib
Read SVG files and convert them to other formats.
Stars: ✭ 139 (-2.8%)
Mutual labels:  svg
React Designer
It's not art
Stars: ✭ 1,762 (+1132.17%)
Mutual labels:  svg
Coreui Icons
CoreUI Free Icons - Premium designed free icon set with marks in SVG, Webfont and raster formats
Stars: ✭ 1,813 (+1167.83%)
Mutual labels:  svg
Styled Icons
πŸ’… Popular icon packs like Font Awesome, Material Design, and Octicons, available as React Styled Components
Stars: ✭ 1,878 (+1213.29%)
Mutual labels:  svg
Alien.js
Future web pattern
Stars: ✭ 141 (-1.4%)
Mutual labels:  svg
React Content Loader
βšͺ SVG-Powered component to easily create skeleton loadings.
Stars: ✭ 11,830 (+8172.73%)
Mutual labels:  svg
Svgren
πŸ“· SVG rendering library in C++
Stars: ✭ 136 (-4.9%)
Mutual labels:  svg
Ijsvg
MacOS SVG rendering and exporting library
Stars: ✭ 139 (-2.8%)
Mutual labels:  svg
Dvisvgm
A fast DVI, EPS, and PDF to SVG converter
Stars: ✭ 134 (-6.29%)
Mutual labels:  svg
Pyecharts Snapshot
renders the output of pyecharts as png, jpeg, gif, svg, eps, pdf and raw base64
Stars: ✭ 142 (-0.7%)
Mutual labels:  svg
React Qr Svg
React component for rendering SVG QR codes
Stars: ✭ 134 (-6.29%)
Mutual labels:  svg
Circle Flags
A collection of 300+ minimal circular SVG country flags
Stars: ✭ 139 (-2.8%)
Mutual labels:  svg
Htmlrenderer
C# HTML Layout and HTML Rendering Engine
Stars: ✭ 143 (+0%)
Mutual labels:  svg
Myvuetest
ι’„θ§ˆι“ΎζŽ₯为前几δΈͺcommitsοΌŒζ„Ÿε…΄θΆ£ηš„ε―δ»₯ε›žι€€δΈ‹γ€‚
Stars: ✭ 143 (+0%)
Mutual labels:  svg
Plutovg
Tiny 2D vector graphics library in C
Stars: ✭ 141 (-1.4%)
Mutual labels:  svg

svglite

R build status Codecov test coverage CRAN Status Badge

svglite is a graphics device that produces clean svg output, suitable for use on the web, or hand editing. Compared to the built-in svg(), svglite produces smaller files, and leaves text as is, making it easier to edit the result after creation. It also support multiple nice features such as embedding of web fonts.

Installation

svglite is available on CRAN using install.packages("svglite"). You can install the development version from github with:

# install.packages("devtools")
devtools::install_github("r-lib/svglite")

Motivation

The grDevices package bundled with R already comes with an SVG device (using the eponymous svg() call). The development of svglite is motivated by the following considerations:

Speed

svglite() is considerably faster than svg(). If you are rendering SVGs dynamically to serve over the web this can be quite important:

library(svglite)

x <- runif(1e3)
y <- runif(1e3)
tmp1 <- tempfile()
tmp2 <- tempfile()

svglite_test <- function() {
  svglite(tmp1)
  plot(x, y)
  dev.off()
}
svg_test <- function() {
  svg(tmp2, onefile = TRUE)
  plot(x, y)
  dev.off()
}

bench::mark(svglite_test(), svg_test(), min_iterations = 250)
#> # A tibble: 2 x 6
#>   expression          min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>     <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 svglite_test()   3.31ms   3.87ms     247.      561KB     5.05
#> 2 svg_test()      10.57ms  12.19ms      76.3     177KB     1.24

File size

Another point with high relevance when serving SVGs over the web is the size. svglite() produces much smaller files

# svglite
fs::file_size(tmp1)
#> 74.9K

# svg
fs::file_size(tmp2)
#> 321K

In both cases, compressing to make .svgz (gzipped svg) is worthwhile. svglite supports compressed output directly which will be triggered if the provided path has a ".svgz" extension.

tmp3 <- tempfile(fileext = ".svgz")
svglite(tmp3)
plot(x, y)
invisible(dev.off())

# svglite - svgz
fs::file_size(tmp3)
#> 9.38K

Editability

One of the main reasons for the size difference between the size of the output of svglite() and svg() is the fact that svglite() encodes text as styled <text> elements, whereas svg() converts the glyphs to polygons and renders these. The latter approach means that the output of svg() does not require the font to be present on the system that displays the SVG but makes it more or less impossible to edit the text after the fact. svglite focuses on providing maximal editability of the output, so that you can open up the result in a vector drawing program such as Inkscape or Illustrator and polish the output if you so choose.

Font support

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.

Code of Conduct

Please note that the svglite project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].