This function produces graphics compliant to the current w3 svg XML standard. The driver output is currently NOT specifying a DOCTYPE DTD.
Arguments
- filename
The file where output will appear.
- height, width
Height and width in inches.
- bg
Default background color for the plot (defaults to "white").
- pointsize
Default point size.
- standalone
Produce a standalone svg file? If
FALSE
, omits xml header and default namespace.- system_fonts
Consider using
systemfonts::register_font()
instead. Named list of font names to be aliased with fonts installed on your system. If unspecified, the R default familiessans
,serif
,mono
andsymbol
are aliased to the family returned byfont_info()
.- user_fonts
Consider using
systemfonts::register_font()
instead. Named list of fonts to be aliased with font files provided by the user rather than fonts properly installed on the system. The aliases can be fonts from the fontquiver package, strings containing a path to a font file, or a list containingname
andfile
elements withname
indicating the font alias in the SVG output andfile
the path to a font file.- web_fonts
A list containing web fonts to use in the SVG. The fonts will still need to be available locally on the computer running the code, but viewers of the final SVG will not need the font if specified as a web font. Web fonts can either be specified using
font_face()
or given as a single string in which case they are taken to be URL's for an@import
directive to e.g. Google Fonts.- id
A character vector of ids to assign to the generated SVG's. If creating more SVG files than supplied ids the exceeding SVG's will not have an id tag and a warning will be thrown.
- fix_text_size
Should the width of strings be fixed so that it doesn't change between svg renderers depending on their font rendering? Defaults to
TRUE
. IfTRUE
each string will have thetextLength
CSS property set to the width calculated by systemfonts andlengthAdjust='spacingAndGlyphs'
. Setting this toFALSE
can be beneficial for heavy post-processing that may change content or style of strings, but may lead to inconsistencies between strings and graphic elements that depend on the dimensions of the string (e.g. label borders and background).- scaling
A scaling factor to apply to the rendered line width and text size. Useful for getting the right sizing at the dimension that you need.
- always_valid
Should the svgfile be a valid svg file while it is being written to? Setting this to
TRUE
will incur a considerable performance hit (>50% additional rendering time) so this should only be set toTRUE
if the file is being parsed while it is still being written to.- file
Identical to
filename
. Provided for backward compatibility.
Details
svglite provides two ways of controlling fonts: system fonts
aliases and user fonts aliases. Supplying a font alias has two
effects. First it determines the font-family
property of all
text anchors in the SVG output. Secondly, the font is used to
determine the dimensions of graphical elements and has thus an
influence on the overall aspect of the plots. This means that for
optimal display, the font must be available on both the computer
used to create the svg, and the computer used to render the
svg. See the fonts
vignette for more information.
References
W3C Scalable Vector Graphics (SVG): https://www.w3.org/Graphics/SVG/
Author
This driver was written by T Jake Luciani jakeluciani@yahoo.com 2012: updated by Matthieu Decorde matthieu.decorde@ens-lyon.fr