Title: | An 'SVG' Graphics Device |
---|---|
Description: | A graphics device for R that produces 'Scalable Vector Graphics'. 'svglite' is a fork of the older 'RSvgDevice' package. |
Authors: | Hadley Wickham [aut], Lionel Henry [aut], Thomas Lin Pedersen [cre, aut] , T Jake Luciani [aut], Matthieu Decorde [aut], Vaudor Lise [aut], Tony Plate [ctb] (Early line dashing code), David Gohel [ctb] (Line dashing code and early raster code), Yixuan Qiu [ctb] (Improved styles; polypath implementation), Håkon Malmedal [ctb] (Opacity code), Posit, PBC [cph, fnd] |
Maintainer: | Thomas Lin Pedersen <[email protected]> |
License: | GPL (>= 2) |
Version: | 2.1.3 |
Built: | 2024-11-25 06:51:51 UTC |
Source: | CRAN |
Webfonts in SVG and HTML can either be specified manually using the
@font-face
at-rule, or imported from e.g. Google Fonts using the @import
at-rule. font_face()
helps you create a valid @font-face
block for the
web_fonts
argument in svglite()
and svgstring()
functions.
font_face( family, woff2 = NULL, woff = NULL, ttf = NULL, otf = NULL, eot = NULL, svg = NULL, local = NULL, weight = NULL, style = NULL, range = NULL, variant = NULL, stretch = NULL, feature_setting = NULL, variation_setting = NULL )
font_face( family, woff2 = NULL, woff = NULL, ttf = NULL, otf = NULL, eot = NULL, svg = NULL, local = NULL, weight = NULL, style = NULL, range = NULL, variant = NULL, stretch = NULL, feature_setting = NULL, variation_setting = NULL )
family |
The font family name this font should respond to. |
woff2 , woff , ttf , otf , eot , svg
|
URLs to the font in different formats. At least one must be given. Best browser support is provided by the woff format. |
local |
One or more font names that local installations of the font may have. If a local font is found with either of the given names it will be used and no download will happen. |
weight |
An optional value for the |
style |
An optional value for the |
range |
An optional value for the |
variant |
An optional value for the |
stretch |
An optional value for the |
feature_setting |
An optional value for the |
variation_setting |
An optional value for the |
A character string with the @font-face
block.
font_face( family = "MyHelvetica", ttf = "MgOpenModernaBold.ttf", local = c("Helvetica Neue Bold", "HelveticaNeue-Bold"), weight = "bold" )
font_face( family = "MyHelvetica", ttf = "MgOpenModernaBold.ttf", local = c("Helvetica Neue Bold", "HelveticaNeue-Bold"), weight = "bold" )
This function produces graphics compliant to the current w3 svg XML standard. The driver output is currently NOT specifying a DOCTYPE DTD.
svglite( filename = "Rplot%03d.svg", width = 10, height = 8, bg = "white", pointsize = 12, standalone = TRUE, system_fonts = list(), user_fonts = list(), web_fonts = list(), id = NULL, fix_text_size = TRUE, scaling = 1, always_valid = FALSE, file )
svglite( filename = "Rplot%03d.svg", width = 10, height = 8, bg = "white", pointsize = 12, standalone = TRUE, system_fonts = list(), user_fonts = list(), web_fonts = list(), id = NULL, fix_text_size = TRUE, scaling = 1, always_valid = FALSE, file )
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 |
system_fonts |
Consider using
|
user_fonts |
Consider using
|
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 |
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
|
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 |
file |
Identical to |
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.
This driver was written by T Jake Luciani [email protected] 2012: updated by Matthieu Decorde [email protected]
W3C Scalable Vector Graphics (SVG): https://www.w3.org/Graphics/SVG/
# Save to file svglite(tempfile("Rplots.svg")) plot(1:11, (-5:5)^2, type = "b", main = "Simple Example") dev.off()
# Save to file svglite(tempfile("Rplots.svg")) plot(1:11, (-5:5)^2, type = "b", main = "Simple Example") dev.off()
This is a variation on svglite
that makes it easy to access
the current value as a string.
svgstring( width = 10, height = 8, bg = "white", pointsize = 12, standalone = TRUE, system_fonts = list(), user_fonts = list(), web_fonts = list(), id = NULL, fix_text_size = TRUE, scaling = 1 )
svgstring( width = 10, height = 8, bg = "white", pointsize = 12, standalone = TRUE, system_fonts = list(), user_fonts = list(), web_fonts = list(), id = NULL, fix_text_size = TRUE, scaling = 1 )
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 |
system_fonts |
Consider using
|
user_fonts |
Consider using
|
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 |
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
|
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. |
See svglite()
documentation for information about
specifying fonts.
A function with no arguments: call the function to get the current value of the string.
s <- svgstring() s() plot.new() s() text(0.5, 0.5, "Hi!") s() dev.off() s <- svgstring() plot(rnorm(5), rnorm(5)) s() dev.off()
s <- svgstring() s() plot.new() s() text(0.5, 0.5, "Hi!") s() dev.off() s <- svgstring() plot(rnorm(5), rnorm(5)) s() dev.off()