showtext_opts {showtext} | R Documentation |
Setting Options for 'showtext' package
Description
The two versions of this function are equivalent, but the "underscore" naming is preferred.
This function sets parameters that will affect the appearance of the graphs created with showtext.
Usage
showtext_opts(...)
showtext.opts(...)
Arguments
... |
Options to be set, expressed in |
Options Used
nseg
Parameter to control the smoothness of the outlines of glyphs, typically used in vector graphics devices such as
pdf()
andsvg()
. It is the number of line segments to approximate a piece of curve in the glyph. The largernseg
is, the smoother text outlines would be, but also with larger file size for vector graphics. Usually a value between 5~20 would be enough.dpi
An integer that gives the resolution of the device. This parameter is only used in bitmap and on-screen graphics devices such as
png()
andx11()
, to determine the pixel size of text from point size. For example, ifdpi
is set to 96, then a character with 12 point size will have a pixel size of12 * 96 / 72 = 16
.
Author(s)
Yixuan Qiu <https://statr.me/>
Examples
## Not run:
## Set dpi to 200
op = showtext_opts(dpi = 200)
png("dpi_200.png", 800, 800, res = 200)
par(family = "sans")
showtext_begin()
set.seed(123)
plot(density(rnorm(100)))
showtext_end()
dev.off()
## Restore old options
showtext_opts(op)
png("dpi_96.png", 800, 800, res = 96)
par(family = "sans")
showtext_begin()
set.seed(123)
plot(density(rnorm(100)))
showtext_end()
dev.off()
## End(Not run)