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 = deprecated(),
svg = deprecated(),
local = NULL,
weight = NULL,
style = NULL,
range = NULL,
variant = NULL,
stretch = NULL,
feature_setting = NULL,
variation_setting = NULL,
embed = FALSE
)
The font family name this font should respond to.
URLs to the font in different formats. At least one must be given. Best browser support is provided by the woff format.
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.
An optional value for the font-weight
descriptor
An optional value for the font-style
descriptor
An optional value for the unicode-range
descriptor Will give
the range of unicode values that this font will support
An optional value for the font-variant
descriptor
An optional value for the font-stretch
descriptor
An optional value for the font-feature-settings
descriptor It is recommended to avoid using this if possible
An optional value for the font-variation-settings
descriptor.
Should the font data be embedded directly in the SVG
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 {
#> font-family: "MyHelvetica";
#> src: local("Helvetica Neue Bold"),
#> local("HelveticaNeue-Bold"),
#> url("") format("woff2"),
#> url("") format("woff"),
#> url("") format("opentype"),
#> url("MgOpenModernaBold.ttf") format("truetype");
#> font-weight: bold;
#> }